Skip to content

Property using declare prompts to add 'override' even though that does not seem valid #43566

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
mjbvz opened this issue Apr 7, 2021 · 3 comments · Fixed by #43569
Closed
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Apr 7, 2021

Bug Report

🔎 Search Terms

  • noImplicitOverride
  • static

🕗 Version & Regression Information

4.3.0-dev.20210406

💻 Code

Using --noImplicitOverride:

export class Foo{
    kind = 1;
}

class SubFoo extends Foo{
    declare kind: undefined;
}

🙁 Actual behavior

On declare kind: undefined, I see:

This member must have an 'override' modifier because it overrides a member in the base class 'Foo'

Adding override makes the code invalid

🙂 Expected behavior

We should probably change our code to:

class SubFoo extends Foo{
    override kind: undefined;
}

However using declare was previously valid and the current error message seems incorrect

@fregante
Copy link

If anyone lands here from Google, you can either:

  • add "noImplicitOverride": false to your tsconfig (just to silence it temporarily)
  • add the override keyword to the methods TypeScript mentions

@Hatem-Nofal
Copy link

Hatem-Nofal commented May 11, 2022

If anyone lands here from Google, you can either:

  • add "noImplicitOverride": false to your tsconfig (just to silence it temporarily)
  • add the override keyword to the methods TypeScript mentions

"* add "noImplicitOverride": false to your tsconfig (just to silence it temporarily)" => it's work thanks

@BenRacicot
Copy link

I noticed that public does not cause TS to give this error. private was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants