【发布时间】:2017-10-24 01:03:34
【问题描述】:
我正在尝试使用 webpack 2 设置我的项目的脚本。
目前我的文件正在编译,但 jQuery-validation
有问题当我尝试生成我的文件时出现此错误:
./wwwroot/scripts/ts/core.ts (18,20) 中的错误:错误 TS2339:属性 'validator' 在类型 'JQueryStatic' 上不存在。
这是我在 core.ts 中的导入:
import jQuery = require("jquery");
import "jquery-validation"
还有我的 webpack 配置:
'use strict';
var webpack = require('webpack');
var path = require('path');
module.exports = {
cache: true,
entry: {
main: './wwwroot/scripts/ts/public/index.ts'
},
output: {
path: path.resolve(__dirname, './wwwroot/scripts/js'),
filename: '[name].js',
},
plugins: [
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
jquery: 'jquery'
})
],
module: {
loaders: [{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader'
}, {
test: /\.js$/,
exclude: /node_modules/,
}]
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
}
};
我已经在 Google 上找到了很多东西,但任何解决方案都适合我,所以如果有人有想法...
【问题讨论】:
标签: jquery typescript webpack