We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
branded types cannot be used for narrowing. Say that we have a
TagA: type: string enum: - a A: oneOf: - TaggedA - ... TaggedA: type: object properties: tag: $ref: TagA
then typescript does not narrow by the tag field as the tag value gets branded as a top level scalar definition.
function foo(a: A): null | Value { if (tagged.tag === 'a') { return a.value; } return null; }
instead need to use instanceof TaggedA or work with ShapeOfTaggedA. Or if possible define TaggedA as
instanceof TaggedA
TaggedAd: ... properties: tag: type: string enum: a ...
The text was updated successfully, but these errors were encountered:
No branches or pull requests
branded types cannot be used for narrowing. Say that we have a
then typescript does not narrow by the tag field as the tag value gets branded as a top level scalar definition.
instead need to use
instanceof TaggedA
or work with ShapeOfTaggedA. Or if possible define TaggedA asThe text was updated successfully, but these errors were encountered: