簡體   English   中英

ESLint 沒有 Object.values 在 TypeScript 項目中的受限全局變量

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

我收到一個no restricted globals的 ESLint 錯誤:

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

我嘗試將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)
  },

嘗試在 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