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
Your MyClass<string> | unknown confused me for a minute into thinking you were asking for something else (i.e., that MyClass<X> | unknown should be narrowed to MyClass<X> if you use instanceof, but that's not possible because unknown absorbs everything). Maybe you can just change it to unknown, since that's the same thing and there's no implication of narrowing to a union member?
Is the idea that since MyClass<T> is covariant in T, that the constraint should be used instead of any when narrowing via instanceof? And if it were contravariant you'd expect never, and if it were invariant or otherwise problematic then any would be fine?
π Search Terms
instanceof
any
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/MYGwhgzhAECyCeBRATsg9sgPAFWgUwA8AXPAOwBMYIjkBLUgcwD5oBvAKGmgAcBXAIxC1g0IgC5o2ANydowNKWrJewIhgAU4yQEo2srkQAWtCADoi0ALyiZXAL7sH7cnlBhkeOQur5UGCQgo6FhK9MzQAD7QvKQA1qRoAO6kMuy0AGbQ6nh+yND01GCkwHhomYG5uhxcOcHmttAA9I1cXAB6APyyzfgE3K4k5BKhjN0tYKq8YCASRfDQgDLkjkA
π» Code
π Actual behavior
See above.
π Expected behavior
See above.
Additional information about the issue
Potentially related?: #17253. Although, this one seems to be for anonymous classes, which is not the case here.
The text was updated successfully, but these errors were encountered: