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
It seems there is a soundness issue with overloaded methods and literal types. See the code below.
Tried with release 2.5.3 and ^2.6.0-dev.20171015.
Code
classT<Xextends"a"|"b">{constructor(readonlyx: X){}m(this: T<"a">): "b";m(this: T<"b">): "a";m(){// should fail to typecheckswitch(this.x){case"a": return"a";case"b": return"b";default: thrownewError();}}}// const good: "a" = new T("a").m();constbad: "b"=newT("a").m();
Expected behavior:
T.m should fail type-checking. bad should fail type-checking.
Actual behavior:
T.m passes type-checking. bad passes type-checking. good fails type-checking.
The text was updated successfully, but these errors were encountered:
Is there a setting to force that this is always checked?
Adding the annotation does indeed cause m to fail to check, which is good. But now if the definition is changed to the following (which should pass type-checking) it still complains:
Now it says Overload signature is not compatible with function implementation. So is even possible to type m correctly at all in the current typescript implementation?
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
It seems there is a soundness issue with overloaded methods and literal types. See the code below.
Tried with release
2.5.3
and^2.6.0-dev.20171015
.Code
Expected behavior:
T.m
should fail type-checking.bad
should fail type-checking.Actual behavior:
T.m
passes type-checking.bad
passes type-checking.good
fails type-checking.The text was updated successfully, but these errors were encountered: