-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Zod resolved type change for Opaque type between v3.14.4 -> v3.15.1 #1121
Comments
Fixes this issue: colinhacks#1121 Specifically, `{ property: (T | undefined) & T }` does not seem to flatten to `{ property: T }` in the case that T is a complex string literal.
Fixes this issue: colinhacks#1121 Specifically, `{ property: (T | undefined) & T }` does not seem to flatten to `{ property: T }` in the case that T is a complex string literal.
Hi @bluepnume. Sorry about this. I changed the definition of As a side node, although the type looks ugly and we should definitely fix the problem, I believe the types |
Thanks @bentefay! Appreciate the fast turnaround! No huge rush to merge, since I can just lock to type QueenCard = Hand['card'];
type CardValue = {
[ FACE.QUEEN ] : 12,
[ FACE.KING ] : 13,
};
type CardToValue<Face extends FACE> = Face extends keyof CardValue
? CardValue[Face]
: never;
const cardToValue = <Face extends FACE>(card : FaceCard<Face>) : CardToValue<Face> => {
return someLogic(card);
};
const value = cardToValue('' as QueenCard);
const expectedValue : 12 = value;
console.log('Value is', value, 'expected', expectedValue); ^ This code type-checks with const expectedValue : 12 = value;
-- essentially, while |
Ahh that makes complete sense. It's also not something I could have possibly dreamed up as a test 😄. Now I see it though I suppose we could add that as a unit test, though it would be perhaps a little too specific? I wonder if there is a simpler set of types that expose the problem. |
* Fix addQuestionsMarks so it resolves correctly in more cases Fixes this issue: #1121 Specifically, `{ property: (T | undefined) & T }` does not seem to flatten to `{ property: T }` in the case that T is a complex string literal. * Ran lint on languageServerFeatures.test.ts
Resolved in 3.16, thanks @bentefay |
Thanks @bentefay and @colinhacks! And again thanks for a stellar library, you guys rock. |
…1122) * Fix addQuestionsMarks so it resolves correctly in more cases Fixes this issue: colinhacks#1121 Specifically, `{ property: (T | undefined) & T }` does not seem to flatten to `{ property: T }` in the case that T is a complex string literal. * Ran lint on languageServerFeatures.test.ts
* Fix addQuestionsMarks so it resolves correctly in more cases Fixes this issue: colinhacks/zod#1121 Specifically, `{ property: (T | undefined) & T }` does not seem to flatten to `{ property: T }` in the case that T is a complex string literal. * Ran lint on languageServerFeatures.test.ts
I have the following code:
In
[email protected]
,Hand
resolved to:But now in
[email protected]
,Hand
is resolving to:Why did the second type get more complex here, when the first one is correct?
(By the way -- incredible library. Thank you for making this, seriously.)
The text was updated successfully, but these errors were encountered: