A simple archive of a Discord chat history with one of the typescript maintainers, @orta, answering some questions with @webstrand.
Original Chat: https://discord.com/channels/508357248330760243/508357248330760249/926399467597471794
Reason: Some core typescript information have been explained, which are not yet to be found in any typescript documentation and which would require some analytical work of a dev to understand.
@RabidCakeMajor |
---|
Am i correct with my thoughts that a typescript library should be transpiled with typescript's tsc transpiler instead of Babel? As far as i understand, both tsc and babel are able to transpile typescript, but only tsc has the powerful type checking feature, kind of the reason to use typescript, right? (while IDE's are not able to fully show type errors?). |
@orta |
---|
yes, and no - your logic is right for both cases, but sometimes its better to use babel because the rest of your build pipeline but still have TS for type checking via --noEmit |
@webstrand |
---|
also for performance reasons. You don't always need to check types at build time, either, for instance your tsserver in vscode checks the types on the file as you edit it. |
@RabidCakeMajor |
---|
> @orta but still have TS for type checking via --noEmit I was thinking about this possibility too - but I've ended up using Rollup as a bundler with the rollup babel plugin. How would i then be able to add TS typechecking to the build process? (Both during production run and development in watch mode?) |
@RabidCakeMajor |
---|
> @webstrand also for performance reasons. You don't always need to check types at build time, either, for instance your tsserver in vscode checks the types on the file as you edit it.Does tsserver and tsc provide the same results? Or is tsc more "complete" in a sense? |
@webstrand |
---|
> @RabidCakeMajor Does tsserver and tsc provide the same results tsserver is equivalent in terms of type checking |
...
@RabidCakeMajor |
---|
> @webstrandtsserver is equivalent in terms of type checking Noice. So based on the tsserver wiki page here: https://github.com/microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29, does "is a node executable that encapsulates the TypeScript compiler" mean it's a wrapper around tsc - since i'd expect tsc to be the typescript compiler? |
@orta |
---|
> @RabidCakeMajor Noice. So based on the tsserver wiki page ... (a bit of a simplification but) Both tsc and tsserver share an internal lib which does the work on type checking etc - so they should give you the same results |
@orta |
---|
... the key for your understanding is that there's a core 'typescript' namespace/object which is what you get with require("typescript") which both of those tools use under the hood if you clone the repo, and look at the tsconfig.jsons like this one for tsc then you'll get a sense of some of the architecture at a high level via the 'references' https://github.com/microsoft/TypeScript/blob/main/src/tsc/tsconfig.json |