r/typescript • u/omardiaadev • Jun 14 '26
How Do You Use verbatimModuleSyntax?
I've been taking my good time building my own portfolio with Next.js to also learn more about TypeScript and whatnot.
At some point I noticed that some of my type imports were prepended with type while others were left unchanged, so being myself, I decided to learn more about verbatimModuleSyntax.
I basically ended up figuring out that when verbatimModuleSyntax is disabled, the compiler goes to every type import to see if it's a type or not, if a type, it omits the import. When verbatimModuleSyntax is enabled, the compiler doesn't have to go to every type import, it omits the import if prepended with type immediately. Correct me if I'm wrong.
In my personal opinion, which I know not every one will like, enabling verbatimModuleSyntax should be the default. I'll justify.
If you prepend type imports with type, you introduce the element of readability in your code, you instantly know what's a type and what's a value. Not only that, but you also improve build performance (i think?) because the compiler doesn't need to infer whether that's a type or a value.
I personally like verbosity, so I'll enable verbatimModuleSyntax in my tsconfig.json for this project and see how it goes. I would like to hear your opinions, and maybe tell me why this option should be enabled/disabled in general.
