Support looking for modules under node_modules when importing
Problem
Update 5 November 2015 The functionality requested below is currently implemented in typescript since at least 1.8 with one main difference: Instead of having `typescript.main` and `typescript.definition` properties, there is only one `typings` property which you can point to either a `d.ts` file or a normal `.ts` file. If you're developing a module to just use locally, you can have the `typings` point to a `.ts` file, but if you plan to publish the module, it is recommended to have it point to a `d.ts` file. This is because you don't want your module consumers to recompile your module files, just consume its typings. I have setup an example of using this here: https://github.com/chanon/typescript_module_example There is a documentation page here that has more information: http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html Thank you TypeScript devs and all contributors. Original issue / feature request follows --- Motivation In TypeScript it is a lot harder to re-use typescript modules compared to re-using npm modules in JavaScript. It would be beneficial if the typescript compiler is smart enough to look in node_modules folders and package.json files. The reason is so that npm module developers that use TypeScript might be able to start writing and distributing modules through npm itself. TypeScript would be able to piggyback on npm's infrastructure and wide support. Example for node_modules If we had: [code block] And in index.ts
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Support looking for modules under node_modules when importing
[moved to typescript.main in package.json in the issue description above]
Trust Score
1 verification
- 1
[moved to typescript.main in package.json in the issue description above]
[moved to typescript.main in package.json in the issue description above]
Validation
Resolved in microsoft/TypeScript GitHub issue #247. Community reactions: 0 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep