microsoft / microsoft/TypeScript

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

Ouverte
#61,489 1 commentaire 2 réactions 0 personnes assignées Voir sur GitHub
Domain: ES Modules Help Wanted Possible Improvement
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
2 j 4 h
PR mergées (30 j)
132

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.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par le TypeScript Playground lié et reproduisez les cas d’importations dynamiques au niveau des valeurs et des types avec une virgule finale. Comparez la manière dont les deux formes sont analysées, puis ajoutez une couverture de régression pour les deux exemples. Le travail est terminé lorsque typeof import() accepte la même syntaxe de virgule finale que import() au niveau des valeurs.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
compilers
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.