[英]jQuery.validator webpack 2 and typescript
I'm trying to set up the scripts of my project with webpack 2. 我正在尝试使用webpack 2设置项目脚本。
Currently my files are compiling but I have an issue with jQuery-validation 目前,我的文件正在编译,但是jQuery验证存在问题
I have this error when I try to generate my file : 尝试生成文件时出现此错误:
ERROR in ./wwwroot/scripts/ts/core.ts (18,20): error TS2339: Property 'validator' does not exist on type 'JQueryStatic'.
./wwwroot/scripts/ts/core.ts(18,20)中的错误:错误TS2339:类型'JQueryStatic'上不存在属性'validator'。
Here is my import in core.ts : 这是我在core.ts中的导入:
import jQuery = require("jquery");
import "jquery-validation"
And my webpack config : 而我的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']
}
};
I already found a lot of thing with Google, but any solution works for me, so if anyone have an idea... 我已经在Google上找到了很多东西,但是任何解决方案都对我有用,因此,如果有人有想法...
您必须安装jquery-validation
:
npm install --save-dev @types/jquery.validation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.