Don't emit abstract members #40632
Labels
Bug
A bug in TypeScript
Fix Available
A PR has been opened for this issue
Help Wanted
You can do this
Milestone
TypeScript Version: 3.7 - 4.1.0-dev.20200918
Search Terms:
abstract properties emit useDefineForClassFields
Code
Turn on
useDefineForClassFields
Expected behavior:
Abstract members are hint for typescript and they don't emit any code. So expected compiled code will be:
Actual behavior:
Playground Link:
https://www.typescriptlang.org/play?useDefineForClassFields=true&ts=4.1.0-dev.20200918#code/IYIwzgLgTsDGEAJYBthjAgggg3gKAUIQAcoB7CAU3koBMFRIZ4EAPALgQDsBXAWxCUoAbjwBfIA
Consequence of such generation:
There is a larger problem caused by compiling abstract member.
There are 2 ways of override - using property or using getter/setter and they both should be (and are according to ts) compatible with abstract member. But only one of them is fine in runtime.
Code
Turn on
useDefineForClassFields
Run compiled code
Expected behavior:
Output:
Compiled code:
Actual behavior:
Ouptut:
Compiled code:
Playground Link:
https://www.typescriptlang.org/play?useDefineForClassFields=true&ts=4.1.0-dev.20200918#code/IYIwzgLgTsDGEAJYBthjAgggg3gKAUIQAcoB7CAU3koBMEpLhayA7ZATwVEhngQAeALgSsArgFsQlKAG48BIsTEhkAS1gIWAZQkQAFgAoAlLkVEisNmDLJKAOmRkA5oYNqw9gcfMIAvngBeChoGABCCJQCVKy0GNj4FqQU1FT0AggAvAgAjAAMgQoh6AgAwpHRlLHxZknkVDT0zpSIAia4DC1iUKwIAOz+hXislADuCGEm9jp6Rj4j46VTMwYmQA
Related Issues:
#31225
The text was updated successfully, but these errors were encountered: