ESLint без ограничений глобалов с Object.values ​​в проекте TypeScript - PullRequest
0 голосов
/ 19 июня 2020

Я получаю сообщение об ошибке ESLint для no restricted globals:

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

1 Ответ

1 голос
/ 19 июня 2020

Попробуйте получить к нему доступ в объекте окна, например window.Object.

const objectParamsAllNumbers = (obj: Object) =>
  !window.Object.values(obj).find(elem => {
    return window.isNaN(elem);
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...