-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Verify types.d.ts after generation #16703
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The TypeScript you're suggesting has broken imports of the data on Yari, because it's trying to map
__compat
to anIdentifier
type. Are you sure this is the right way to do this?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 is just a manual definition of
Record<string, Identifier>
. It's semantically no different thanRecord<>
, except it allows recursive reference. Note that this does not fail the test added by #16685.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.
With this TypeScript type, however, we run into the following error on Yari:
The same issue occurs in a simplified test environment that uses the
tsconfig.json
from this project and includes anindex.ts
that just containsimport bcd from "@mdn/browser-compat-data";
.The more I work with TypeScript, the more I hate itThere 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.
Tried to build Yari but it's broken in another way 🤔
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.
Good old code problems left and right... 🙃
I have a pull request open that uses an updated version of BCD (which includes the error I screenshotted up above), if you'd like to try mdn/yari#6490 out?
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.
(
__compat!
is probably not a real fix, but anyway)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.
You'll want to check the logs in the "Testing Yari" CI test: https://github.com/mdn/yari/runs/6906221112?check_suite_focus=true
(I'm aware of the other two issues reported by the tests, I plan to fix those at a later time, once this issue is resolved!)
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.
Hmm, I got what happened on Yari with your trial to fix:
It just made it to
any
, and that was hidden byskipLibCheck
in Yari's tsconfig. 🙂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 see, that makes sense -- so either way, it's broken...argh. This is honestly making me want to just give up on TypeScript altogether.
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.
Alright, I'm going to go ahead and merge this PR as-is with the reverted change, and then going to follow-up with updating the default TS export to cast to
any
first. I understand that's very bad to do and may result in unintended typecasts, but at this point, TypeScript users cannot use newer versions of BCD, including Yari.