相关疑难解决方法(0)

如何在打字稿中使用 toSorted() 方法

当我尝试在打字稿中使用toSorted方法时,如下所示:

const x = [1,2];
const y = x.toSorted();
Run Code Online (Sandbox Code Playgroud)

我收到此 ts 错误:

类型“number[]”上不存在属性“toSorted”。ts(2339)

toReverse () 和toSplice () 方法也会发生这种情况

sorting typescript

27
推荐指数
3
解决办法
1万
查看次数

标签 统计

sorting ×1

typescript ×1