-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Replacement for TypeStrong/ts-node#770.
I have an idea for a new project that I think is a good TypeStrong candidate, and I'm hoping to solicit a second opinion.
tsc is very compelling as a straightforward CLI interface to the compiler. For example, one of my coworkers -- not a TypeScript developer -- was curious what it could do for his project, so he did npx typescript tsc --noEmit --allowJs --checkJs. CLIs are great for accessibility. The TypeScript team talks about this in their 2019 roadmap, under "command-line experiences." Some really cool compiler features aren't exposed by the CLI:
- Dump diagnostics -- including extra "related" info from
--pretty-- as parse-able JSON - Transpile without typechecking, for speed and/or for projects that are migrating from JS and will have type errors for a while. Or for development, where you want to run code even if it has type errors, and maybe ts-node isn't a good fit. As a transpiler, this is simpler to configure and runs faster than babel. (tsc-to) (someone else making the case: TypeScript "non-standard" compiler options #1 (comment))
- Log a list of quick-fixes matching a grep expression.
- Apply all quick-fixes that match a grep expression.
- Support transformers, like "ttypescript"?
I think the barrier to entry with a project like this, is there's no easy way (that I'm aware of) to do all the bootstrapping that tsc does. It discovers tsconfig, loads and parses "extend"ed tsconfigs, gets a list of source files, and creates a language service. Ideally there would be a single function call to: augment tsc with additional CLI flags to parse, perform the above tsconfig discovery, and get back a parsed config and a language service instance.
I suppose I'm proposing 2 projects:
- a) A bootstrapper that mimics
tsc's bootstrapping, giving you a fully parsed tsconfig and a language service instance to do whatever you want. - b) A
tscdrop-in replacement with miscellaneous extra features, powered by (a).
Am I reinventing the wheel? Is this a good candidate for TypeStrong? Is there prior art I can build off?
EDIT: cleaned up a few sentences