diff options
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()) +} |
