Description
import emit in module: none Emit for dynamic import (import()) when target >= ES2020 and module == None #48702
Today, import in module: none + outFile produces an async require
This makes no sense per the config flags
But it could work, so someone might be doing it anyway
Seems like this is just a bug, but there may be people depending on it
There's no combination of flags that would allow this if we "fix" it
Q: ES2020 is the first version that supports dynamic import? A: Yes
What is module: none supposed to do?
We used to emit CommonJS because we had to do "something", and this requirement predated ES modules
How does this scenario work if we transition the TS codebase to modules?
It should be OK since we can emit to nodenext
Q: Do we have any untransformed imports today? A: No
Q: Is potentially this a problem? A: Not today (used to be)
What problem are we trying to solve and in what scope?
Is it actually a 4.7 deliverable?
Do we need to just do a one-off hack here?
Q: Can we use nodenext module target? A: No, because we use outFile
We handled dynamic import wrong, basically
Options on the table
"Just fix this"; potentially break some builds. Broken builds can use require instead
Build-time hack (e.g. write IMPORT, change to import)
New (undocumented) flag
Q: Why not provide this behavior under commonjs?
Specifying module and outFile simultaneously is an error because it's a really dangerous configuration
Posited: We should do other fixes in module: none, e.g. handling import declarations, in 4.8
Consensus: "Just fix this", in 4.8 branch (to avoid breaks in RC period)
If VS Code needs something in release before 4.7, we can buildhack
Parser Problems allow PrivateIdentifier in QualifiedName #48640
We added support for typeof a.#foo
The PR had an incorrect type assertion
API change: QualifiedName now includes MemberName instead of Identifier
We could change the typeof operand type instead?
Problems with Parsers [4.7-beta] Parsing failure for arrow function expr in conditional expr #48733
(false ? (param): string => param: null);
Is the : a type annotation, or the colon in the form x ? y: z ?
The former turns out to be pretty common
The parser has a heuristic based on looking two (?) tokens ahead, but this is insufficient
The code a ? (n) : m => expr is ambiguous until you get to the end of the expr and see that the : is missing
This is an unbounded lookahead
a ? (b) : c => (d) : e => f means what ?
Proposal: Parentheses policing preferred, per personnel's palaver
We parse this wrong in JS
Some cases to consider for consistency
Unambiguous (?): a ? (): b => c : d
Ambiguous (?): a ? (x): b => c : d
Unambiguous (?):a ? (x: y): b => c : d
Ambiguous (?): a ? (x, z): b => c : d
Put up an "expression-preferring" Playground and try it out
Reactions are currently unavailable
You can’t perform that action at this time.
importemit inmodule: noneEmit for dynamic import (import()) when target >= ES2020 and module == None #48702importinmodule: none+outFileproduces an asyncrequirerequireinsteadIMPORT, change toimport)module: none, e.g. handling import declarations, in 4.8Parser Problems allow PrivateIdentifier in QualifiedName #48640
typeof a.#fooQualifiedNamenow includesMemberNameinstead ofIdentifiertypeofoperand type instead?Problems with Parsers [4.7-beta] Parsing failure for arrow function expr in conditional expr #48733
(false ? (param): string => param: null);:a type annotation, or the colon in the formx ? y: z?a ? (n) : m => expris ambiguous until you get to the end of theexprand see that the:is missinga ? (b) : c => (d) : e => fmeans what ?a ? (): b => c : da ? (x): b => c : da ? (x: y): b => c : da ? (x, z): b => c : d