jtwang7 / JavaScript-Note

JavaScript学习笔记
10 stars 2 forks source link

TS - 箭头函数泛型的6种表示 #60

Open jtwang7 opened 2 years ago

jtwang7 commented 2 years ago

常用const foo = <T extends {}>(x: T): T => x;

const foo: <T>(x: T) => T = x => x;

const foo = <T,>(x: T): T => x;

const foo = <T extends Record<string, unknown>>(x: T): T => x;

const identity = <T,>(arg: T): T => {
    console.log(arg);
    return arg;
};

const renderAuthorize = <T>(Authorized: T): ((currentAuthority: CurrentAuthorityType) => T) => (
    currentAuthority: CurrentAuthorityType,
  ): T => {
     return
 };