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
This is unfortunately a limitation from the TypeScript type system – structural typing makes it consider two classes with different names as the same type, unless they contain a discriminant property to distinguish them.
classClassA{}classClassB{}typeT=Exclude<ClassA|ClassB,ClassA>// ^? never
In this case, you could expect T to be of type ClassB, but it isn't.
One workaround is to give them a discriminant property:
Describe the bug
The
exhaustive()
function does not raise a TS error wheninstanceOf
is used and not all possible classes are handledTypeScript playground with a minimal reproduction case
Example: Playground
In the above example, I would expect that
exhaustive()
to raise aNonExhaustiveError
error becauseClassB
is not handledVersions
The text was updated successfully, but these errors were encountered: