vue3.3.polyfill.d.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. import type { Prop } from 'vue';
  2. type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
  3. type InferPropType<T, NullAsAny = true> = [T] extends [null] ? NullAsAny extends true ? any : null : [T] extends [{
  4. type: null | true;
  5. }] ? any : [T] extends [ObjectConstructor | {
  6. type: ObjectConstructor;
  7. }] ? Record<string, any> : [T] extends [BooleanConstructor | {
  8. type: BooleanConstructor;
  9. }] ? boolean : [T] extends [DateConstructor | {
  10. type: DateConstructor;
  11. }] ? Date : [T] extends [(infer U)[] | {
  12. type: (infer U)[];
  13. }] ? U extends DateConstructor ? Date | InferPropType<U, false> : InferPropType<U, false> : [T] extends [Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? IfAny<V, V, D> : V : V : T;
  14. type PublicRequiredKeys<T> = {
  15. [K in keyof T]: T[K] extends {
  16. required: true;
  17. } ? K : never;
  18. }[keyof T];
  19. type PublicOptionalKeys<T> = Exclude<keyof T, PublicRequiredKeys<T>>;
  20. declare module 'vue' {
  21. /**
  22. * Extract prop types from a runtime props options object.
  23. * The extracted types are **public** - i.e. the expected props that can be
  24. * passed to component.
  25. */
  26. type __ExtractPublicPropTypes<O> = {
  27. [K in keyof Pick<O, PublicRequiredKeys<O>>]: InferPropType<O[K]>;
  28. } & {
  29. [K in keyof Pick<O, PublicOptionalKeys<O>>]?: InferPropType<O[K]>;
  30. };
  31. interface GlobalComponents {
  32. }
  33. }
  34. export {};