Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2stack specificStack: TypeScript
typescriptimportsbuild
Use type-only imports for types
Import types with `import type` (or an inline `type` specifier). Under verbatimModuleSyntax/isolatedModules a value-style import of a type is not erased and can pull runtime code in or fail the build. It also documents intent: this symbol is only used for typing.
PR: profico-org-corpus batch2 (all stacks/products)Created: Jul 26, 2026
Bad example
Old codets
| 1 | import { User } from './models'; |
| 2 | import { formatUser } from './format'; |
| 3 |
|
| 4 | function render(user: User) { return formatUser(user); } |
Explanation (EN)
`User` is only a type but is imported as a value; with verbatimModuleSyntax this is an error or keeps a runtime dependency.
Objašnjenje (HR)
Good example
New codets
| 1 | import type { User } from './models'; |
| 2 | import { formatUser } from './format'; |
| 3 |
|
| 4 | function render(user: User) { return formatUser(user); } |
Explanation (EN)
`import type` is fully erased at compile time and makes the type-only intent explicit.
Objašnjenje (HR)