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
added fetch api type definitions extracted from official dom lib using ts-graft #93
Conversation
.gitignore
Outdated
@@ -2,6 +2,7 @@ | |||
*.log | |||
test.ponyfill.js | |||
test.polyfill.js | |||
dom.d.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why we would ignore this file. will it change every time ts-graft
runs?
package.json
Outdated
@@ -77,13 +77,16 @@ | |||
"serve-index": "1.9.1", | |||
"sinon": "9.2.4", | |||
"standard": "16.0.3", | |||
"ts-graft": "1.0.1", | |||
"typescript": "4.2.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need the typescript
dependency here.
Makefile
Outdated
@@ -4,7 +4,7 @@ node_modules: package.json | |||
npm install && /usr/bin/touch node_modules | |||
|
|||
build: node_modules | |||
npx rollup -c && /usr/bin/touch dist | |||
npx ts-graft && npx rollup -c && /usr/bin/touch dist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels overkill to me. there's no need to run that command on every build.
.ts-graftrc.js
Outdated
grafts: [ | ||
{ | ||
source: "typescript/lib/lib.dom.d.ts", | ||
output: "dom.d.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's call it lib.fetch.d.ts
@lquixada thanks for the speedy review! The typescript library needs to be available to provide WRT to change frequency, the output will only change if the version of typescript changes and the new version has a different Admittedly, it is inefficient to generate the file on every build, but that is the easy way of demonstrating its provenance. If someone were inclined to publish the output of lib files as a library, we could just consume the transformed version as a plain type definition file. That would be nice... If you prefer that I generate and commit |
@jstewmon giving it a second thought here. Automation is good but it brings overhead: dependencies, configurations, increased build time. I feel we should keep things as simple as possible by just adding the generated Depending on how often the type definition changes, we could introduce |
@lquixada SGTM. I squashed everything down to one commit that I hope reflects what you wanted. I included a small shell "one-liner" in the commit message that can be used to reproduce |
@jstewmon LGTM! I just need the commit message and the PR title to reflect the new changes. Something like "added fetch api type definitions extracted from official dom lib using ts-graft." |
…g ts-graft lib.fetch.d.ts includes all types from the dom lib needed to define the fetch function and the Request, Response, and Headers classes. The file was generated by ts-graft as follows: npm i --no-save typescript@4.2.3 \ && cat <<EOF > .ts-graftrc.yaml \ && npx ts-graft@1.0.1 \ && rm .ts-graftrc.yaml \ && npm un typescript grafts: - source: typescript/lib/lib.dom.d.ts output: lib.fetch.d.ts include: [RequestInfo, RequestInit, Response] EOF
Although the security check failed, it is due to a limitation on Github Actions passing secrets to PRs on forks. I'm merging it any way as it will get checked on the main branch. PR looks great! Thanks @jstewmon ! |
🎉 Can we get a release soon? I have time this week-end to open PRs against reverse-dependencies. |
@LilRed done! |
Thank you very much! |
We're using Typescript and this PR and release is breaking our build.
|
@pitgrap Sorry about that. #96 should resolve - I added a compilation check to the shell command I used to generate the lib file. The problem was introduced when I copied the constructor signatures. The missing types weren't reachable from the interface definitions, and I forgot to list the types used by those signatures in the graft config. |
This PR demonstrates how we could address #70 with ts-graft.