I'm developing Win8 app with TypeScript.
To compile my typescript code, I added winrt.d.ts
and winjs.d.ts
then referenced them
using:
<reference path="winrt.d.ts" static="true" />
<reference path="winjs.d.ts" static="true" />
Compile & build succeeded but IDE's intelliSense was being very slow. I simply opened winrt.d.ts
and checked the file. The file has 18,770 lines which is really huge file to compile on the fly.
Are there any options or methods to reference those huge definition file without compile again just like lib.d.ts
?
This slowness seriously hurts my TypeScript selection.
UPDATED:
On the current compiler version (0.8.0), there is no solution. Hope to see best performance gain in near future release.
UPDATED:
Here is my simply hack to boost dev. performance.
I simply created winrt.compact.d.ts
.
Then copy only part of namespaces which are actually used
and save the file.
Fortunately the file(winrt.d.ts
) looks like being generated
from several declaration files. So each namespace is
clearly separated from others.
It is much easier to make compact version for WinRT.
TypeScript is slow by nature. Its performance degrades with the file size, and the relation is likely non-linear.
The first thing that we can consider doing to improve performance, is to skip type checking between other files by setting the isolatedModules compiler option to true . This brings the average compile time down to 9.09 seconds , a 32% reduction in time (not bad for a quick setting change).
Things to Remember. Code generation is independent of the type system. This means that TypeScript types cannot affect the runtime behavior or performance of your code. It is possible for a program with type errors to produce code (“compile”).
TypeScript is great but sometimes, using it can turn out to be an unnecessary waste of time. Being a former C# programmer, I'm a big fan of TypeScript and strongly-typed programming languages — having said that, I know better than to use it in every project.
Correct me if I'm wrong, but I don't think that lib.d.ts
is being treated in any special way by the compiler. I took a look at the source code and here is the snippet that deals with lib.d.ts
:
if(this.compilationSettings.useDefaultLib) {
var compilerFilePath = this.ioHost.getExecutingFilePath();
var binDirPath = this.ioHost.dirName(compilerFilePath);
var libStrPath = this.ioHost.resolvePath(binDirPath + "\\lib.d.ts");
code = new TypeScript.SourceUnit(libStrPath, null);
this.compilationEnvironment.code.push(code);
}
If the user requests lib.d.ts
to be included, it is simply added to the compilation environment as the first piece of code to compile. All other source files (stored in opts.unnamed
are added in exactly the same way:
for(var i = 0; i < opts.unnamed.length; i++) {
code = new TypeScript.SourceUnit(opts.unnamed[i], null);
this.compilationEnvironment.code.push(code);
}
So if lib.d.ts
is not being treated in a special way then this is also not possible for other (declaration) files. Also, on my system lib.d.ts
has 7,677 lines, which is way less than the reported 18,770 for winrt.d.ts
, so it may be that the sum of all the lines is just too much for the compiler to achieve acceptable speed.
Other than that, my only idea is that "something else" is causing the slowdown of your machine. If you provide me with a link to the libraries and a snippet of your code, I can at least measure how long a compilation run takes on my system.
There is currently a work item outstanding for this issue on Codeplex:
http://typescript.codeplex.com/workitem/265
There is nothing you can currently do to improve this (except give the compiler more hardware!) But hopefully the work item will be picked up and the issue will be resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With