davidje13 / neutrino-typescript

Transpiles TypeScript as part of the build process.
MIT License
8 stars 2 forks source link

Proposal: genarate tsconfig.json automatically when tsconfig.js is present #5

Open constgen opened 4 years ago

constgen commented 4 years ago

Currently consumers should manually setup a call to a function to refresh tsconfig.json. I propose to atomize this process and generate tsconfig when neutrino() is called with neutrino-typescript middleware and only if tsconfig.js is present. tsconfig.js just have to return the config that will be saved. If consumers are going to use a custom tsconfig.json they just don't need to create tsconfig.js in the project. This should always synchronize tsconfig with Neutrino config

davidje13 commented 4 years ago

Interesting idea. In essence this would mean incorporating behaviour like https://www.npmjs.com/package/tsconfig.js but only invoke it when a build-like action is performed (rather than using a constant watcher, like it does).

Caveats:

I think the first issue is a show-stopper in my mind, because it could cause confusing behaviour (in particular, anybody performing type checking before a build will find that they have to run build twice for a change to take effect, which they will probably assume is a bug in this preset).

Obviously it could be set up so that the automatic rewriting and explicit rewriting co-exist, but will people understand when they need to invoke rewrite-tsconfig?


If the TypeScript authors could be convinced to add some kind of scriptable startup hook to tsc then I could see something working, but given how passionately opposed they are to natively supporting tsconfig.js, I wouldn't hold out any hope for that.

Definitely open to ideas here; the current setup is far from ideal.

davidje13 commented 4 years ago

Another possibility would be to provide a "wrapper" tsc command (maybe tscjs or something). It would ensure tsconfig.json is up-to-date then forward all args to regular tsc. That way as long as people remember to use tscjs rather than tsc it would be fine. That could be combined with your suggestion to auto-rewrite when neutrino is called so that eslint works too.

Also not great and not very in the spirit of Neutrino 9 (which aims to leave the invocation of the tooling up to the developer)

constgen commented 4 years ago

All you said make sense