首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在TypeScript项目中使用Object.values时ESLint没有受限的全局变量

在TypeScript项目中使用Object.values时ESLint没有受限的全局变量
EN

Stack Overflow用户
提问于 2020-06-20 00:05:02
回答 1查看 91关注 0票数 0

我收到no restricted globals的ESLint错误

代码语言:javascript
复制
const objectParamsAllNumbers = (obj: Object) =>
  !Object.values(obj).find(elem => {
    return isNaN(elem);
  });

我尝试将ES2017.Object添加到我的tsconfig中,但错误仍然抛出:

代码语言:javascript
复制
{
  "compilerOptions": {
    "isolatedModules": true,  // Warn you if you write certain code that can’t be correctly interpreted by a single-file transpilation process.
    "outDir": "./dist/",
    "module": "commonjs",
    "target": "ES5",
    "jsx": "react",
    "lib": ["ESNEXT", "DOM", "DOM.Iterable", "ES5", "ES2017", "ES2017.Object"],
    "allowJs": true, // Allow JavaScript files to be imported inside your project, instead of just .ts and .tsx
    "checkJs": true,  // When checkJs is enabled then errors are reported in JavaScript files. This is the equivalent of including // @ts-check at the top of all JavaScript files which are included in your project.
    "allowSyntheticDefaultImports": true, // Allow default imports from modules with no default export
    "skipLibCheck": true,
    "types": ["node", "webpack-env", "@wdio/sync", "mocha", "expect-webdriverio"],
    "strict": false // Enables all strict type checking options (This is too restrictive for the current code base)
  },
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-20 00:13:12

尝试在window对象上访问它,比如window.Object

代码语言:javascript
复制
const objectParamsAllNumbers = (obj: Object) =>
  !window.Object.values(obj).find(elem => {
    return window.isNaN(elem);
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62474258

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档