4 ms·
> For one, try redefining a property as a getter/setter pair in a subclass. This is actually a completely invalid pattern in JavaScript, and it's really good t
by spankalee 4y ago
> For one, try redefining a property as a getter/setter pair in a subclass.
This is actually a completely invalid pattern in JavaScript, and it's really good that TypeScript errors for it.
Class fields are created with a define property step in the constructor, so they would shadow the getter/setter in the subclass.
The super class needs to have a getter/setter pair itself to be overrideable.
The upcoming `accessor` keyword will help by makes getter/setter pairs automatically.
As for required args and defaults, TypeScript doesn't really change anything over JavaScript except adding type warnings: https://www.typescriptlang.org/play?#code/MYewdgzgLgBAZiEMC8MAUBDATgcwgLhgG8APQsAVwFsAjAUywBoYBPAfkOiwEswcBfAJQoAfMQBQMGKEixseAOrcoACwAidOBgoAbKBBQSpUloQDkGM40nGAdPfkRrU-gG4bWOlApYwMR0qqGlq6+u5u4uIIIGikhACMQu7RsaYwFmZJQA https://www.typescriptlang.org/play?#code/MYewdgzgLgBAZiEMC8...