Skip to content

Using @ts-expect-error on class method signature would disable checking all other methods in interface #59266

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
fenying opened this issue Jul 14, 2024 · 2 comments

Comments

@fenying
Copy link

fenying commented Jul 14, 2024

πŸ”Ž Search Terms

ts-expect-error missing method

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried between v4.0 and v5.5, didn't try older versions

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.5.3#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgSQBVgBneAbwChK5a5MAKASgC44A3CBAEwG5q6cAEbM2nHvwC+1UJFhxsAG0wkScYmUQBbMIuBbgKNUVIUBdAPQW4AARgkAtLODYYTqFGg06YAK5DFBGx6BgBrNjIoZABzVg4ubjhyaWkgA

πŸ’» Code

export interface ITest {

    a(): void;

    b(): void;
}

export class Test implements ITest {

    // @ts-expect-error
    public a(k: string): void {}

    // method b is missing, but no errors reported
}

πŸ™ Actual behavior

No error reported even missing a method in the class

πŸ™‚ Expected behavior

Should report errors if any method is not implemented in class

Additional information about the issue

No response

@MartinJohns
Copy link
Contributor

ts-expect-error is not the culprit here, you also don't get the error you expect when you remove it. The compiler doesn't check if your class implements the interface when there's already an error inside your class. Using ts-expect-error does not remove the error and let the compiler happily continue its job, it just hides the error.

Related comment: #47551 (comment)

once your program has a type error in it, it's up to our heuristics to decide exactly what the most useful reporting of that type error is.

@fenying
Copy link
Author

fenying commented Jul 15, 2024

OH. I see, the compiler stops checking next error if it meet an error, until this one got resolved :(

@fenying fenying closed this as completed Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants