Failed to compile.
/app/node_modules/@ant-design/icons/lib/components/AntdIcon.d.ts
TypeScript error in /app/node_modules/@ant-design/icons/lib/components/AntdIcon.d.ts(2,13):
'=' expected. TS1005
1 | import * as React from 'react';
> 2 | import type { IconDefinition } from '@ant-design/icons-svg/lib/types';
| ^
3 | import type { IconBaseProps } from './Icon';
4 | import { getTwoToneColor, TwoToneColor, setTwoToneColor } from './twoTonePrimaryColor';
5 | export interface AntdIconProps extends IconBaseProps {
我的package.json
{
"name": "web",
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/react-native-fetch-blob": "^0.10.5",
"@types/react-select": "^3.0.16",
"@types/rn-fetch-blob": "^1.2.1",
"antd": "^4.2.4",
"common-tags": "^1.8.0",
"lodash": "^4.17.19",
"moment": "^2.26.0",
"node-sass": "^4.13.1",
"normalize.css": "^8.0.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"rn-fetch-blob": "^0.12.0",
"socket.io-client": "^2.3.0",
"typescript": "~3.7.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 9000 -c .storybook"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@storybook/addon-actions": "^5.3.18",
"@storybook/addon-info": "^5.3.18",
"@storybook/addon-knobs": "^5.3.18",
"@storybook/addon-notes": "^5.3.18",
"@storybook/addons": "^5.3.18",
"@storybook/preset-create-react-app": "^2.1.2",
"@storybook/react": "^5.3.18",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/common-tags": "^1.8.0",
"@types/jest": "^24.0.0",
"@types/lodash": "^4.14.150",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"@types/react-redux": "^7.1.7",
"@types/react-router-dom": "^5.1.4",
"@types/redux": "^3.6.0",
"@types/socket.io-client": "^1.4.32",
"babel-loader": "8.1.0",
"react-docgen-typescript-loader": "^3.7.2"
}
}
我的Dockerfile
FROM node:12 as builder
WORKDIR /app
COPY package.json .
RUN npm install
COPY . ./
RUN npm run build
FROM nginx:stable
COPY --from=builder /app/build /usr/share/nginx/html
谷歌搜索了这个问题之后才知道https://github.com/ant-design/ant-design/issues/23266#issuecomment-613773502 you need update @types/react
。我尝试了"@types/react" : "17.0.1"
。但是没有帮助。
Antdv4.2.4
使用TypeScript v3.9.2
。
import type
从TypeScript开始,支持编译器抱怨的功能v3.8
。
大多数用户可能不必考虑此功能。但是,如果您遇到--isolatedModules,TypeScript的transpileModule API或Babel下的问题,则此功能可能是相关的。
import type { SomeThing } from "./some-module.js"; export type { SomeThing };
来源:https : //www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html
将本地TypeScript版本从更新v3.7.2
为atleast v3.8
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句