Using a fully patched Visual Studio 2013, I am integrating JQuery, JQueryUI, JSRender, and TypeScript into my project. However, I am encountering an error in the ts file:
Property 'fadeDiv' does not exist on type '{}'.
While I believe I have the necessary references for TypeScript, it seems like this issue stems from a d.ts problem.
Although there are no errors in JavaScript, Visual Studio keeps flagging 'fadeDiv' with red lines. The error message remains consistent:
/// <reference path="../scripts/typings/jquery/jquery.d.ts" />
/// <reference path="../scripts/typings/jqueryui/jqueryui.d.ts" />
/// <reference path="typings/jsrender/jsrender.d.ts" />
var SUCSS = {};
$(document).ready(function () {
SUCSS.fadeDiv();
});
SUCSS.fadeDiv = function () {
var mFadeText: number;
$(function () {
var mFade = "FadeText";
//This part actually retrieves the info for the fadediv
$.ajax({
type: "POST",
url: "/js/sucss/General.aspx/_FadeDivList",
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (xhr, status, error) {
// Show the error
},
success: function (msg) {
mFadeText = msg.d.Fade;
if (msg.d.FadeType == 0) {//FadeDivType = List
var template = $.templates("#theTmpl");
var htmlOutput = template.render(msg.d);
$("[id$=lblFadeDiv]").html(htmlOutput);
}
else {//FadeDivType = String
$("[id$=lblFadeDiv]").html(msg.d.FadeDivString);
}
},
complete: function () {
if (mFadeText == 0) {
$("[id$=lblFadeDiv]").fadeIn('slow').delay(5000).fadeOut('slow');
}
}
});
});
In TypeScript, to make 'SUCSS.fadeDiv' accessible externally, the following structure would be appropriate:
$(document).ready(function () {
SUCSS.fadeDiv();
});
module SUCSS {
export function fadeDiv () {};
};
By exporting the function using 'export', one can call 'SUCSS.fadeDiv' at page load with the syntax 'SUCSS.fadeDiv();'. This explanation may serve as a helpful guide.