Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Use import type for type-only imports
Use import type when the symbol is only used as a type to support isolated transpilation.
Bad example
| 1 | import {User} from './types'; |
| 2 |
|
| 3 | export function formatUser(u: User) { |
| 4 | return u.name; |
| 5 | } |
Explanation (EN)
A type-only import makes compile-time intent clear and avoids an unnecessary runtime dependency where the toolchain preserves imports.
Objašnjenje (HR)
Type-only import pojašnjava namjeru pri prevođenju i izbjegava nepotrebnu izvršnu ovisnost kada alatni lanac zadržava obične importe.
Good example
| 1 | import type {User} from './types'; |
| 2 |
|
| 3 | export function formatUser(u: User) { |
| 4 | return u.name; |
| 5 | } |
Explanation (EN)
import type documents intent and keeps type-only dependencies clean for file-by-file builds.
Objašnjenje (HR)
import type jasno pokazuje namjeru i drži type-only dependencyje čistima za file-by-file build.
Notes (EN)
Use import type or an inline type specifier when the symbol has no runtime role under the project compiler and decorator configuration.
Bilješke (HR)
Koristi import type ili inline type kada simbol nema izvršnu ulogu prema compileru i konfiguraciji dekoratora projekta.
Exceptions / Tradeoffs (EN)
Keep value imports needed for reflection, decorators or actual calls. Preserve intentional module side effects with a separate explicit import if removing the value import would remove initialization.
Iznimke / Tradeoffi (HR)
Zadrži value importe potrebne za reflection, dekoratore ili stvarne pozive. Ako bi uklanjanje importa uklonilo namjernu inicijalizaciju modula, sačuvaj nuspojavu zasebnim izričitim importom.