Skip to content
An asset pipeline wrapper for the TypeScript language
Latest commit 3cc9d41 Sep 30, 2015 @bdrazhzhov bdrazhzhov Update

TypeScript for Rails Build Status Coverage Status

This is a wrapper for the TypeScript, JavaScript superset language by Microsoft.

It enables you to use the .ts extension in the Asset Pipeline and also in ActionView Templates.

This gem uses the typescript-node-ruby library by KAWACHI Takashi for the typescript parsing with node js.

The credit for the overall structure and the tests goes to the people that wrote the coffee-rails Gem, since I shamelessly copy&pasted some of their code.


The current version requires that node.js is installed on the system.

The requirement for node is tested upon starting the application. If the node command is not available you get the following error message:

typescript-node requires node command, but it's not found. Please install it. Set TS_NODE environmental variable If you want to use node command in non-standard path.


Add this line to your application's Gemfile:

gem 'typescript-rails'

And then execute:

$ bundle


Just add a .js.ts file in your app/assets/javascripts directory and include it just like you are used to do.


# Its defaults are `--target ES5 --noImplicitAny`.
Typescript::Rails::Compiler.default_options = [ ... ]

Referenced TypeScript dependencies

typescript-rails recurses through all TypeScript-style referenced files and tells its Sprockets::Context that the TS file being processed depends_on each file listed as a reference. This activates Sprocket’s cache-invalidation behavior when any of the descendant references of the root TS file is changed.


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request




Klaus Zanders

Something went wrong with that request. Please try again.