-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
Proposal
You simply do require('typescript').register() and then all require calls e.g. var foo = require('./foo') would load foo.ts if foo.js/json/etc are not found.
This would mean we would compile in-memory and completely skip all type checking and do a fast emit. This would however greatly help increase .ts adaption IMHO.
Currently there is a userland maintained : https://github.com/TypeStrong/ts-node
Motivation
CoffeeScript supports this via require('coffee-script').register(); (synonym for require('coffee-script/register');) so that once you call this function it patches require to support .coffee files.
E.g.
The implementation for coffeescript can be found here : http://coffeescript.org/documentation/docs/register.html
Where in typescript
This can potentially be done in an external NPM package, but:
- having it officially support would enhance adaption.
- give better statistics for
typescriptnpm package as users would startrequireingtypescript(coffeescript downloads https://www.npmjs.com/package/coffee-script)