My current 0.9.1 project structure (workarounds to make the compiler happy)

Topics: General
Aug 21, 2013 at 9:15 AM
Edited Aug 21, 2013 at 2:07 PM
This is what I did to make a project work fine with 0.9.1

1) To clean up and get better manageability: I splitted my project into three, one for tests and one for main application and one for experiments. Earlier I had them in one project, but only deployed the right set of files.

2) To handle some typings that was not picked up by the language service for me (in particular kendo.d.ts was not picked up for me) I made a libs.any.d.ts as a temporary (lame) workaround "declare var kendo:any;"

3) Remove all manually added references (reference path=...), let Visual Studio do that work (it references all ts + d.ts files in the project automatically as of 0.9.1)

4) Make all code independent on order - i.e. move startup code to a document ready function.

5) Compile everything into one application.js and make it create a definition file by editing the build in .csproj, see below.

6) Use the compiled application.js and the application.d.ts in the test project.
  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
This looks very much like any C#-solution structure and works quite well for me. Unfortunately it makes me dependant on Visual Studio, which I hoped not to be. And the workaround in 2) is obviously not good.

See also
Aug 22, 2013 at 8:13 AM
Edited Aug 22, 2013 at 12:40 PM
The now picks up all definitions (incl the kendo one), plus it found a few type errors of mine that 0.9.1 missed. Great work guys!

A few errors (of mine) I stumbled on and that might help others perhaps: reported "Generic type references must include all type arguments" for JQuery.d.ts and others, on these kinds of defs:
promise(type?: any, target?: any): JQueryPromise;
// change to : 
promise(type?: any, target?: any): JQueryPromise<any>;
// I guess I should be using T instead, but I'm not sure exacly how.
A definition was not being picked up, and when run the file with that in the console I got the error TS5037: Cannot compile external modules unless the '--module' flag is provided.
// I used this erroneously in a few places:
exports interface IFoo ...
// change to (if you're not using external modules):
interface IFoo ...
And I found that even though I included my definition files in Visual Studio it had one of them included as Content, check properties, Build Action. Should be TypeScriptCompile. Both .ts files and .d.ts files