Skip to content

TypeScript preserves 'override' modifier on properties in JavaScript esnext output #44273

Closed
@AsamK

Description

@AsamK

Bug Report

🔎 Search Terms

override, property, esnext

🕗 Version & Regression Information

Bug in new feature of version 4.3

💻 Code

class Base {
    state?: string;
}
    
export default class TestClass extends Base {
    override state = "string";
}

🙁 Actual behavior

Compiling this code for target esnext the override keyword on properties is preserved:

tsc -t esnext TestClass.ts
class Base {
    state;
}
export default class TestClass extends Base {
    override state = "string";
}

🙂 Expected behavior

The override keyword should be removed from the javascript output, as it is already done correctly for methods.

(Compiling for other targets (e.g. es2021) works correctly as the property is transformed to a constructor initialization.)

Maybe related to #43535

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JS EmitThe issue relates to the emission of JavaScriptFix AvailableA PR has been opened for this issueFixedA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions