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
Import assertion #40698
Import assertion #40698
Changes from 31 commits
e1b3b78
66d2273
5f3cea6
5a1af04
4b51ca9
375b433
41a881c
46a3eb1
a484ea2
d64f7ba
68c8c5d
29fe0d3
adcfd1b
fb01eb3
4f22a60
f5e594d
60434d1
ff87d3e
43b67b9
c69a05b
d1c48b5
d14f93a
aa8b856
7a5ec34
9cea9cf
6337a7e
eee2cab
2857d69
88e39d5
f941d92
106ff06
7df4964
6ea3c55
fc51c42
bf7ca71
463138a
b07c6e9
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.
Do we need to check that all elements of the
assert
property of the second argument have typestring
? Per https://tc39.es/proposal-import-assertions/#sec-evaluate-import-call, Step 10.d.v.3:No coercion to string is performed here, the algorithm explicitly checks for strings.
We might want to consider something like the
ImportMeta
interface for the import argument, something like:Then we can check against the global
ImportCallOptions
type, and if other assertions or options are added later, they can be introduced using global augmentation similar toImportMeta
.We could consider this as a follow-on PR if necessary, but it would be nice to have.
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.
NOTE: if we wanted to be more specific with
type
we'd need to create an open-ended union via an interface as well:That way, we have better completions for
type
and if a host environment supported other values fortype
, they could also be added via augmentation, i.e.: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.
Also, the
nodeArguments.length
check shouldn't be necessary ifcheckGrammarImportCallArguments
already asserts thatnodeArguments.length
can't be zero.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.
We also need to ensure that
nodeArguments[1]
(if present) is not a spread element.I would suggest this approach:
That way it checks all arguments, but only reports on the first error (which is almost always the case for grammar errors).
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.
Should we check the assert clause too?Or just the second parameter of dynamic import.
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.
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.
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.
Agree, but I think
module specifier
is a more correct term thanpath