-
Notifications
You must be signed in to change notification settings - Fork 2
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
Bump typescript from 5.1.6 to 5.2.2 #460
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
For context, as the failing build log will eventually expire, this is the error message:
This error is new to TypeScript 5.2.2, and comes from this PR: microsoft/TypeScript#54567 .
The relevant bits of configuration from
@tsconfig/node18/tsconfig.json
:This was also recently changed: in tsconfig/bases#197, which we brought in via #453 .
I do not yet fully understand the consequences of opting in to
node16
formodule
andmoduleResolution
(see also the docs formodule
intsconfig.json
). My concern is that we'd be opening the door to ESM, which I would very much like to avoid.I'll keep researching, but wanted to document how we got to this question in the first place. Despite being a single line change, this is a complicated situation!
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.
@jasonaowen thanks for doing this research -- once the dust settles I'll make sure to update the commit message with the information (and add you as a co-author)
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.
Reading through https://www.typescriptlang.org/docs/handbook/esm-node.html, it looks like Node16 means typescript SUPPORTS ESM, not that it must be ESM. Specifically, Node16 means that if
type: 'module'
is defined inpackage.json
then typescript will start to flag ESM errors.This is why the PR does not currently error (we don't specify
type
in package.json so it is using the default, which iscommonjs
).If we add
"type": "module"
topackage.json
then running build results in tons of ESM errors:This is corroborated with the TS documentation Which notes:
Bottom line is I think it's safe to merge this. We might consider also explicitly setting
"type": "commonjs"
in thepackage.json
.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.
Thank you, @slifty! I think that matches my initial research.
"type": "commonjs"
? if not, I really like that idea!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.
@jasonaowen
This is a great question! I'll test it out (my theory is no since it has to be able to compile to common js. stay tuned to find out)
My understanding of the documentation of
type
is that omission is the same as explicitly setting tocommonjs
so let's do it!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 behavior on this branch appears to the same as
main
regarding esm-only modules still error in the same as onmain
. I tried installingnode-fetch
on both and in both cases it triggered the same output when runningbuild
both for whenpackage.json
contained"type": "commonjs"
and"type": "module"
.This makes sense to me because the way imports are processed is dictated by the
moduleResolution
setting (as opposed to themodule
setting). ThemoduleResolution
is the same on this branch and onmain (it is
Node16`).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.
Thank you for following up on this, @slifty!
Note that that changed recently, in #412 - previously the
moduleResolution
wasnode
, which the TypeScript docs describe asI ran through the manual test you described with commit 86ea0c9 (the parent commit of #412), and the new behavior is better: previously, it would successfully build, but then at runtime say
So, +1 to this change, and thanks again @slifty for digging in!