|
|
|
|
|
by neurotrace
1555 days ago
|
|
For better or for worse, features of TypeScript that generate code (like enums) are generally considered a mistake. I assume part of the idea here is that people would aim to target this particular subset so they can avoid compiling while in development and as such people would move away from those features. I like enums but you can get most of the same benefits with type RGB = 'red' | 'green' | 'blue'
|
|
Considered a mistake by whom? they are valid Typescript.
It's just creating yet another flavor of Typescript... and why straight out adopt that type syntax? Because it will please Typescript developers and Microsoft?
All for what? being able to run that flavor of typescript without having to compile typescript files into Javascript? It would change nothing to the already complex build pipelines JS developers are already mandated to use for production.
I agree with the parent, this is a bad proposal.
What Typescript should do as an alternative is better support for JSDoc type analysis. I don't use typescript language, however I do use typescript compiler.
https://www.typescriptlang.org/docs/handbook/jsdoc-supported...
Does it defeat the purpose of typescript? No, typescript is both a language AND a JavaScript static type analyzer.