-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Unable to access extended properties in constructor #1617
Copy link
Copy link
Closed
Labels
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" insteadCanonicalThis issue contains a lengthy and complete description of a particular problem, solution, or designThis issue contains a lengthy and complete description of a particular problem, solution, or design
Description
Activity
Metadata
Metadata
Assignees
Labels
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" insteadCanonicalThis issue contains a lengthy and complete description of a particular problem, solution, or designThis issue contains a lengthy and complete description of a particular problem, solution, or design
I'm not sure if this is an intention of typescript or not but acts differently to how I would've expected.
If i have a base class and extend it, overriding some base class properties, then want to work with the properties in the child class constructor I still access the parent properties.
This is shown in the below basic example.
This happens in the compiled JS because the super is called before the child properties are set:
Is this intended? An issue? Or a trade off because of JS limitations? Thanks!
Note that if I do something like this, it works as I would've expected. However it feels like a bit of a hacky work around.