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
So the one 3.0 feature I’m thinking about not supporting is not. The reason is… I’m not sure how!
According to the definition:
The not keyword does not exactly combine schemas, but as all of the keywords mentioned above it helps you to modify your schemas and make them more specific.
While that can be done in JavaScript at runtime (typeof PetByType !== 'number'), I don’t think it’s possible in TypeScript to create a type that’s equal to anything but the given type.
Am I wrong? Is this possible?
The text was updated successfully, but these errors were encountered:
It seems like this could be accomplished with a general union type which expresses all the basic types which openAPI supports, and the Exclude utility type:
I actually haven’t used Exclude<> much! But it looks promising.
🤔 I think your solution is absolutely perfect for primitives. But my hesitation would be when it comes to advanced types. Like, what would not: { $ref: '…' } look like?
I haven’t run across not used in a real-world schema, and I couldn‘t get a good picture from the spec how this is enforced. Should we just put a pin in this until someone has a real-world example how they use it?
So the one 3.0 feature I’m thinking about not supporting is not. The reason is… I’m not sure how!
According to the definition:
The example given is:
While that can be done in JavaScript at runtime (
typeof PetByType !== 'number'
), I don’t think it’s possible in TypeScript to create a type that’s equal to anything but the given type.Am I wrong? Is this possible?
The text was updated successfully, but these errors were encountered: