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
error TS2322: Type 'Decoder<Expand<{ [P in undefined extends T ? "foo" : never]?: { foo: T; }[P]; } & { [P in undefined extends T ? never : "foo"]: { foo: T; }[P]; }>, unknown>' is not assignable to type 'Decoder<{ foo: T; }, unknown>'.
Type 'Expand<{ [P in undefined extends T ? "foo" : never]?: { foo: T; }[P]; } & { [P in undefined extends T ? never : "foo"]: { foo: T; }[P]; }>' is not assignable to type '{ foo: T; }'.
Property 'foo' is missing in type '{}' but required in type '{ foo: T; }'.
2 const recordDecoder: Decoder<{ foo: T }> = fieldsAuto({ foo: decodeT });
~~~~~~~~~~~~~
The type {} seems suspicious. Perhaps interestingly, the following change doesn't affect the last line of the error message at all:
- const recordDecoder: Decoder<{ foo: T }> = fieldsAuto({ foo: decodeT })+ const recordDecoder: Decoder<{ foo: T }> = fieldsAuto({ foo: decodeT, bar: number })
I'm on TypeScript 4.9.5.
The text was updated successfully, but these errors were encountered:
Yes, fieldsAuto + generics is broken. It’s due to WithUndefinedAsOptional, which is fundamentally broken. (We talked about this elsewhere once if you remember, when someone else reported a similar problem.)
I’ve solved this design mistake, and #22, in the codec branch. You probably won’t be able to see anything interesting in that diff, though, because it’s heavy WIP and features a new (but similar) API (with “codecs” instead of decoders).
The status of the branch is that I’m satisfied with the new API and have managed to make it work type wise. I now need to update documentation and tests, and fix bugs that the tests will uncover.
This works as expected at run time:
But it doesn't type check:
The type
{}
seems suspicious. Perhaps interestingly, the following change doesn't affect the last line of the error message at all:I'm on TypeScript 4.9.5.
The text was updated successfully, but these errors were encountered: