编写代码的时候有时候会遇到这种问题:
【ts】对修饰器的实验支持是一项将在将来版本中更改的功能。设置+"experimentalDecorators"+选项以删除此警告
解决方法:
1、打开配置文件tsconfig.js,在compilerOptions选项中配置:
"experimentalDecorators": true,
2、在VS Code中配置:
文件-首选项-设置-打开settings.json
3.在文件夹下建jsconfig.json文件
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "es2017"
},
"exclude": [
"node_modules",
"dist",
],
"include": [
"src",
"env",
"static"
]
}
4.去除eslint,在文件夹下建.eslintignore文件
**/*.js
**/*.ts
原因是因为插件babel-plugin-transform-decorators-legacy 以及.babelrc文件引入了
{
"presets":[
"react-app"
],
"plugins": [
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }],
["transform-decorators-legacy"]
]
}