Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DanielRosenwasser opened this issue Aug 16, 2021 · 2 comments · Fixed by #49827
Closed

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

DanielRosenwasser opened this issue Aug 16, 2021 · 2 comments · Fixed by #49827
Assignees
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Domain: JavaScript The issue relates to JavaScript specifically Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@DanielRosenwasser
Copy link
Member

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();
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Domain: JavaScript The issue relates to JavaScript specifically labels Aug 16, 2021
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.5.0 milestone Aug 16, 2021
@DanielRosenwasser
Copy link
Member Author

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.

@sandersn
Copy link
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.

@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Dec 15, 2021
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Domain: JavaScript The issue relates to JavaScript specifically Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants