用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
819 B

6 months ago
  1. import { expectType } from 'tsd';
  2. import { curl } from '..';
  3. // curl
  4. expectType<Buffer>((await curl<Buffer>('http://a.com')).data);
  5. // RequestOptions
  6. expectType<Buffer>((await curl<Buffer>('http://a.com', {})).data);
  7. expectType<string>((await curl<string>('http://a.com', {
  8. method: 'HEAD',
  9. })).data);
  10. expectType<string>((await curl<string>('http://a.com', {
  11. method: 'head',
  12. })).data);
  13. // HttpClientResponse
  14. const res = await curl<Buffer>('http://a.com');
  15. expectType<number | undefined>(res.res.timing?.queuing);
  16. expectType<number | undefined>(res.res.timing?.dnslookup);
  17. expectType<number | undefined>(res.res.timing?.connected);
  18. expectType<number | undefined>(res.res.timing?.requestSent);
  19. expectType<number | undefined>(res.res.timing?.waiting);
  20. expectType<number | undefined>(res.res.timing?.contentDownload);