diff options
| author | Li Zhineng <[email protected]> | 2025-07-23 21:15:21 +0800 |
|---|---|---|
| committer | Li Zhineng <[email protected]> | 2025-07-23 21:15:21 +0800 |
| commit | b2584c0e805476a971d24e22350caf3875b42dd0 (patch) | |
| tree | 258f2679b2d2aa85802ee6284e5faf0ad45f562b /tests/index.test-d.ts | |
| parent | 2f6bfbcaff5b35d9fd14563f1e2892dbf040646e (diff) | |
| download | wave-b2584c0e805476a971d24e22350caf3875b42dd0.tar.gz wave-b2584c0e805476a971d24e22350caf3875b42dd0.zip | |
test types
Diffstat (limited to 'tests/index.test-d.ts')
| -rw-r--r-- | tests/index.test-d.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/index.test-d.ts b/tests/index.test-d.ts new file mode 100644 index 0000000..52df93c --- /dev/null +++ b/tests/index.test-d.ts @@ -0,0 +1,32 @@ +import { expectType } from 'tsd' +import { Client } from '../src' + +interface User { + name: string +} + +;async () => { + const response = await Client.new().get('http://example.com') + expectType<WechatMiniprogram.RequestSuccessCallbackResult['data']>( + response.data() + ) +} + +;async () => { + const response = await Client.new().get<User>('http://example.com') + expectType<User>(response.data()) +} + +;async () => { + const response = await Client.new().get<string>('http://example.com/string') + expectType<string>(response.data()) +} + +;async () => { + const response = await Client.new().upload({ + url: 'http://example.com', + filePath: '/tmp/foo.txt', + name: 'file' + }) + expectType<string>(response.data()) +} |
