Last active
January 13, 2020 03:25
-
-
Save siassaj/884173d0256a534bccca8a87f667841e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // everything works totally correctly with this version | |
| export function test< | |
| P extends Props | |
| >(input: unknown, innerCodec: TypeC<P>) { | |
| return innerCodec.is(input) // no errors | |
| } | |
| // no errors within this function, but where the function is called such as | |
| // | |
| // test({}, someCodec) | |
| // type { [x: string]: any } is missing the following properties from type '{ id: number; completed_at: string | null; }': id, completed_at [2345] | |
| export function test< | |
| P extends Props, | |
| InnerCodec extends TypeC<P>, // <- use a named type to make it easier to read | |
| >(input: unknown, innerCodec: InnerCodec) { | |
| return innerCodec.is(input) | |
| } | |
| // no errors within this function, but where the function is called such as | |
| // | |
| // test({}, someCodec) | |
| // type { [x: string]: any } is missing the following properties from type '{ id: number; completed_at: string | null; }': id, completed_at [2345] | |
| export function test< | |
| P extends Props, | |
| InnerCodec extends TypeC<P> = TypeC<P>, // <- use a named type to make it easier to read | |
| >(input: unknown, innerCodec: InnerCodec) { | |
| return innerCodec.is(input) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment