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.
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 support for
import defer
proposal #60757base: main
Are you sure you want to change the base?
Add support for
import defer
proposal #60757Changes from 1 commit
de82ce7
9e43939
b1f506b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Preemptively noting that this is a breaking API change, and would require a deprecation helper in the deprecations project to tack onto our public API something that will set a default for the new parameter.
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.
It may also be the case that
phase
needs to go afterisTypeOnly
since AST node builder parameters and properties are intended to be in source order.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 want to mix
type
imports withdefer
orsource
. Something likeimport type source foo from "foo"
doesn't make sense if allsource
imports will have the same type, andimport type defer * as foo from "foo"
would essentially be the same asimport type * as foo from "foo"
.If we consider
type
,defer
, andsource
to be mutually exclusive, then I would suggest we replace theisTypeOnly
parameter with something likeimportModifier: SyntaxKind.TypeKeyword | SyntaxKind.DeferKeyword | SyntaxKind.SourceKeyword | boolean | undefined
and haveImportClause
be:For back-compat purposes, we can set
isTypeOnly
totrue
ifimportModifier
isSyntaxKind.TypeKeyword
.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 think the issue with that scheme is that it's a little weirder to capture multiple modifiers being used in the cases of error recovery.
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 was originally going with something very similar to Ron's suggestion, and consider "type" just as another phase. I ended up not doing it because of the AST breaking change, but if just keeping the old property for backwards compat is ok then I'd go for it.
Error recovery is going to be tricky anyway, because each modifier is a valid identifier so things like
import type defer
are a potentially valid start of an import declaration. I wonder how likely it is for people to accidentally write two modifiers in an import.