Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:58:06+00:00 2026-06-14T05:58:06+00:00

I have the following class defined: class Link { Action: string; DialogType: string; constructor

  • 0

I have the following class defined:

class Link {
    Action: string;
    DialogType: string;
    constructor ($link: JQuery) {
        this.Action = $link.attr('data-action') || '';
        this.DialogType = $link.attr('data-dialogType') || '';
    }
}

I have function that declares an instance of the class. Once the class is declared then I can use intellisense and there is full type checking:

function adminDialog($link: JQuery) {
    var link = new Link($link);
    link.Modal.MaxHeight = 600;
    doDialogAjax(link);
}

In the doDialogAjax function below I still have full type checking:

function doDialogAjax(link: Link) {
    $.ajax( link.Url, {
        cache: false,
        context: { link: link },
        dataType: 'html'
    }).done(onDialogDone).fail(onDialogFail);
}

At this point I lose the type checking if I try to access this.link:

function onDialogDone(data: any, textStatus: string, jqXHR: JQueryXHR) {

    // no type checking. I can type anything after this.link
    var x = this.link.abcdefg;

    // I assign to link
    var link: Link = this.link;

    // Now I get checking
    var a = link.Modal.MaxHeight; // allowed
    var a = link.abcdefg;         // error

    // However will the following change the property of the link passed 
    // into the function. I assume not but I am not 100% sure.
    link.Modal.MaxHeight = 999;

}

So my question here is how can I get type checking for the value of link passed using context to the function onDialogDone? Also am I correct in saying that after I create a new variable link in that function then any changes made to link will not be made to the object that is passed in as this.link?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:58:08+00:00Added an answer on June 14, 2026 at 5:58 am

    This line is a perfectly valid way of doing what you want:

    var link: Link = this.link;
    

    I would suggest changing it to:

    var link = <Link>this.link;
    

    Each object in JavaScript is a reference, and you don’t create a new object with this line.
    So any change on the new link variable is reflected on this.link.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function defined inside my linked list class. The declaration in
If I have the following class defined, class Category { /** * * @var
I have defined the following class using COM to use the IGroupPolicyObject using C#.NET:
Let's say I have defined the following class: public abstract class Event { public
I have the following classes defined to do validation: public class DefValidator : IValidate<IDef>
I have the following interface defined to expose a .NET class to COM: [InterfaceType(ComInterfaceType.InterfaceIsDual)]
I have two entities, defined as following public class Corporation { public int Id{get;set;}
All, i have the following model defined, class header(models.Model): title = models.CharField(max_length = 255)
I have defined an Event class: Event and all the following classes inherit from
I have the following defined: class AnswerChoiceInline(admin.TabularInline): model = AnswerChoice # extra = 0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.