就像上面说的一样简单:React 16.9.22 和 TypeScript 3.8.2。它不会影响任何事情,只是挤满了我的警告窗口表单实际上有用的东西。
在我的 tsconfig 我有:
{
"compilerOptions": {
"esModuleInterop": true
}
}
但是每个文件都有一行
import React from 'react';
我收到掉毛错误:
.../node_modules/@types/react/index"' can only be default-imported using the 'esModuleInterop' flag
可能相关的部门:
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.22.0",
"@typescript-eslint/parser": "^2.22.0",
"cross-env": "^5.2.0",
"eslint": "^6.6.0",
"eslint-config-react-app": "^4.0.1",
"eslint-plugin-flowtype": "^2.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.18.3",
"typescript": "^3.8.2"
},
最佳答案
如上所述,我现在使用它,有没有人知道如何将它作为单线?
import * as React from 'react'
import {
useState, useEffect
} from 'react';
这不起作用:import * as React, {
// useEffect,
useState, useEffect
} from 'react';
关于reactjs - 如何摆脱我的 "@types/react/index"只能在 React/TypeScript 中使用 'esModuleInterp' 标志 Lint 默认导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60551025/