Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Mar 19, 2021

Conversation

jstewmon
Copy link
Contributor

@jstewmon jstewmon commented Mar 18, 2021

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.

index.d.ts Outdated
HeadersInit,
Request,
RequestInfo,
RequestInit,
Response,
ResponseInit,
} from "./lib.fetch"
import type { Headers as IterHeaders } from "./lib.fetch.dom.iterable";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should abbreviate the file name to lib.fetch.iterable

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, don't forget to add this file to the files property on package.json

test.ts Outdated
const headers = new Headers();
for (const h of headers) {

}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this file won't be needed anymore.

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
@lquixada lquixada merged commit 58b7b11 into lquixada:main Mar 19, 2021
@lquixada
Copy link
Owner

thanks @jstewmon ! great job! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Types of property 'headers' are incompatible (with new 3.1.0)
2 participants