-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Module augmentation does not work on un-imported node packages / generated d.ts files #8113
Comments
Are you using |
Nope, generating and publishing loose *.d.ts files. 😄 |
I'm not able to repro the issue. Can you upload your code to GitHub or somewhere so I can clone it and take a look? |
To repro: 1. git clean -xdf 2. cd ext && npm install 3. cd ../A && npm install 4. cd ../B && npm install Note, TSC is set as npm prepublish, which runs it automatically after npm install.
@DanielRosenwasser - sure, I published a repo as https://github.com/theoy/tsc-8113-repro To repro:
There's a comment in B.ts that demos the workaround of importing 'ext' from B. In my real project, 'ext' is an implementation detail, and would prefer to not have to expose it, but was augmenting 'ext' from within A, in order to clean up an aspect of A's implementation. |
I can see what is going on. The issue is that in // A.d.ts
declare module 'ext' {
}
declare var _default: {};
export default _default; Now if module |
@vladima - yep, I figured that's what was going on, especially once exporting in |
another solution can be: since we now are distinguishing root files from imported we can only issue |
TypeScript Version: v1.8.10
Create a basic external npm package 'node_modules/ext'. In it, set up the following 2 files:
Reference package 'ext' from A.ts, using
--declaration
, generating A.d.tsCopy A.d.ts to another directory, that has the ext package installed in node_modules
// B.ts import * as modA from './A'
Expected behavior:
Generated A.d.ts causes no errors because typed package 'ext' was in the correct location.
Actual behavior:
A.d.ts(1,16): error TS2664: Invalid module name in augmentation, module 'ext' cannot be found.
Workarounds:
Remarks:
This is frustrating because the fact that A depended on 'ext' was an implementation detail, and in reality
npm
was the one that brought 'ext' into node_modules.Thoughts?
The text was updated successfully, but these errors were encountered: