#Type inference in Generic

3 messages · Page 1 of 1 (latest)

cinder goblet
#

Hey there,
I'm trying to create a declaration for an object literal

woven peakBOT
#
errorfourofour#0

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> = (
...```

cinder goblet
#

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