在我的应用中,我想使用dropzone.js
所以,我按npm install --save-dev dropzone
我在我的polyfills.browser.ts
文件中包含导入此库
/**
* Added parts of es6 which are necessary for your project or your browser support requirements.
*/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'core-js/es6/weak-map';
import 'core-js/es6/weak-set';
import 'core-js/es6/typed';
import 'core-js/es6/reflect';
/**
* See issue https://github.com/AngularClass/angular2-webpack-starter/issues/709
*/
/* import 'core-js/es6/promise'; */
import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
import 'dropzone';
我还安装了'@ types / dropzone'。
但这不能正常地抛出这样的错误。
[at-loader] ./node_modules/@types/jquery/index.d.ts:4482:65
TS2314: Generic type 'Event<TTarget, EventTarget, TData>' requires 3 type argument(s).
[at-loader] ./node_modules/@types/jquery/index.d.ts:4483:20
TS2314: Generic type 'PlainObject<T, any>' requires 2 type argument(s).
[at-loader] ./node_modules/@types/jquery/index.d.ts:4483:49
TS2314: Generic type 'Event<TTarget, EventTarget, TData>' requires 3 type argument(s).
[at-loader] ./node_modules/@types/jquery/index.d.ts:4487:46
TS2531: Object is possibly 'null'.
[at-loader] ./node_modules/@types/jquery/index.d.ts:4487:52
TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures.
[at-loader] ./node_modules/@types/jquery/index.d.ts:4488:10
TS2331: 'this' cannot be referenced in a module or namespace body.
[at-loader] ./node_modules/@types/jquery/index.d.ts:4488:16
TS2304: Cannot find name 'TContext'.
我不知道发生了什么事。 我不知道缺少什么概念?
答案 0 :(得分:0)
打开tsconfig.webpack.json
并添加:
"skipLibCheck": true
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmit": true,
"noEmitHelpers": true,
"importHelpers": true,
"strictNullChecks": false,
"skipLibCheck": true,
"lib": [
"es2015",
"dom"
],
"typeRoots": [
"node_modules/@types"
],
"types": [
"hammerjs",
"node"
]
},
与答案无关。但是,您应该使用--save
而不是--save-dev
来运行应用程序所需的依赖项。另外,我建议使用Angular CLI,这个启动器不像以前那样维护。