I created my first TypeScript file using the VS2012 plugin and web essentials:
///<reference path='/Scripts/jquery/jquery.d.ts' />
/*jslint browser: true*/
/*jslint vars: true */
/*global $, jQuery*/
/*global ajaxOnFailure, doAddSubmit, doResetTabs*/
/*global mvcOnFailure, updateGridMeta*/
function alertWin(title, message) {
$.modal({
content: '<p class="align-center">' + message + '</p>',
title: title,
minWidth: 150,
maxWidth: 900,
maxHeight: 600,
width: false,
buttons: {
'Ok': function (win) { win.closeModal(); }
}
});
}
I dragged and dropped the reference file from the solution to the top of the file and it does exist.
However as soon as it's dragged I get a red line under it saying "referenced file does not exist". I also note that it does not seem to recognize the $
in my script.
Here's my directory structure:
/Scripts
/jquery/jquery.d.ts
/Shared/dialog/functions/file1.ts <-- the file above
Note:
When I put the .ts file in the same directory as file1.ts and reference as follows then it works:
///<reference path='jquery.d.ts' />
So my question is:
How can I have my jquery.d.ts in just the one place and reference it from my files?
I created my first TypeScript file using the VS2012 plugin and web essentials:
///<reference path='/Scripts/jquery/jquery.d.ts' />
/*jslint browser: true*/
/*jslint vars: true */
/*global $, jQuery*/
/*global ajaxOnFailure, doAddSubmit, doResetTabs*/
/*global mvcOnFailure, updateGridMeta*/
function alertWin(title, message) {
$.modal({
content: '<p class="align-center">' + message + '</p>',
title: title,
minWidth: 150,
maxWidth: 900,
maxHeight: 600,
width: false,
buttons: {
'Ok': function (win) { win.closeModal(); }
}
});
}
I dragged and dropped the reference file from the solution to the top of the file and it does exist.
However as soon as it's dragged I get a red line under it saying "referenced file does not exist". I also note that it does not seem to recognize the $
in my script.
Here's my directory structure:
/Scripts
/jquery/jquery.d.ts
/Shared/dialog/functions/file1.ts <-- the file above
Note:
When I put the .ts file in the same directory as file1.ts and reference as follows then it works:
///<reference path='jquery.d.ts' />
So my question is:
How can I have my jquery.d.ts in just the one place and reference it from my files?
Share Improve this question edited Oct 26, 2012 at 9:13 Fenton 252k73 gold badges402 silver badges410 bronze badges asked Oct 26, 2012 at 5:50 user1679941user16799412 Answers
Reset to default 5You need to use reference path relative to the script using it (with..) – you can't just ask to calculate from root.
See this answer Using jQuery plugin in TypeScript
The issue with jQuery plugins (and other plugin based libraries) is that you not only do you need a library.d.ts file for the base library you also need a plugin.d.ts file for each plugin. And somehow thes plugin.d.ts files need to extend the library interfaces defined in the library.d.ts files. Fortunately, TypeScript has a nifty little feature that lets you do just that.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745462384a4628767.html
评论列表(0条)