microsoft / microsoft/TypeScript
Trailing comma in dynamic import should be allowed also when used in a `typeof` type
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- PR merge metrics
- PR metrics pending
Description
### 🔎 Search Terms
trailing comma dynamic import
### 🕗 Version & Regression Information
- This is the behavior in every version I tried
### ⏯ Playground Link
https://www.typescriptlang.org/play/?#code/CYUwxgNghgTiAEBbA9sArhBAiAZs5W8A3gL4BQZYyAdgM4Au8AbvALzxQDuUAloz4gAOyGPQAUufFgA0ASgDcZegE9BCACpt4KtchzwBw0RLwE5iyjQbMATFq69+QkeMlnS5pao132OkHoGzsZuMh4KZEA
### 💻 Code
```ts
declare module "foo" {}
const v = await import("foo",);
type T = typeof import("foo",);
const v2 = await import("foo",{},);
type T2 = typeof import("foo",{},);
```
### 🙁 Actual behavior
The trailing commas in the type-level `import()`s are reported as syntax error
### 🙂 Expected behavior
The _syntax_ of `import()` at the type-level should match the one at the value level, thus allowing trailing commas.
### Additional information about the issue
Note that the error was correct before import attributes, but import attributes changed the dynamic import syntax to allow trailing commas.
Contributor guide
Research direction
Start with the linked TypeScript Playground and reproduce the trailing-comma cases for value-level and type-level dynamic imports. Compare how the two forms are parsed, then add regression coverage for both examples. Done means typeof import() accepts the same trailing-comma syntax as value-level import().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100