TypeScript Compiler Diagnostics

TS1484: Type must use a type-only import

With verbatimModuleSyntax, an imported interface used as a type must be marked type-only. The interface has no runtime export. Use import type for the interface and an ordinary import for a runtime value. The fixture uses explicit Node ESM file extensions to avoid unrelated module-format diagnostics. Baseline: TypeScript 5.8.3 with the shown configuration. Reproduce in one directory and create the corrected project in another. The diagnostic can have other causes; inspect its location and message before choosing a correction. Both projects keep strict checking enabled.

Formal Syntax & Structure

typescript syntaxtypescript
TS1484 (compiler diagnostic code, not TypeScript syntax)

Working Example

Example Snippettypescript
// INTENTIONALLY INVALID — reproduce// File: tsconfig.json (omit this label){  "compilerOptions": {    "strict": true,    "target": "ES2022",    "module": "NodeNext",    "types": [],    "lib": [      "ES2022",      "DOM"    ],    "noEmitOnError": true,    "outDir": "dist",    "moduleResolution": "NodeNext",    "verbatimModuleSyntax": true  },  "files": [    "main.mts"  ]}
// File: main.mts (omit this label)import { Item, value } from "./dep.mjs";const item: Item = { count: value };console.log(item.count);
// File: dep.mts (omit this label)export interface Item { count: number }export const value = 8;
// Run: tsc -p . --pretty false// Expected: TS1484; no output emitted.
// CORRECTED PROJECT — separate directory// File: tsconfig.json (omit this label){  "compilerOptions": {    "strict": true,    "target": "ES2022",    "module": "NodeNext",    "types": [],    "lib": [      "ES2022",      "DOM"    ],    "noEmitOnError": true,    "outDir": "dist",    "moduleResolution": "NodeNext",    "verbatimModuleSyntax": true  },  "files": [    "main.mts"  ]}
// File: main.mts (omit this label)import type { Item } from "./dep.mjs";import { value } from "./dep.mjs";const item: Item = { count: value };console.log(item.count);
// File: dep.mts (omit this label)export interface Item { count: number }export const value = 8;
// Run: tsc -p . --pretty false// Expected: no diagnostics.// Run: node dist/main.mjs// Expected stdout: 8
TypeScript Reference