提交 8401e573 编写于 作者: 雪洛's avatar 雪洛

test: 增加JSON.parse测试例

上级 c22d0401
...@@ -404,5 +404,16 @@ export function testJSON() : Result { ...@@ -404,5 +404,16 @@ export function testJSON() : Result {
expect(map?.get('a')?.num).toEqual(1) expect(map?.get('a')?.num).toEqual(1)
}) })
test('parse generic type', () => {
type A = {
num: number,
}
function test<T>(json: string): T {
return JSON.parse<T>(json)!
}
const a = test<A>(`{"num": 1}`)
expect(a.num).toEqual(1)
})
}) })
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册