Feasibility of writing a new Typescript compiler package

Today there are two main ways to get Typescript support in Meteor.

The first is to use the core Typescript package which relies on Babel to compile typescript.
That seems to imply that types are seen only as decorators because Babel doesn’t do type checking (https://babeljs.io/docs/en/#type-annotations-flow-and-typescript) so it means giving up on getting type compilation errors as part of the build process.
It also doesn’t currently read the tsconfig.json files that control the VSCode experience.

The other is to use one of the descendants of barbatus:typescript (I forked adornis:typescript and have published it as refapp:typescript). It is very slow and recompiles all files for each target. It’s also a lot of code that I find hard to understand in the details.

I wonder, with the recent additions in Typescript 3.6 to support incremental compilation in the TS API if it’s feasible to start over with writing a new compiler plugin that uses some api like createIncrementalProgram and lets the TS compiler bother with dependencies and caching.

Does anyone here know how much work that would be? Is it remotely doable?

If it’s at all feasible I would start from scratch writing a compiler plugin package in Typescript using the core Typescript package for bootstrapping.

There is a webpack plugin that seems to be in line with what I really want but adapting it to a Meteor compiler package is probably a lot of work… It is not trival.

I haven’t invested much time into webpack but it seems like a very lively community - is there any way we could make webpack itself replace or complement the existing bespoke Meteor build system, like how Meteor added npm support to benefit from that community?

In my development work flow, I’d rather make type errors something that I am alerted about in my development tool and at commit time (using a git hook) rather than something that breaks my Meteor build. Sometimes I’m just exploring ideas and I don’t care if the types are not perfect yet.

So for that reason the I prefer the current workflow of using types as decoration at the Meteor typescript compiler level.

But having the ability to specify custom tsconfig.json options would be great.

I’m sure if you created a PR for this that it would be welcome!