the property does not exist on type '{}'

advertisements

I am using Visual Studio 2013 fully patched. I have a website that i've just created and am trying to use jquery, jqueryui and jsrender. I am also trying to use TypeScript. In the ts file i'm getting an error as follows

Property 'fadeDiv' does not exist on type '{}'.

I have the correct references i think for jquery, jqueryui and jsrender for typescript.. but from what I've read this is looking like a d.ts issue. Was hoping someone could help me out.

there are no errors in javascript but i don't want to have Visual Studio saying there are errors if i can help it. Both times fadeDiv is mention in the javascript there is a red line under it and both errors say the same thing as above.

thanks shannon

/// <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/General.aspx/_FadeDiv1",
        url: "/js/sucss/General.aspx/_FadeDivList",
        //data: "{'iInput':" + JSON.stringify(jInput) + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        error: function (xhr, status, error) {
            // Show the error
            //alert(xhr.responseText);
        },
        success: function (msg) {
            mFadeText = msg.d.Fade;
            // Replace the div's content with the page method's return.
            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');
            }
        }
    });
});

For those who might read this later.. the SUCSS the namespace.. In typescript it appears I would have wanted to do something like this.

$(document).ready(function () {
    SUCSS.fadeDiv();
});
module SUCSS {
    export function fadeDiv () {};
};

So the function is made public by use of the export and i could call the SUCSS.fadeDiv to run on the page loading by calling it out in with the SUCSS.fadeDiv(); hope that can be helpful.


Simply assign the any type to the object:

let bar = <any>{};
bar.foo = "foobar";