Skip to content

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

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
AsamK opened this issue May 26, 2021 · 2 comments · Fixed by #44290
Closed

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

AsamK opened this issue May 26, 2021 · 2 comments · Fixed by #44290
Assignees
Labels
Bug A bug in TypeScript Domain: JS Emit The issue relates to the emission of JavaScript Fix Available A PR has been opened for this issue Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this

Comments

@AsamK
Copy link

AsamK commented May 26, 2021

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

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label May 27, 2021
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.3.3 milestone May 27, 2021
@DanielRosenwasser DanielRosenwasser added the Domain: JS Emit The issue relates to the emission of JavaScript label May 27, 2021
@DanielRosenwasser DanielRosenwasser added Good First Issue Well scoped, documented and has the green light Help Wanted You can do this labels May 27, 2021
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented May 27, 2021

We have tests for this, we just didn't read them correctly. nevermind

@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label May 27, 2021
@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Jun 3, 2021
@DanielRosenwasser
Copy link
Member

Thanks @a-tarasyuk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: JS Emit The issue relates to the emission of JavaScript Fix Available A PR has been opened for this issue Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants