Microsoft/TypeScript

Default type imported with `import type` from not-found module not flagged when used as a value

Open

#57.820 geöffnet am 18. März 2024

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: BinderHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

🔎 Search Terms

cannot be used as a value because it was imported using import type

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.4.2#code/JYWwDg9gTgLgBDAnmApnAKnAZlCIBQA9IXAAIwDOAtCgB6oDGMNUuU+ccA5CBACZcA3PnwMIAOwrx4AXgzD8oSLDgBvJKjgBVAL7ZcBYmUo16KJizYduvAQrGT4AVzhytwoA

💻 Code

import type T from
// @ts-expect-error
  'mod';

const t = T;

import {type U} from
// @ts-expect-error
  'mod';

const u = U;

🙁 Actual behavior

TS does not error on the usage of T.

TS errors on the usage of U with the error

'U' cannot be used as a value because it was imported using 'import type'.(1361)

🙂 Expected behavior

TS errors on the usage of T with the error

'T' cannot be used as a value because it was imported using 'import type'.(1361)

TS errors on the usage of U with the error

'U' cannot be used as a value because it was imported using 'import type'.(1361)

Additional information about the issue

No response

Contributor Guide