Rules Hub

Coding Rules Library

← Back to all rules
fullstack ruleStack: typescript
namingtypescriptclean-codefile-structure

Avoid naming files 'Types' if they export runtime values

Files named '*.types.ts' should strictly contain type definitions. If they export runtime values, rename them to '*.constants.ts' or the domain name.

PR: Feat/FCK-1669 - Adding Job Landing Page #3656Created: Dec 8, 2025

Bad example

Old codets
1// src/components/ArticleTypes.ts
2
3export interface Article {
4 id: string;
5 title: string;
6}
7
8// Bad: This is a runtime value in a 'Types' file
9export const ARTICLE_CATEGORIES = ['News', 'Sports', 'Tech'];

Explanation (EN)

The filename 'ArticleTypes' suggests it only contains TypeScript definitions and will be erased at runtime. Including runtime constants like 'ARTICLE_CATEGORIES' violates this expectation.

Objašnjenje (HR)

Naziv datoteke 'ArticleTypes' sugerira da ona sadrži samo TypeScript definicije i da će biti obrisana pri kompajliranju. Uključivanje 'runtime' konstanti poput 'ARTICLE_CATEGORIES' krši to očekivanje.

Good example

New codets
1// src/components/ArticleConstants.ts
2
3// Good: The filename reflects that it contains values
4export interface Article {
5 id: string;
6 title: string;
7}
8
9export const ARTICLE_CATEGORIES = ['News', 'Sports', 'Tech'];

Explanation (EN)

Renaming the file to 'ArticleConstants' (or just 'Article') correctly indicates that it exports runtime values alongside types.

Objašnjenje (HR)

Preimenovanje datoteke u 'ArticleConstants' (ili samo 'Article') ispravno naznačuje da ona izvozi 'runtime' vrijednosti uz tipove.