类型应该检测数组是否有重复的项目并在打字稿中引发错误?
type UniqueArray = [
// How to implement this?
]
const a:UniqueArray = [1, 2, 3] // success
const b:UniqueArray = [1, 2, 2] // error
Run Code Online (Sandbox Code Playgroud)
PS:我目前正在使用JS删除重复项,但是,好奇是否可以使用手写脚本类型捕获此错误?