GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — No referencing/intellisense fo nested properties/functions within class · Issue #7801 · microsoft/TypeScript

No referencing/intellisense fo nested properties/functions within class #7801

New issue
Copy link
New issue
Copy link
Closed
Closed
No referencing/intellisense fo nested properties/functions within class#7801
Copy link
Assignees
sandersn
Labels
SuggestionAn idea for TypeScriptAn idea for TypeScriptWon't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix itThe severity and priority of this issue do not warrant the time or complexity needed to fix it

Description

@magicode118
magicode118
opened on Apr 4, 2016
Issue body actions

I have the following structure where I have a class that contains functions nested inside properties and vice versa. Intellisense and therefore referencing is not working when inside a function that resides inside a property of the class. Is there a way to solve this sort of issue so that I can reference myThirdProp inside mySecondFunc?

export class a {

    myProperty = 'hello';
    myFunc() {

        this.myProperty; //referencing and intellisense available
    }

    mySecondProp: Object = {

        myThirdProp: 'hello2',
        mySecondFunc() {

            this. //no intellisense/reference here
        }
    }
}

Activity

  1. RyanCavanaugh commented on Apr 4, 2016

    @RyanCavanaugh
    Ryan Cavanaugh (RyanCavanaugh)
    on Apr 4, 2016
    Member
    More actions

    Currently, we don't really know how mySecondProp.mySecondFunc is going to be invoked, so its this type is any. #6739 should solve this for you by allowing you to specify the type of this inside mySecondFunc.

  2. Mohamed Hegazy (mhegazy)
    added
    BugA bug in TypeScriptA bug in TypeScript
    SuggestionAn idea for TypeScriptAn idea for TypeScript
    and removed
    BugA bug in TypeScriptA bug in TypeScript
    on Apr 4, 2016
  3. Mohamed Hegazy (mhegazy)
    added this to the TypeScript 2.0 milestone on Apr 4, 2016
  4. Mohamed Hegazy (mhegazy)
    assigned
    Nathan Shively-Sanders (sandersn)
    on Apr 4, 2016
  5. Mohamed Hegazy (mhegazy)
    added
    CommittedThe team has roadmapped this issueThe team has roadmapped this issue
    on Apr 4, 2016
  6. sandersn commented on Apr 7, 2016

    @sandersn
    Nathan Shively-Sanders (sandersn)
    on Apr 7, 2016
    Member
    More actions

    this inside of an object literal now has Intellisense. @zalow517 can you try typescript@next? It will be available April 8, after the nightly build picks it up.

  7. Nathan Shively-Sanders (sandersn)
    closed this as completedon Apr 7, 2016
  8. Mohamed Hegazy (mhegazy)
    added
    FixedA PR has been merged for this issueA PR has been merged for this issue
    on Apr 7, 2016
  9. sandersn commented on Apr 30, 2016

    @sandersn
    Nathan Shively-Sanders (sandersn)
    on Apr 30, 2016
    Member
    More actions

    #8389 reverts this fix for now.

  10. Nathan Shively-Sanders (sandersn)
    reopened this on Apr 30, 2016
  11. mhegazy commented on Apr 30, 2016

    @mhegazy
    Mohamed Hegazy (mhegazy)
    on Apr 30, 2016
    Contributor
    More actions

    Cross positing from #8110 (comment)

    We have tried different ways of addressing this issue, and the current behavior (this in an object literal is of type any) seems to be the most reasonable.

    Classes present stronger assumptions about how the functions will be called. object literals on the other hand can be used as a property bag often with no assumptions about the relationship of the methods and properties on them. we have seen common JS patterns where methods are added, removed, or called with a different this target at runtime (see #8133 for an example).

    the recommendation is to specify an explicit this type in methods:

    interface FooBar {
        foo(): void;
        bar(): void;
    }
    
    let o = {
        foo: function (this: FooBar) { this /* FooBar */ },
        bar(this: FooBar) { this /* FooBar */ }
    }
  12. Mohamed Hegazy (mhegazy)
    closed this as completedon Apr 30, 2016
  13. Mohamed Hegazy (mhegazy)
    added
    Won't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix itThe severity and priority of this issue do not warrant the time or complexity needed to fix it
    and removed
    CommittedThe team has roadmapped this issueThe team has roadmapped this issue
    FixedA PR has been merged for this issueA PR has been merged for this issue
    on Apr 30, 2016
  14. Mohamed Hegazy (mhegazy)
    removed this from the TypeScript 2.0 milestone on Apr 30, 2016
  15. ahejlsberg commented on Feb 17, 2017

    @ahejlsberg
    Anders Hejlsberg (ahejlsberg)
    on Feb 17, 2017
    Member
    More actions

    See #14141.

  16. microsoft
    locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sandersn
    Nathan Shively-Sanders (sandersn)

Labels

SuggestionAn idea for TypeScriptAn idea for TypeScriptWon't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix itThe severity and priority of this issue do not warrant the time or complexity needed to fix it

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.