我正在尝试按照文档连接到我的 Firebase 应用程序,但 ESLint 正在抱怨。我已经检查过相关问题,但那里提出的解决方案似乎对我不起作用。我有以下 .eslint.js 文件:
module.exports = {
extends: [
'airbnb-typescript/base',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:typescript-sort-keys/recommended',
'plugin:import/recommended',
'prettier'
],
parser : '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
modules: true
},
ecmaVersion: 6,
project : './tsconfig.json',
sourceType : 'module'
},
plugins: ['@typescript-eslint', 'typescript-sort-keys', 'sort-keys-fix'],
rules : { ... }
}
Run Code Online (Sandbox Code Playgroud) 我曾经使用以下代码定义全局变量:
interface CustomNodeJSGlobal extends NodeJS.Global {
myGlobalVariable: unknown
}
export { CustomNodeJSGlobal }
Run Code Online (Sandbox Code Playgroud)
在 Node 14 中,但是当我安装时@types/node(目前是版本 16),它会抛出一个错误Namespace 'NodeJS' has no exported member 'Global'。如何在 Node 16 及以上版本中声明全局变量?