I'd be very surprised if this has never been floated before, so I'm slightly trying to invoke Cunningham's law by presenting this as an "idea":
What if ecmascript could run typescript directly?
This would simplify a huge number of build setups. Type checking could still be done by tsc
/the typescript
library, but for runtimes that supported it, there'd be no need for: source maps or call stack modification, complex dependency tracking in monorepos just to be able to build things, declaration maps, worrying about destination directories differing from source at runtime, etc. etc.
Similarly to how babel is now able to parse typescript without validating the types, could the js engine be taught to parse the type annotations and just throw them out, then run the code without them? tsc
would effectively become a lint task.
I'm not really expecting anyone to say "cool, good idea, we'll do that next week" but I'd be interested to find out if it's already been considered. It seems like it's not that much of a stretch beyond all the es modules syntax, as long as the actual type checking is out of scope. The annotations could be thought of in the same way as comments. The syntax is valid/interpretable, but has no effect at runtime.