-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in codeRevisitAn issue worth coming back toAn issue worth coming back to
Description
Consider this code:
// myPlugin.ts
<reference path="typings/jquery/jquery.d.ts" />
// Add a plugin to the JQuery type
interface JQuery {
myPlugin():JQuery;
}
var $myEl = $('foo').myPlugin();
var $bar = $('foo').find('bar');
This works fine. The problem comes when I mix this with an external import:
// myPlugin.ts
<reference path="typings/jquery/jquery.d.ts" />
import _ = require('underscore');
// Add a plugin to the JQuery type
interface JQuery {
myPlugin():JQuery;
}
var $myEl = $('foo').myPlugin();
var $bar = $('foo').find('bar');
/// error TS2339: Property 'find' does not exist on type 'JQuery'.
This does not seem to be specific to JQuery/underscore, but happens whenever I add to an interface in the same file as an import.
I can work around this by moving the interface additions to another file:
// jquery.ext.d.ts
<reference path="typings/jquery/jquery.d.ts" />
interface JQuery {
myPlugin();
}
// myPlugin.ts
<reference path="typings/jquery/jquery.d.ts" />
<reference path="jquery.ext.d.ts" />
import _ = require('underscore');
var $myEl = $('foo').myPlugin();
var $bar = $('foo').find('bar');
Is this a bug in the compiler, or expected behavior? If it is expected, is there any documentation I can look at?
Thanks!
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in codeRevisitAn issue worth coming back toAn issue worth coming back to