Open VeryCrazyDog opened 3 years ago
Also getting this same problem in superstruct@1.0.3
and typescript@5.1.3
. The issue also seems to only occur if you use Describe
:
import { optional, assign, string, Describe, type } from "superstruct";
interface Foo {
bar?: string;
}
const Foo: Describe<Foo> = type({
bar: optional(string()),
});
const Baz = assign(Foo, type({ qux: string() }));
Error:
Argument of type 'Describe<Foo>' is not assignable to parameter of type 'Struct<{ bar?: unknown; }, { bar?: Describe<string | undefined> | undefined; }>'.
Types of property 'refiner' are incompatible.
Type '(value: Foo, context: Context) => Iterable<Failure>' is not assignable to type '(value: { bar?: unknown; }, context: Context) => Iterable<Failure>'.
Types of parameters 'value' and 'value' are incompatible.
Type '{ bar?: unknown; }' is not assignable to type 'Foo'.
If Describe
is not used, then no errors reported.
Infer has the same problem
Below is the minimal example to reproduce the error using superstruct 0.15.1 and TypeScript 4.2.3. Expect the not working potion of code to work without error but this is not the case.
The following errors are observed: