[Typescript 5.3] returnWhatIPassIn

const returnWhatIPassIn = <const T extends any[]>(t: T) => {
  return t;
};

// result is any[] in TS 5.2, but ['a', 'b', 'c'] in 5.3
const result = returnWhatIPassIn(["a", "b", "c"]); // type as ["a", "b", "c"]

 

posted @ 2023-12-13 01:55  Zhentiw  阅读(6)  评论(0编辑  收藏  举报