I was really excited when I got to know that Microsoft had released a new language called TypeScript.
Type, which means better intellisense and type safety that serve the purpose of its existence — scalable.
- Type safety.
Hate bugs? There’s a joke we talk a lot, which is also a truth: “The weirder the bug is, the stupider mistake we might have made.” And the compiler would now worry about some of these things for us, like typo or forgetting to change a property after copying some code.
TypeScript makes code navigation much easier and most of the time, we won’t even need to navigate because the information we need is there with intellisense.
WHAT? Maybe that buddy haven’t really met something big enough.
And actually I have never given the “good or bad part” thing much credit.
- Poor IDE and editor plugin support.
There have been several IDEs with TypeScript support integrated. Visual Studio, of course, would be one of them. But the experience coding using Visual Studio can’t even beat the experience on TypeScript Playground. This really bothers me a lot. No automatic-quote/bracket completion, no snippets, strange indent behavior, etc.
I haven’t tried TypeScript in WebStorm, maybe it would have done better job. Also ReSharper for Visual Studio may improve the experience according to some comments I’ve seen.
There are also some plugins for Sublime Text, but… you know.
- Poor NPM package and cross-project referencing support.
Actually TypeScript is capable generating definition files so that it should have been friendly to these things. But the reality is not that awesome…
I have proposed a convention on distributing TypeScript-written NPM package, and hoping it would make things better.
If finally you choose TypeScript, here’s some information and techniques that might help.
You may install the declarations though NuGet on Visual Studio, to make things work after installation, try to refresh the solution tree.
- Temporary “best” practice for cross-project referencing in Visual Studio.
Create a “.d.ts” file in parent project and add the declaration file generated by sub project to it as a reference.
When it comes to NPM packages, I haven’t figure out an acceptable way. But following that convention I mentioned earlier in this post, I may try to write an extension for Visual Studio which would pick up declaration files automatically, wrap it up with ambient module name and add the modified declaration file into the project that’s using that module. It would also be useful even if we are using these packages ourselves without publishing it to npmjs.org only. (BTW, symlink would save you hours if you didn’t know.)
I have now a symptom trying to make everything typed, it slows me down starting up coding a project, but speeds my lines up once the skeleton completes. Hope you enjoy writing in TypeScript if you need it.
(BTW it would be great if TypeScript add support for await/async based on Promise.)