-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Merge and re-export module in external module declaration #2019
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
Comments
You need a /// reference to myLib.d.ts in consumer.ts so that it knows where to find the quoted names (myLib, myLibWithExtras). Otherwise this is all correct and works for me with the latest bits. |
Hmm. I built off master and modified consumer.ts and got this:
Perhaps I'm missing something simple? |
Your module myLib {
export function doSomethingElse(): void;
} |
@mhegazy Adding |
Oh.. my bad. this is actually a bug, import declarations can not merge with other declarations. The bug is to get an error message in mylib.d.ts to not export the import but complain that it is merged with the module. The compiler shows the error correctly in non-ambient declarations but not here. I think your scenario would work well with the new import syntax:#1983, this will be in our next release (1.5). so your code will look like: // myLib.d.ts
declare module "myLib" {
export function doSomething(): void;
}
declare module "myLibWithExtras" {
export * from "myLib";
export function doSomethingElse(): void;
} |
Ah! Very good, thanks! |
Re-opening, sounds like we do want to fix today's error message. |
Ah right, sorry about that. |
I think this might be fixed. The following code: declare module "myLib" {
function doSomething(): void;
}
declare module "myLibWithExtras" {
// this doesn't work
import myLib= require("myLib");
module myLib {
function doSomethingElse(): void;
}
export = myLib;
} now throws the following error: "Import declaration conflicts with local declaration of 'myLib' module" |
thanks @jbrantly for reporting back. resolving. |
Let's say I'm writing a declaration file for a library that exports two external modules:
myLib
andmyLibWithExtras
. ThemyLibWithExtras
module is exactlymyLib
but with some additional items.As an example of what I'm trying to do:
Is there any way to accomplish this?
The text was updated successfully, but these errors were encountered: