microsoft / microsoft/TypeScript

Trailing comma in dynamic import should be allowed also when used in a `typeof` type

Offen
#61,489 1 Kommentar 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Domain: ES Modules Help Wanted Possible Improvement
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

### 🔎 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem verlinkten TypeScript Playground und reproduziere die Fälle mit abschließendem Komma für dynamische Imports auf Wert- und Typebene. Vergleiche, wie die beiden Formen geparst werden, und füge anschließend Regressionstests für beide Beispiele hinzu. Fertig ist die Aufgabe, wenn typeof import() dieselbe Syntax mit abschließendem Komma akzeptiert wie der Import auf Wertebene.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.