Peter Mekhaeil

TypeScript: Type-only imports and exports

TypeScript can enforce explicit type imports and exports using the importsNotUsedAsValues configuration.

{
  "compilerOptions": {
    "importsNotUsedAsValues": "error",
  }
}

Setting this to error will report an error if there is a type being imported without import type syntax.

import type { MyType } from './types';
export type { MyType };

Bundlers prefer this to help avoid potiential problems with types being incorrectly bundled.