[Typescript] Exercise: const T

// Before
declare function useState<T>(status: T[]): T;
const loadingStatus = useState(["loading", "idle"]) // string type

// after
declare function useState2<const T>(status: T[]): T;
const loadingStatus2 = useState2(["loading", "idle"]) // loading | idle

 

posted @ 2024-01-22 02:57  Zhentiw  阅读(8)  评论(0编辑  收藏  举报