简体   繁体   English

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

[英]ESLint no restricted globals with Object.values in TypeScript project

I am getting an ESLint error for no restricted globals :我收到一个no restricted globals的 ESLint 错误:

const objectParamsAllNumbers = (obj: Object) =>
  !Object.values(obj).find(elem => {
    return isNaN(elem);
  });

I tried adding ES2017.Object to my tsconfig but the error is still throwing:我尝试将ES2017.Object添加到我的tsconfig但仍然抛出错误:

{
  "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)
  },

Try accessing it on the window object like window.Object .尝试在 window object 上访问它,例如window.Object

const objectParamsAllNumbers = (obj: Object) =>
  !window.Object.values(obj).find(elem => {
    return window.isNaN(elem);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM