summaryrefslogtreecommitdiff
path: root/tests/index.test-d.ts
blob: 52df93c04eabd8dc2e01757d83760ef68fd35317 (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
30
31
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())
}