summaryrefslogtreecommitdiff
path: root/tests/index.test-d.ts
blob: ef9669aabcdb666375ba25dbffe4bd5ee8155bc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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())
}