require-ts is a Require.js plugin that allows you to require TypeScript dependencies into your project.
You leverage require-ts like any other require.js plugin! Simply place "ts!" before your dependency path, make sure to leave off the file extension.
define(['ts!a/typescript/dep'], function(dep) {
// dep is compiled to JS at this point.
});You can also see the "example" folder, where require-ts is being used to run the Microsoft provided greeter sample.
You can load in TypeScript type declaration files by adding some configuration to your require.js configuration. Ultimately a a string of the source needs to be passed into the compiler and for the time being you can use the text! plugin.
requirejs.config({
ts: {
declarations: [
'text!../vendor/typescript/bin/lib.d.ts',
'text!../vendor/typescript/bin/jquery.d.ts'
]
}
});npm install && grunt build
This project leverages git submodules to embed the TypeScript project. This allows us to automate the build for a new version of the plugin as the TypeScript project moves forward. We leverage grunt and rigger to build the plugin.
- Name: Merrick Christensen
- Twitter: @iammerrick
The text loading mechanisms is extracted from require-cs, the work done by James Burke.
Available via the MIT or new BSD license.