You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exporttypeProp<T>={(): T}exporttypePropType<T>=Prop<T>;exporttypePropDefaultValue<T>=T;exporttypePropValidatorFunction<T>=(value: T)=>boolean;exporttypePropValidator<T>=PropOptions<T>;exporttypePropOptions<T>={type: PropType<T>;value?: PropDefaultValue<T>,required?: boolean;validator?: PropValidatorFunction<T>;}exporttypeRecordPropsDefinition<T>={[KinkeyofT]: PropValidator<T[K]>}exporttypePropsDefinition<T>=RecordPropsDefinition<T>;declarefunctionextend<T>({ props }: {props: PropsDefinition<T>}): PropsDefinition<T>;interfaceMyType{valid: boolean;}constr=extend({props: {// gets resolved to PropOptions<any> but should be PropType<MyType>notResolved: {type: ObjectasPropType<MyType>,// type not inferred validator: (x)=>{returnx.valid;}},// gets resolved currectly to PropType<MyType>// on typescript@3.4rc doest resolve to PropType<MyType>explicit: {type: ObjectasPropType<MyType>,// type not inferred validator: (x: MyType)=>{returnx.valid;}}}})// return type on 3.4@rc doesn't get resolvedr.explicitr.notResolvedr.explicit.requiredr.notResolved.required
Expected behavior:
The validator parameter as typescript type inferred from T.
Props record values to be resolved with the interface of PropType
Return type to be PropsDefinition<T>
Actual behavior:
Getting validator parameter resolved as any/unknown.
Record types are not getting resolve to the type PropOptions<T> in 3.4@rc but working in 3.3.x
The return type not working in 3.4@rc
The key issue here is that during the initial pass in type inference where we defer context sensitive function expressions and arrow functions, we never perform reverse mapped type inference on types that contain anything context sensitive. That is too conservative because, as illustrated by the examples, there are cases where we want to infer from the properties that aren't context sensitive and then apply those inferences to the context sensitive locations. I will be putting up a PR that does this.
TypeScript Version: 3.4.0@rc
Search Terms:
Code
Expected behavior:
The
validator
parameter as typescripttype
inferred fromT
.Props record values to be resolved with the interface of PropType
Return type to be
PropsDefinition<T>
Actual behavior:
Getting validator parameter resolved as
any
/unknown
.Record types are not getting resolve to the type
PropOptions<T>
in 3.4@rc but working in 3.3.xThe return type not working in 3.4@rc
Playground Link:
playground
The text was updated successfully, but these errors were encountered: