-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Need to support declaration merging in external modules #2821
Comments
by adding Modules, as per ES6 spec, have their own scope. so your interface JQuery is a local interface, and does not merge with the global JQuery. TypeScript does not provide a way to model modules affecting global state. To do that, you have two options:
Please note that ES6 modules have not supported this pattern, but rather a pattern of module composition, where you would import JQuery, add your extension, and export it again. users would only import your module instead of JQuery plus your module. e.g. |
I like the module composition solution. Is it supported by TypeScript yet? |
@cnshenj ES6 module syntax is supported starting form TypeScript 1.5-alpha |
Could you please illustrate this? How would this work when I have two different modules that add different things to JQuery? |
See #6213 for the module augmentation support. |
jQuery (jQuery UI) support method extensions. If we write my own jQuery UI widget, I can do this:
In myWidget.ts:
Then in another file:
However, this stops working when I add this line to myWidget.ts:
Now TypeScript thinks there 2 JQuery interfaces, instead of merging them into one. How do I tell TypeScript that I'm not creating a new interface for this module, but need to merge it with an existing interface?
The text was updated successfully, but these errors were encountered: