gpt4 book ai didi

typescript - 类型 'values' 上不存在属性 'ObjectConstructor'

转载 作者:搜寻专家 更新时间:2023-10-30 21:02:23 29 4
gpt4 key购买 nike

在下文中,我将枚举转换为数组,看来我的 tsconfig.json 中可能缺少某些内容。

这是脚本:

const menuItems = Object.values(MediaListFilterType).map(value => ({
type: value,
description: () => {
switch (value) {
case value === MediaListFilterType.notPitched:
return 'Exclude already pitched';
break;
case value === MediaListFilterType.notDoublePitched:
return 'Exclude double pitched';
break;
case value === MediaListFilterType.assignedToMe:
return 'Assigned to me';
break;
case value === MediaListFilterType.notAssigned:
return 'Unassigned';
break;
}
}
}));

这给了我这个错误:“ObjectConstructor”类型上不存在属性“values”。

tsconfig如下...

{
"compilerOptions": {
"module": "es6",
"target": "es2015",
"sourceMap": true,
"jsx": "react",
"moduleResolution": "node",
"declaration": false,
"allowSyntheticDefaultImports": true
}
}

我对此有点陌生,所以我不确定我需要在 tsconfig.xml 中更改什么。帮助!

最佳答案

es2017.object 添加到 tsconfig.json 中的 compilerOptions.lib 数组。

关于typescript - 类型 'values' 上不存在属性 'ObjectConstructor',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52304422/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com