-
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
Unable to do module augmentation #7148
Comments
I'm assuming that the relevant |
@DanielRosenwasser here's a little repro project: https://github.com/yortus/repro-7148 |
I have failed to augment |
discussed offline with @mhegazy: this is not a bug in implementation but rather the consequence of the fact that currently typings for 'knockout' and 'jquery' are not augmentation-friendly - they both export variable with some global type as module and so i.e. in case of JQuery declare module 'jquery' {
interface JQuery {
timepicker(): JQuery;
timepicker(options: TimePickerOptions): JQuery;
}
} module 'jquery' is defined as declare module "jquery" {
export = $;
}
declare var jQuery: JQueryStatic;
declare var $: JQueryStatic; so type of 'jquery' is effectively What you can do:
/// <reference path="./jquery.d.ts" />
declare global {
interface JQuery {
timepicker(): JQuery;
}
}
$().timepicker();
export {} |
@vladima Could you please add a few words about how the above mentioned UMD support solves this? I'm currently stuck with this situation and wouldn't like to use the global scope declarations unless I have no other way. |
http://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html#umd does not cover your question? |
It doesn't get me closer, as I still don't see what the working alternative is for
as it still doesn't work at me. The compiler still can't see these extension methods. |
where is |
It's installed via the |
the issue is that Jquery as defined in DefinitelyTyped is not a module, it is really a variable. The correct fix is to submit a PR to DefinitelyTyped turning the jquery definition into a module. Alternatively, you can augment the interface declare global {
interface JQuery {
timepicker(): JQuery;
timepicker(options: TimePickerOptions): JQuery;
}
} |
Yes I know that, I was just confused because @vladima wrote in one of the previous posts that there are two options, and the first option was to wait for UMD support as it will solve it. The second was to augment the global scope jQuery definitions. So basically UMD support doesn't solve this particular issue, as the issue is still with the jQuery definition file if I understand correctly. Thank you for the clarification. |
well, jquery does not use UMD modules. so no, it does not solve the issue for jquery. |
Severity Code Description Project File Line Suppression State
i have same issue. |
TypeScript Version:
nightly (1.9.0-dev.20160217)
Code:
Asking the same thing as #6722, but for
jquery
andknockout
.The text was updated successfully, but these errors were encountered: