Skip to content

override isn't required in ambient contexts with noImplicitOverrideΒ #60635

Closed as not planned
@Andarist

Description

@Andarist

πŸ”Ž Search Terms

override ambient type declaration class dts noImplicitOverride

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play/?noImplicitOverride=true&ts=5.8.0-dev.20241128&ssl=15&ssc=2&pln=1&pc=1#code/PTAEAEDsHsEkFsAOAbAlgY1QFwPIDcBTAJyNQBMCAuULIgVwIChGL1kBDIg0N9gZz6gAQv24BvRqFAAjapDrxpxANyMAvs1YcuPDgNAARYqkJlQBAB5YCkMoJF9xkmXIVKiqjSwK8dvfQ4EAEygYl5anNz+gkakpiGW1rb2oiESUtCEJOTcsqDyiirqjEA

πŸ’» Code

// @noImplicitOverride: true

declare class Base {
  b: number;
}

declare class Derived extends Base {
  b: number; // no error
}

declare class Base2 {}

declare class Derived2 extends Base2 {
  override b: number; // error
}

πŸ™ Actual behavior

A property in a derived class in ambient context doesn't have to have override modifier with noImplicitOverride. override is still checked when present though.

πŸ™‚ Expected behavior

It feels slightly inconsistent. I couldn't find any note about this in the docs and I had to look into the source code and dig up the PR that implemented override to check if it's a bug or not.

Additional information about the issue

I believe this works like that since noImplicitOverride was introduced in #39669 in 4.3: TS playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions