Skip to content

Type Alias: InferPropType<T>

ts
type InferPropType<T> = [T] extends [null] ? any : [T] extends [{
  type: null | true;
}] ? any : [T] extends [
  | ObjectConstructor
  | {
  type: ObjectConstructor;
}] ? Record<string, any> : [T] extends [
  | BooleanConstructor
  | {
  type: BooleanConstructor;
}] ? boolean : [T] extends [
  | DateConstructor
  | {
  type: DateConstructor;
}] ? Date : [T] extends [
  | infer U[]
  | {
  type: ...[];
}] ? U extends DateConstructor ? Date | InferPropType<U> : InferPropType<U> : [T] extends [Prop<infer V, infer D>] ? unknown extends V ? IfAny<V, V, D> : V : T;

Infers the actual prop type from a Vue prop definition. Handles string/number/boolean constructors, prop objects with type, defaults, and more.

Type Parameters

Type ParameterDescription
TThe prop definition (constructor or Prop object)