This gem adds TypeScript support to Sprockets.
Add the following line in Gemfile
:
gem "sprockets-typescript", github: "antage/sprockets-typescript"
Run bundle install
.
And just add .js.ts
extension to filename of typescript source.
This gem adds all dependencies from ///<reference path="..."/>
and import
declarations to the compiler.
Example:
// app/javascripts/bar.module.js.ts
export function bar(): string {
return "bar";
}
// app/javascripts/application.js.ts
import bar = module("bar.module");
bar.bar();
You need not add //=require bar
directive in application.js.ts
.
bar.module.js.ts
is required automagically
(the compiler notifies sprockets about import
declaration).
Rename the file to jquery.d.js.ts
.