From 8401e573dd2355b3a1ebe46b8083f8a17c5af295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=9A=E7=90=AA?= Date: Sat, 27 Jul 2024 19:53:11 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0JSON.parse=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/JSON.uts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 1b1e348..4bdd1d4 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.uts @@ -404,5 +404,16 @@ export function testJSON() : Result { expect(map?.get('a')?.num).toEqual(1) }) + test('parse generic type', () => { + type A = { + num: number, + } + function test(json: string): T { + return JSON.parse(json)! + } + const a = test(`{"num": 1}`) + expect(a.num).toEqual(1) + }) + }) } \ No newline at end of file -- GitLab