Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tooling available to automatically resolve and order TypeScript dependencies with (or without) _references.ts?

I am trying to grok the new "_references.ts" workflow, and feel like I'm missing something w/r/t using/combining multiple files (no external modules) and still producing correct "dependency-ordered" .js code. Starting with the standard "greeter" template example in Visual Studio 2013, I:

  1. refactor the Greeter class to a file named greeter.ts
  2. select the "Combine JavaScript output" option in the project property page, replacing this as the new script target in the HTML
  3. create a "_references.ts" file and manually add, in the correct order, references to my two source files, first "greeter.ts" and then "app.ts"

This compiles and runs fine. Thanks to the "all .ts files reference all other ones in the project" feature available as of TypeScript 0.9.1, I never had to explicitly reference "greeter.ts" from "app.ts". Thinking ahead to a large project, this will be very convenient.

BUT, it's only half the story (unless I'm missing something...new to JavaScript, too, so that's very likely). What about tooling to automatically order the list in "_references.ts" (e.g. auto-generation)? Seems to me that Visual Studio (TypeScript compiler?) already knows the correct ordering. I'm looking to port a C# application with many hundreds of classes, and it would be a daunting task to order these manually. Is there a "planned" feature to do this in 1.0, or should I be looking at 3rd party tools? I found grunt-ts...am I on the right track?

like image 350
lightw8 Avatar asked Oct 20 '22 16:10

lightw8


1 Answers

grunt-ts has had support for reference.ts file creation since before visual studio supported it : https://github.com/basarat/grunt-ts#reference-file-generation

You can see a sample workflow here : http://www.youtube.com/watch?v=0-6vT7xgE4Y&hd=1

like image 126
basarat Avatar answered Oct 23 '22 07:10

basarat