Never type creates a typescript issue
yannbriancon opened this issue · comments
Yann Briançon commented
[BUG]
Description
Using never
with typescript ends up throwing an error:
Type 'Struct<never, null>' is not assignable to type 'Struct<any, any>'.
Types of property 'refiner' are incompatible.
Type '(value: never, context: Context) => Iterable<Failure>' is not assignable to type '(value: any, context: Context) => Iterable<Failure>'.
Types of parameters 'value' and 'value' are incompatible.
Type 'any' is not assignable to type 'never'.ts(2322)
Expected Behaviour
No error and a type generated like this:
const User = type({
name: string(),
age: never()
});
/*
* Expected type is:
* type User = {
* name: string,
* age: never
* }
Actual Behaviour
Reproduction
https://codesandbox.io/s/superstruct-never-typescript-bug-r6nnk4?file=/src/index.ts