#Type inference in Generic
3 messages · Page 1 of 1 (latest)
Preview:```ts
type PropertyConstructor = StringConstructor | NumberConstructor | BooleanConstructor;
type PropertySchemaBase<Type extends unknown> = (
Type extends PropertyConstructor
? {
type: Type;
// other props
}
: never
);
type PropertySchemaWithDefault<Type extends unknown> = (
...```
You can choose specific lines to embed by selecting them before copying the link.
it's working
but
at the moment the field type is infered from the default value.
I was wondering if it's possible to do this the other way round?
like infer default from type