Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support `register` to allow users to just require `.ts` files

See original GitHub issue


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 :


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.


  • Atom does this for coffee : here and here
  • Grunt does this here

The implementation for coffeescript can be found here :

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 typescript npm package as users would start requireing typescript (coffeescript downloads

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:58
  • Comments:25 (9 by maintainers)

github_iconTop GitHub Comments

mhegazycommented, Dec 9, 2015

We have been getting consistent feedback about this. i think we should reconsider the current position.

billticommented, Aug 14, 2015

I left a comment in the pull request also to this effect, but this functionality is deprecated in the Node API. Specifically, it states at

*Deprecated* In the past, this list has been used to load non-JavaScript modules into Node by compiling them on-demand. However, in practice, there are much better ways to do this, such as loading modules via some other Node program, or compiling them to JavaScript ahead of time.

While it does go on to say, Since the Module system is locked, this feature will probably never go away, it still seems undesirable to add new features the depend on deprecated features.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't run my Node.js Typescript project TypeError ...
I just resorted to using tsc --outDir out file.ts and then running the file normally with node out/file.js , and then adding out...
Read more >
TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
Read more >
ts-node - npm
You can require ts-node and register the loader for future requires by using require('ts-node').register({ /* options */ }) . Check out our API ......
Read more >
How to use TypeScript with Node.js -
A browser will only read JavaScript code. To invoke any Typescript code, you need a compiler to transpile Typescript to browser executable ...
Read more >
TypeScript - Cypress Documentation
This allows you to write your tests in TypeScript. ... interface (so called because commands are chained together) to your cypress/support/index.ts file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found