Skip to content

No suggestion diagnostic for unchecked JS files in method from class #45479

Closed

Description

class Person {
    getFavoriteColor() {

    }
}

const person = new Person();
person.getFavoriteColour();

Expected

A suggestion diagnostic:

Property 'getFavoriteColour' may not exist on type 'Person'. Did you mean 'getFavoriteColor'?

Actual

No suggestion diagnostic.

In contrast, see this example:

const person = {
    getFavoriteColor() {

    }
}

person.getFavoriteColour();

Activity

  1. DanielRosenwasser commented on Aug 16, 2021

    @DanielRosenwasser
    MemberAuthor

    Ugh, from #44271

    The error is suppressed for property accesses on a class because the compiler doesn't understand JS constructor functions well enough. In particular, it doesn't understand any inheritance patterns.

  2. sandersn commented on Aug 19, 2021

    @sandersn
    Member

    I think that rule could be improved to allow suggestions from class types that are known to come from a class declaration or expression which don't have an extends clause. It's constructor functions where I observed the bad suggestions, and it's possible that completions from a base class might also be bad.

    That rule is even harder to explain though.

  3. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallyFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestonecheckJsRelates to checking JavaScript using TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions