TypeScript team released an explorer for performance tuning
devblogs.microsoft.com
devblogs.microsoft.com
The Typescript transpiler does definitely slow things down but I've tried the "only check types during build" approach and while it starts out very nice and quickly, you end up wasting all that time you would've waited on tsc by chasing down impossible to find typing bugs and doing the necessary code restructuring to fix the problems your IDE missed. Only finding out about these bugs when pushing code (or even worse, when opening a pull/merge request) can be a lot more annoying than giving tsc half a second to catch up.
I do wish that tsc was faster, but on the other hand I can't say it's been that much of a problem for me.
Perhaps this is because I'm almost exclusively on Linux. tsc operates on tons of tiny files and Windows is notoriously slow at dealing with that, even with AV exclusions.
TypeScript doesn't evolve super fast, but there are a steady stream of great improvements. I'd be so afraid I have either less type checking, things that silently pass/aren't checked, or intelligence that TypeScript has that other checkers don't have.
Also, as others say, just using --watch largely eliminates the problems of using tsc. I haven't worked on any truly huge codebases but it's been quite snappy. It's a longshot, but I wish TypeScript would also be it's own LSP too.
I definitely did love love love how blazingly fast & super easy to work with, no setup, Deno was. Incredibly refreshing, no ceremony.
Deno uses tsc internally, and VSCode at least uses the official typescript language server, which I believe uses tsc internally
I realise this is sort of a dead horse, but rewriting the Typescript checker in Rust would not be an impossible task for a team as well-resourced as Microsoft’s.
I know, because I rewrote a different 100KLOC typechecker myself in Rust (making a few small adjustments for a slightly different target language). It took me about a year.
It would speed up the TypeScript typechecker at least 3-5x, which would save a lot of programmer time (and also datacenter energy consumption).
There’s one obvious downside — it raises the bar for outside contributions — but given the expertise necessary to contribute usefully to a static analysis tool in the first place, and to contribute to TypeScript in particular, I’m not sure it’s a big additional impediment.
Rewriting it in rust would remove that important aspect c
Sorry, my previous comment wasn't very clear. Of course, faster languages produce faster results. But the language alone isn't enough in this case.
It takes three steps. Steps 1 and 3 are parellisable, and 2 should be very quick:
1. Convert every file in the repository to an AST, and perform static reflection on that AST.
2. Calcuate the inheritance graph for all the functions, classes etc. you've collected
3. Analyse every file, using the pre-calculated list of functions and classes available in each case.
But, while I’m sure it was really important initially, there are now very many test cases and early-adopters to help prevent regressions.
And they still have that large TypeScript codebase to test their new tool on — it wouldn’t vanish.
It sounds like you could easily have a nice consulting gig for Microsoft.
[1] https://github.com/tc39/proposal-type-annotations
[2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guid...
Theoretically HTTP/2 push could've helped here, forcing the necessary files into the browser cache, but that's been removed from browsers.
https://www.typescriptlang.org/docs/handbook/jsdoc-supported...
You may want to read
https://news.ycombinator.com/item?id=35187377
https://news.ycombinator.com/item?id=35653653
Transpiling is entirely optional. Choose "esnext" as target and don't use the old and no longer needed "namespace" (now: just use modules) and "enum" (now: just use an object literal annotated with "as const") - and all that is done is removal of the type annotations.
If you write Typescript you already write pure Javascript, you just add type annotations, which are not part of the code and don't make it into the code.
Typescript mixes type checking and transpiler (Babel) and a few other thing in one big "blob" of a tool - unfortunately, the Unix way would have been to have separate tools. Which you can do and many do: Don't use "tsc" to create your .js code, only use it (through the IDE or standalone) to check types, and let Babel do any transpilations. It's much more flexible than "tsc" too.
What you are really asking is "Is there an effort to add types to ECMAscript" - and that does not look likely, because a) the existing solution already works well enough, and b) if you look at all the troubles and limitations you get when you use types you realize adding types is nearly impossible if you want to remain backwards compatible. If you use typed code, e.g. by using Typescript or Flow, you either end up with a lot of "any" types, or you have to code for the type checker. You cannot add reliable types to any previously pure Javascript code base. The code itself would have to change. Also, enough people don't want any types with their JS.
Both these things are needed. The workarounds you listed are not equivalent and not drop in replacements.
See these and many similar statements/posts.
https://michelenasti.com/2019/01/23/is-typescript-namespace-...
https://stackoverflow.com/questions/64495793/typescript-name...
https://github.com/microsoft/TypeScript/issues/30994#issueco... (link to a specific comment)
> Namespaces are probably never going away and, simultaneously, you probably shouldn't use them, since better, more standard and modern patterns exist through the use of modules. If you have code that you feel needs to use a namespace, more power to you and go for it, but most of the time you don't need one, as we now have a different conceptual organizational model recommended for large-scale JS (modules). That's why @DanielRosenwasser (Program Manager of TypeScript) said namespaces are not a huge loss - most new TS code should probably never need to use them, and should think hard about if they really need to.
Sure, you can use them, enums as well still provide a few more options than object literals, and since those features are in TS anyway and will remain like everything in JS always remains for backwards compatibility... - but they are not needed.
There even is a sentence in the TS documentation (under Namespaces and Modules) that starts with "If you’re converting a program from namespaces to modules,..." (see https://www.typescriptlang.org/docs/handbook/namespaces-and-...)
This is distorting my post's point, which was Typescript is ECMAscript, and I did mention the two big exceptions, and I said they are not needed - which is just truth. They were necessary before ES 2015, which is the reason they exist to begin with. Other than that, Microsoft's explicitly stated goal is to keep Typescript perfectly aligned with ECMAScript, and to only add types.
Now that the language has all the minimum features they don't make any more changes that require actual transpiling because the code itself - not the types - is "Typescript only" and not part of ECMAScript. They will, however, leave in anything that is already there, just like ECMAScript does, because backwards compatibility trumps all.
Also note that you can have types-only namespaces that only contain type definitions, which are entirely different: They fall exactly under what I said, types are just removed in the .js file generation step. Those kinds of "namespaces" don't lead to any executable code.
Not to mention that you could easily just write the tiny bit of JS yourself instead of using the namespace keyword, because namespaces are simply named JavaScript objects in the global namespace. -- This is all it does: https://www.typescriptlang.org/play?noUnusedLocals=true&noUn...
So if you want the same thing as TS namespaces with just JS code, all you need is a global object and then assign stuff to it, from one or from several modules.
https://www.typescriptlang.org/docs/handbook/declaration-mer...
It's a stretch to say "they're not needed." Like the comments in the threads you linked, they are usually not necessary for code written with esm modules in mind. However, modules cannot express the same semantics that namespaces can, and if you need those semantics for your program, you need namespaces.
Similarly, enums are not semantically equivalent to object literals with const fields, and I think it's kind of absurd to say that one of the most useful things in the TS type system is "not needed.
But that is for TYPES and does not produce any JS code!
> Similarly, enums are not semantically equivalent to object literals with const fields
I know and I mentioned it! That still does not make them needed! You can use them if you want. As I mentioned.
> I think it's kind of absurd to say that one of the most useful things in the TS type system is "not needed.
I on the other hand think it's absurd to pretend to have a serious discussion when you claim that enums are "one of the most useful things" in TS. Some very minor syntactic sugar add-on as one of the main points of type checks???
Browser-side, they tried to add support for a second language via Dart, but that didn't work out.