lquixada / cross-fetch

Universal WHATWG Fetch API for Node, Browsers and React Native.
MIT License
1.67k stars 104 forks source link

add missing Headers interface augmentation from lib.dom.iterable.d.ts #97

Closed jstewmon closed 3 years ago

jstewmon commented 3 years ago

Added test.ts to support type checking the type declaration files.

declaration files were generated and tested with the following command:

npm i --no-save typescript@4.2.3 \
&& cat <<EOF > .ts-graftrc.yaml \
&& npx ts-graft@1.0.1 \
&& rm .ts-graftrc.yaml \
&& npx tsc --lib ES2016 --target ES2016 --noEmit index.d.ts \
&& npm un typescript
grafts:
- source: typescript/lib/lib.dom.d.ts
  output: lib.fetch.d.ts
  include:
    - BodyInit
    - HeadersInit
    - RequestInfo
    - RequestInit
    - Response
    - ResponseInit
- source: typescript/lib/lib.dom.iterable.d.ts
  output: lib.fetch.dom.iterable.d.ts
  include:
    - Headers
EOF

Fixes #95

Until ts-graft can automatically merge the declarations, I thought the easy fix for now is to graft each lib file and combine the declarations manually in index.d.ts.

lquixada commented 3 years ago

thanks @jstewmon ! great job! 👍