Skip to content

Contextual constness no longer provided by inherited generic properties in 4.4 #45191

@sandersn

Description

@sandersn

Bug Report

🔎 Search Terms

context inherited property

🕗 Version & Regression Information

Broken by #44601; repro from react-svg-pan-zoom on DT.

💻 Code

interface State {
    version: 2
}
declare class Base<S> {
    state: S
}
class Assignment extends Base<State> {
    constructor() {
        super()
        this.state = { version: 2 }
    }
}

🙁 Actual behavior

Error on this.state = { version: 2 } -- "version: number is not assignable to version: 2"

🙂 Expected behavior

No error on this.state = { version: 2 }

Note that you get the expected behaviour for a non-inherited property, an inherited but non-generic property, and a local variable.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions