TypeScript is meant to add static typing to JavaScript.
This means
-
Static types. Explictily add types in your code.
-
Turns JS from weakly typed (type coercion etc.) to strongly typed.
-
Compile time error handling (errors related to types).
-
Enhanced dev tooling e.g. code completion, error highlighting.
All of these features are in the scope/relation to Types. Even options in tsconfig.json
such as:
-
“strict”
-
“noUncheckedIndexedAccess”
-
“checkJs”
are all in scope/relation to types. This makes sense to me.
But features such as
-
Transpiling one version of ECMAScript code to another “target”
-
Transpiling one module system code to another “module”
-
Supporting/easing interop between module systems, “enableEsModuleInterop”
are not in scope/relation to “types”.
While these are great features, wouldn’t it be better to separate these features out into their own tools? This enables TS to just be a tool to support types. tsconfig.json
would also really be simple.
A separate build tool can be used for the other features.
IMO, this is a better separation of concerns. TypeScript will then just be what its name implies, a tool to add type support for JS.
I understand that things are easier when all features are supported by a single tool, reducing the need for more build phases and tools, but I’d take the separation of concerns over a overly packed tool.