hexo/node_modules/urllib/lib/index.test-d.ts

23 lines
841 B
TypeScript
Raw Normal View History

2023-10-03 11:14:36 +08:00
import { expectType } from 'tsd';
import { curl } from '..';
// curl
expectType<Buffer>((await curl<Buffer>('http://a.com')).data);
// RequestOptions
expectType<Buffer>((await curl<Buffer>('http://a.com', {})).data);
expectType<string>((await curl<string>('http://a.com', {
method: 'HEAD',
})).data);
expectType<string>((await curl<string>('http://a.com', {
method: 'head',
})).data);
// HttpClientResponse
const res = await curl<Buffer>('http://a.com');
expectType<number | undefined>(res.res.timing?.queuing);
expectType<number | undefined>(res.res.timing?.dnslookup);
expectType<number | undefined>(res.res.timing?.connected);
expectType<number | undefined>(res.res.timing?.requestSent);
expectType<number | undefined>(res.res.timing?.waiting);
expectType<number | undefined>(res.res.timing?.contentDownload);