-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip typechecking; only emit #4176
Comments
Then why use TypeScript? |
I am using the atom-typescript package with Atom, so the code does get typechecked. |
The typechecking step has to run for the emit to be correct. The emit will happen either way, though, so you can simply pipe the console output of tsc to |
What part of typechecking informs the emit? I am mostly interested in skipping it for performance reasons, as I am led to believe this is most of the time spent. Can the transpile API do a correct emit ignoring all type annotations? That sounds like a good suggestion if so, thank you! |
The actual types the compiler sees doesn't matter in terms of producing correct emit, but it's the typecheck phase that, for example, sets the flag that tells the emitter that the second arrow function (but not the first) needs to have class Foo {
fn1() {
let x = () => { null; };
}
fn2() {
let y = () => { this.fn1(); };
}
} The transpile API should be a bit faster because it doesn't include lib.d.ts. |
For completeness here is some documentation for ts.transpile. |
The typecheck phase is lengthy and requires type inference. It is convenient to get sub-second iteration time for active development work, and then the safety of type checking when creating the final product. Since tsc's output does not depend on types (as opposed to say, gcc), it would be very possible -- IMO prudent -- to separate these rather different steps. |
After some time working with typescript, I realize that it makes more sense for me to disable type checking during compilation. My motivations:
So with my workflow, having compilation and type checking as different tasks makes a lot more sense. This is something I appreciate in Flow's approach. |
I am often already convinced of my programs type safety before I run my simple bash script to compile through TypeScript, compile through babel, and run. I do not currently see any mechanism to simply emit JavaScript code instead of typechecking. Is it already done somewhere/not currently feasible/not worth it?
The text was updated successfully, but these errors were encountered: