-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix TS module resolution #123
Conversation
I couldn't use npm Reselect typings as I do with eg Immutable.js TS would not find the module. It turns out you need to declare a module whose name match exactly the import's name, "" included. I tested it, it works® A good reference: https://github.com/facebook/immutable-js/blob/master/dist/immutable.d.ts
…claration in a .d.ts file.
Current coverage is 100%@@ master #123 diff @@
====================================
Files 1 1
Lines 47 47
Methods 0 0
Messages 0 0
Branches 0 0
====================================
Hits 47 47
Misses 0 0
Partials 0 0
|
Using TypeScript 1.8, with the following import syntax and .tsconfig, I can compile without problems on master, but see errors when using the changes in your branch:
or
.tsconfig
With this pull request, I see an error:
Can you give information on your environment - TS version, .tsconfig settings, and import / require syntax? |
@threehams Does it work with immutable ? I just basically used their project as a template as they should know better. |
Again, can you post reproduction steps and version/environment/code? The ability to read definition files from node_modules was added in Typescript 1.6, so version matters a lot here, as well as es5/6 target, module setting, whether you're using Babel in addition to Typescript, etc. Immutable creates a module, exports everything from that, then re-exports it using the final string name. This makes it backwards-compatible with 1.5 and earlier when used outside node_modules, but I don't think we're not worried about doing that here. If we're targeting 1.6+, it's simpler to use top-level exports and avoid declaring modules at all:
Information on writing definition files can be really tricky to find, and a lot of it is buried in comments in issues and pull requests. |
As we can't reproduce this, I am going to close due to inactivity. |
I couldn't use npm Reselect typings as I do with eg Immutable.js
TS would not find the module.
It turns out you need to declare a module whose name match exactly the import's name, "" included.
I tested it, it works®
A good reference: https://github.com/facebook/immutable-js/blob/master/dist/immutable.d.ts