Category: Next.js, React and TypeScript

TypeScript: import must be type-only at verbatimModuleSyntax

Read this guide in Polish

The compiler rejects an interface import that was to be used only as a type. With verbatimModuleSyntax TypeScript, import values and types must be properly separated.

How to determine the source of the error

Check tsconfig for verbatimModuleSyntax and the files indicated by TS1484.

Determine whether the imported symbol exists in runtime or is just an alias or an interface.

What to do step by step

1. Replace the corresponding import to import type {... } from '...' or mark individual names as type.

2 . Leave normal imports for values used during JavaScript operation.

How to check the score

Typecheck does not report TS1484 and the result JavaScript does not contain non-existent types of imports.

What to do

Do not disable the TS configuration just to avoid improving several imports.