Skip to content

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

Merged
lquixada merged 1 commit into
lquixada:mainfrom
jstewmon:fix-iter-headers
Mar 19, 2021
Merged

add missing Headers interface augmentation from lib.dom.iterable.d.ts#97
lquixada merged 1 commit into
lquixada:mainfrom
jstewmon:fix-iter-headers

Conversation

@jstewmon

@jstewmon jstewmon commented Mar 18, 2021

Copy link
Copy Markdown
Contributor

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.

Comment thread index.d.ts Outdated
Response,
ResponseInit,
} from "./lib.fetch"
import type { Headers as IterHeaders } from "./lib.fetch.dom.iterable";

Copy link
Copy Markdown
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
Copy Markdown
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

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

}

Copy link
Copy Markdown
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
@jstewmon jstewmon requested a review from lquixada March 19, 2021 19:41
@lquixada lquixada merged commit 58b7b11 into lquixada:main Mar 19, 2021
@lquixada

Copy link
Copy Markdown
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