-
Notifications
You must be signed in to change notification settings - Fork 7
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
Error identifying equality creating z.custom #30
Comments
Hello @sonegobruno, Yeah sorry, I have to work on the The workaround I iplement when the Equal type chokes is: {
type Expected = Shema;
type Got = z.infer<typeof statusShema>;
assert<Expected extends Got ? true : false>();
assert<Got extends Expected ? true : false>();
} As long as your types does not involves function this is bullet poof. If your types involves function it might, in certain edge cases, yield false positive (deeming equals types that are not). |
Also, quick tip, I encourage you to use anonymous scope |
Thanks this worked for me 👍 |
Glad the workaround does it for you! |
I encountered a problem identifying equality between types generated by z.custom on an object
General file
![Captura de tela de 2023-11-16 09-19-04](https://private-user-images.githubusercontent.com/33105540/283447389-b59ccd76-6a4c-4bf1-b34a-45a1467910bc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4NDYyMzAsIm5iZiI6MTczODg0NTkzMCwicGF0aCI6Ii8zMzEwNTU0MC8yODM0NDczODktYjU5Y2NkNzYtNmE0Yy00YmYxLWIzNGEtNDVhMTQ2NzkxMGJjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA2VDEyNDUzMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ1ZjhmOGYyYmViMjBmYzgxYjg3ZjIxMWQ4ODMzMmVlNGRlNmNmZjEyZTIyYjEyYmU4ZjM1NDA2ZTNiNzk5ZjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.W2XjRWel_45B2hBaUJCl1bPYh6HHh53c-0RijtlK5ow)
Schema type inferred
![Captura de tela de 2023-11-16 09-24-56](https://private-user-images.githubusercontent.com/33105540/283448846-eaae426c-0c91-4a1a-9c13-6b1fa1c01392.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4NDYyMzAsIm5iZiI6MTczODg0NTkzMCwicGF0aCI6Ii8zMzEwNTU0MC8yODM0NDg4NDYtZWFhZTQyNmMtMGM5MS00YTFhLTljMTMtNmIxZmExYzAxMzkyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA2VDEyNDUzMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI2YWM5MjNmZjc3ODIxODNkMmRhZmUxYjlkZjA2YmQ3YTgwODQzY2FkNGE0ZDNkNThlOTUwZTI1ODFkMmFkZGMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.NIj3-BqZJXCS6F7QRQBxHKZiK6TSIJKts1SIqtB2Ivg)
Type created
![Captura de tela de 2023-11-16 09-24-59](https://private-user-images.githubusercontent.com/33105540/283448864-8f7bb1a0-5a61-461c-aa6f-8a3d46f44cf9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4NDYyMzAsIm5iZiI6MTczODg0NTkzMCwicGF0aCI6Ii8zMzEwNTU0MC8yODM0NDg4NjQtOGY3YmIxYTAtNWE2MS00NjFjLWFhNmYtOGEzZDQ2ZjQ0Y2Y5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA2VDEyNDUzMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkwMzI4MWU3NjQwNDNhOGFmMGVjNDA4MTMyMWVmZTY4OTllMzA1MDBiMjJjNGFhODQ1M2QwZTU4YzYyZDZmNWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.iOYU_8AMADA1yxGYrVCd93oxcE6HNl6ZdTxInBSXxPU)
It can be seen that when the schema assert is performed directly it passes without problems. However, when asserting within an object it presents an error even though it has the same typing.
I also noticed that when determining the attribute as optional the error disappears.
The text was updated successfully, but these errors were encountered: