-
Notifications
You must be signed in to change notification settings - Fork 539
/
formdata.test-d.ts
27 lines (24 loc) · 1.26 KB
/
formdata.test-d.ts
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
import { Blob } from 'buffer'
import { Readable } from 'stream'
import { expectAssignable, expectType } from 'tsd'
import { File, FormData, SpecIterableIterator } from '../..'
import Dispatcher from '../../types/dispatcher'
declare const dispatcherOptions: Dispatcher.DispatchOptions
declare const blob: Blob
const formData = new FormData()
expectType<FormData>(formData)
expectType<void>(formData.append('key', 'value'))
expectType<void>(formData.append('key', blob))
expectType<void>(formData.set('key', 'value'))
expectType<void>(formData.set('key', blob))
expectType<File | string | null>(formData.get('key'))
expectType<File | string | null>(formData.get('key'))
expectType<Array<File | string>>(formData.getAll('key'))
expectType<Array<File | string>>(formData.getAll('key'))
expectType<boolean>(formData.has('key'))
expectType<void>(formData.delete('key'))
expectAssignable<SpecIterableIterator<string>>(formData.keys())
expectAssignable<SpecIterableIterator<File | string>>(formData.values())
expectAssignable<SpecIterableIterator<[string, File | string]>>(formData.entries())
expectAssignable<SpecIterableIterator<[string, File | string]>>(formData[Symbol.iterator]())
expectAssignable<string | Buffer | Uint8Array | FormData | Readable | undefined | null>(dispatcherOptions.body)