nvie/decoders

upgrading to TS4

joaomilho opened this issue · 5 comments

The following code works fine on TS 3.4.5:

type Example = {
    eg: string;
};

const exampleDecoder: Decoder<Example> = object({
    eg: string,
});

In TS 4.0.3 however, I got this message:

Type 'Decoder<{ eg?: string; }, unknown>' is not assignable to type 'Decoder<Example, unknown>'.
  Type '{ eg?: string; }' is not assignable to type 'Example'.
    Property 'eg' is optional in type '{ eg?: string; }' but required in type 'Example'.ts(2322)

Any ideas?

nvie commented

I cannot replicate this behavior. I ran the following steps:

  1. Create a new, empty, directory
  2. yarn add typescript decoders
  3. yarn run tsc --init
  4. Create a test.ts file with the following content
  5. Run yarn run tsc

This doesn't give any type errors for me.

nvie commented

Is there any additional information you can share?

Let me try.

Yeah, on an empty project it works fine here too. I'll take a look again and if I find anything I'll raise a new one. I guess we can close this one for now. Thanks for taking the time!

It's the strict option.