回答

无。

分析

  1. // lib.es5.d.ts源码
  2. /**
  3. * Make all properties in T optional
  4. */
  5. type Partial<T> = {
  6. [P in keyof T]?: T[P];
  7. };
  8. /**
  9. * Make all properties in T required
  10. */
  11. type Required<T> = {
  12. [P in keyof T]-?: T[P];
  13. };
  14. /**
  15. * Make all properties in T readonly
  16. */
  17. type Readonly<T> = {
  18. readonly [P in keyof T]: T[P];
  19. };
  20. /**
  21. * From T, pick a set of properties whose keys are in the union K
  22. */
  23. type Pick<T, K extends keyof T> = {
  24. [P in K]: T[P];
  25. };
  26. /**
  27. * Construct a type with a set of properties K of type T
  28. */
  29. type Record<K extends keyof any, T> = {
  30. [P in K]: T;
  31. };
  32. /**
  33. * Exclude from T those types that are assignable to U
  34. */
  35. type Exclude<T, U> = T extends U ? never : T;
  36. /**
  37. * Extract from T those types that are assignable to U
  38. */
  39. type Extract<T, U> = T extends U ? T : never;
  40. /**
  41. * Construct a type with the properties of T except for those in type K.
  42. */
  43. type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
  44. /**
  45. * Exclude null and undefined from T
  46. */
  47. type NonNullable<T> = T extends null | undefined ? never : T;
  48. /**
  49. * Obtain the parameters of a function type in a tuple
  50. */
  51. type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never;
  52. /**
  53. * Obtain the parameters of a constructor function type in a tuple
  54. */
  55. type ConstructorParameters<T extends new (...args: any) => any> = T extends new (...args: infer P) => any ? P : never;
  56. /**
  57. * Obtain the return type of a function type
  58. */
  59. type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
  60. /**
  61. * Obtain the return type of a constructor function type
  62. */
  63. type InstanceType<T extends new (...args: any) => any> = T extends new (...args: any) => infer R ? R : any;
  64. /**
  65. * Marker for contextual 'this' type
  66. */
  67. interface ThisType<T> { }

参考资料

  1. TypeScript 强大的类型别名 [https://juejin.im/post/6844903753431138311]