Skip to content
New issue

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

Extends Optional Property Check #650

Merged
merged 2 commits into from
Oct 29, 2023
Merged

Extends Optional Property Check #650

merged 2 commits into from
Oct 29, 2023

Conversation

sinclairzx81
Copy link
Owner

This PR resolves an optional property check when comparing left and right property keys. The following now works.

type A = { a: number }
type B = { a?: number }
type C = A extends B ? true : false // true

// ...

const A = Type.Object({ a: Type.Number() })
const B = Type.Object({ a: Type.Optional(Type.Number()) })
const C = TypeExtends.Extends(A, B) // True

Inversion

type A = { a: number }
type B = { a?: number }
type C = B extends A ? true : false // false

// ...

const A = Type.Object({ a: Type.Number() })
const B = Type.Object({ a: Type.Optional(Type.Number()) })
const C = TypeExtends.Extends(B, A) // False

@sinclairzx81 sinclairzx81 merged commit ce1ace5 into master Oct 29, 2023
18 checks passed
@sinclairzx81 sinclairzx81 deleted the extends branch October 29, 2023 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant