You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a class field method contains 2 or more types, using if statement can help confirm and expose the object types. But when that same field is used inside a wrapped function, the check no longer works, exposing the default type as if the control statement doesn't exist at all.
Workaround: Set the field as a separate independent variable and the check will pass through.
Sample Code
classA{test=1;testCall(){return1;}}classB{tester=2;testCaller(){return2;}}classC{testee: A|B;testCaller(){return33;}}functiontest(){letD: C=SomeFunctionThatSpawnsC();letE=D.testee;if(!(D.testeeinstanceofB))return;if(!(EinstanceofB))return;D.testee.tester;// worksE.tester;// worksconstF=()=>{D.testee.tester// Type ErrorE.tester// Works}}
Documentation Link
No response
The text was updated successfully, but these errors were encountered:
⚙ Compilation target
ESNext
⚙ Library
v5.1.3
Missing / Incorrect Definition
When a class field method contains 2 or more types, using if statement can help confirm and expose the object types. But when that same field is used inside a wrapped function, the check no longer works, exposing the default type as if the control statement doesn't exist at all.
Workaround: Set the field as a separate independent variable and the check will pass through.
Sample Code
Documentation Link
No response
The text was updated successfully, but these errors were encountered: