杜一袁老师讲解类型体操

type JSTypeMap = {
  boolean: boolean;
  bigint: bigint;
  number: number;
  string: string;
  symbol: symbol;
  undefined: undefined;
  object: object;
  function: (...args: any[]) => any;
};
type JSTypes = keyof JSTypeMap;

type GetType<T extends JSTypes[]> = {
  [I in keyof T]: JSTypeMap[T[I]];
};

declare function addImpl<T extends JSTypes[]>(
  ...args: [...T, (...args: GetType<T>) => any]
): void;

addImpl("string", "bigint", "number", (a, b, c) => {});
posted @ 2026-06-16 20:11  一个行走者  阅读(4)  评论(0)    收藏  举报