Microsoft/TypeScript

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

Open

#61.489 aberto em 26 de mar. de 2025

Ver no GitHub
 (1 comment) (2 reactions) (0 assignees)TypeScript (6.726 forks)batch import
Domain: ES ModulesHelp WantedPossible Improvement

Métricas do repositório

Stars
 (48.455 stars)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)

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

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.

Guia do colaborador