Type narrowing #548
-
Hi there! Another question. We have a component typed liked this (rough code): interface Args {
type: 'a' | 'b'
} … and interface Args {
type: 'a'
} … I'll see an error saying |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You need an implementation of
In other words, it's the same basic scenario as discussed in #547! |
Beta Was this translation helpful? Give feedback.
You need an implementation of
eq
which "narrows" the same way that TypeScript's===
does. At the moment, the types foreq
fromember-truth-helpers
or similar do not in general support that. I think we're missing some docs on that, but you can see how it works to give it those semantics in the implementing pull request. The reason this isn't "built in" is noted in the PR: