根据ts官网的教程,配置了一个react-ts-es6的技术栈
但是遇到了一个问题:在ide中会出现一些不明所以的报错,但是并不影响webpack编译,也可以正常运行,所以非常疑惑,希望大佬们可以解惑一下
代码如下
此处的compiler和framework已经通过interface和范型进行约束了,为什么IDE无法检测到其关联关系
webpack和tsconfig如下
webpack.config
let path = require('path');
let webpack = require('webpack');
let HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: __dirname + '/src/index.tsx',
output: {
filename: 'bundle.js',
path: __dirname + '/dist'
},
devtool: 'eval-source-map',
resolve: {
extensions: [
'.js', '.json', '.webpack.js', '.tsx', '.jsx'
]
},
module: {
rules: [
{test: /\.tsx$/, use: ['awesome-typescript-loader']},
{test: /\.css$/, use: ['style-loader', 'css-loader', 'postcss-loader']},
{test: /\.sass$/, use: ['style-loader', 'css-loader', 'sass-loader']},
{
enforce: "pre", test: /\.js$/, loader: "source-map-loader"
}
]
},
externals: {
"react": "React",
"react-dom": "ReactDOM"
},
plugins: [
require('autoprefixer'),
new HtmlWebpackPlugin({
template: path.resolve(__dirname + '/src', 'index.html')
}),
new webpack.HotModuleReplacementPlugin()
],
devServer: {
contentBase: './src/',
historyApiFallback: true,
inline: true,
hot: true
}
};
tsconfig
{
"compilerOptions": {
"target": "es2015",
"sourceMap": true,
"noImplicitAny": true,
"jsx": "react"
},
"exclude": [
"node_modules"
]
}
this.props
在定义的时候有赋类型HelloProps
吗?