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
Make JsonObject
work as expected with TS 4.4 --exactOptionalPropertyTypes
#272
Comments
👍 |
Since this style of
Relatedly: JSON.stringify(['foo', 1, undefined, 2]) Outputs: ["foo",1,null,2] So I guess (If one wants to go crazy, then such serialization/stringification versions of the types could even include support for the |
FI: A version that supports both cases (playground) added in #465. export type JsonObject = {[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined}; |
#269 brought to my attention that #65 changed the
JsonObject
so that all keys are marked as optional.Before TypeScript 4.4 a
{ foo?: string}
and a{ foo?: string|undefined }
was always treated as equal, so #65 made sense then.But with TS 4.4 the new
--exactOptionalPropertyTypes
config was introduced, which (correctly )no longer treats{ foo?: string}
as equal to{ foo?: string|undefined }
.For some reason though, the change introduced in #65 still gets treated in the old way:
type-fest/source/basic.d.ts
Line 22 in 6b6d81c
I would propose reverting #65 and moving back to:
I think it behaves more correctly, as can be seen in this playground.
Upvote & Fund
The text was updated successfully, but these errors were encountered: