Menu

357 type aliases, zero interfaces, and the only interface in our codebase belongs to the browser
📰

357 type aliases, zero interfaces, and the only interface in our codebase belongs to the browser

DEV Community: typescript·Daniel Pertu·17 days ago
#Lz1HL4q8
#devtotypescript#devto#dev#type#union
Long article (1715 words) — no AI summary yet.
Reading 0:00
15s threshold

The interface versus type argument is one of the oldest in TypeScript, and the honest answer is that it rarely matters. What does matter, and what nobody measures, is the vocabulary a codebase settles into: how many of your types are objects, how many are unions, how deep the generics go, and which of the standard utility types you actually use.

So I counted every type declaration in ours.

The subject is Nakodo , 582 TypeScript files, 72,683 lines, strict mode, no type-generation step other than the ORM's row inference.

The headline

type aliases 357 (262 exported, 95 file-local) interfaces 1 (a global Window augmentation) enums 0 classes 19 (18 of them Error subclasses) generic aliases 2 generic functions 14

Enter fullscreen mode

Exit fullscreen mode

One interface in 72,683 lines, and it is not describing anything of ours.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.