突然获得"重复标识符" My Angular2 App中的错误

时间:2016-12-06 22:09:34

标签: javascript angular typescript hammer.js

我一直在研究Angular 2应用程序,并取得了稳步进展。然后,突然间,今天中午我尝试启动应用程序时遇到错误。我还没有处理与我遇到的错误有关的任何事情,所以我不确定为什么我现在收到这些错误。错误与我的node_modules文件夹中的hammerjs有关。以下是一些错误:

typings/globals/hammerjs/index.d.ts(90,11): error TS2430: Interface 'HammerOptions' incorrectly extends interface 'HammerDefaults'.
  Property 'domEvents' is optional in type 'HammerOptions' but required in type 'HammerDefaults'.
typings/globals/hammerjs/index.d.ts(116,15): error TS2300: Duplicate identifier 'HammerInput'.
typings/globals/hammerjs/index.d.ts(194,15): error TS2300: Duplicate identifier 'MouseInput'.
typings/globals/hammerjs/index.d.ts(199,15): error TS2300: Duplicate identifier 'PointerEventInput'.
typings/globals/hammerjs/index.d.ts(204,15): error TS2300: Duplicate identifier 'SingleTouchInput'.
typings/globals/hammerjs/index.d.ts(209,15): error TS2300: Duplicate identifier 'TouchInput'.
typings/globals/hammerjs/index.d.ts(214,15): error TS2300: Duplicate identifier 'TouchMouseInput'.
typings/globals/hammerjs/index.d.ts(313,15): error TS2300: Duplicate identifier 'TouchAction'.

这很奇怪,因为当我打开这些文件时,我没有明显看到任何这些标识符被复制,所以我不确定为什么我会收到这些特定错误?< / p>

这是我的npm-debug日志:

 0 info it worked if it ends with ok
    1 verbose cli [ '/usr/local/Cellar/node/6.8.0/bin/node',
    1 verbose cli   '/usr/local/bin/npm',
    1 verbose cli   'start' ]
    2 info using npm@3.10.8
    3 info using node@v6.8.0
    4 verbose run-script [ 'prestart', 'start', 'poststart' ]
    5 info lifecycle abc@0.0.1~prestart: abc@0.0.1
    6 silly lifecycle abc@0.0.1~prestart: no script for prestart, continuing
    7 info lifecycle abc@0.0.1~start: abc@0.0.1
    8 verbose lifecycle abc@0.0.1~start: unsafe-perm in lifecycle true
    9 verbose lifecycle abc@0.0.1~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ef/Documents/quin-backup/abc/node_modules/.bin:/usr/local/Cellar/node/6.8.0/bin:/Users/ef/.rvm/gems/ruby-2.2.4/bin:/Users/ef/.rvm/gems/ruby-2.2.4@global/bin:/Users/ef/.rvm/rubies/ruby-2.2.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ef/.rvm/bin:/Users/ef/.rvm/bin
    10 verbose lifecycle ARK@0.0.1~start: CWD: /Users/ef/Documents/quin-backup/abc
    11 silly lifecycle abc@0.0.1~start: Args: [ '-c', 'tsc && concurrently "npm run tsc:w" "npm run lite" ' ]
    12 silly lifecycle abc@0.0.1~start: Returned: code: 2  signal: null
    13 info lifecycle abc@0.0.1~start: Failed to exec start script
    14 verbose stack Error: abc@0.0.1 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
    14 verbose stack Exit status 2
    14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
    14 verbose stack     at emitTwo (events.js:106:13)
    14 verbose stack     at EventEmitter.emit (events.js:191:7)
    14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
    14 verbose stack     at emitTwo (events.js:106:13)
    14 verbose stack     at ChildProcess.emit (events.js:191:7)
    14 verbose stack     at maybeClose (internal/child_process.js:877:16)
    14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
    15 verbose pkgid ARK@0.0.1
    16 verbose cwd /Users/ef/Documents/backup/abc
    17 error Darwin 15.6.0
    18 error argv "/usr/local/Cellar/node/6.8.0/bin/node" "/usr/local/bin/npm" "start"
    19 error node v6.8.0
    20 error npm  v3.10.8
    21 error code ELIFECYCLE
    22 error ARK@0.0.1 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
    22 error Exit status 2
    23 error Failed at the abc@0.0.1 start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '.
    23 error Make sure you have the latest version of node.js and npm installed.
    23 error If you do, this is most likely a problem with the abc package,
    23 error not with npm itself.
    23 error Tell the author that this fails on your system:
    23 error     tsc && concurrently "npm run tsc:w" "npm run lite"
    23 error You can get information on how to open an issue for this project with:
    23 error     npm bugs abc
    23 error Or if that isn't available, you can get their info via:
    23 error     npm owner ls abc
    23 error There is likely additional logging output above.
    24 verbose exit [ 1, true ]

我还尝试删除我的node_modules文件夹并再次运行npm install,但我遇到了同样的问题。

而且,这是一个刚刚出现的问题。之前没有问题。

这是我的package.json文件:

{
  "name": "abc",
  "version": "0.0.1",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings",
    "docs": "typedoc --experimentalDecorators --out docs/ app/ --target 'es5' -module 'system' --ignoreCompilerErrors",
    "clean": "del /q dist",
    "browserify": "^13.0.1",
    "uglifyjs": "^2.4.10",
    "minify": "uglifyjs dist/main.min.js --screw-ie8 --compress --mangle --output dist/main.min.js",
    "build": "npm run clean && tsc",
    "build_prod": "npm run build && browserify -s main dist/main.js > dist/main.min.js && npm run minify"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "^2.0.0",
    "@angular/compiler": "^2.0.0",
    "@angular/core": "^2.0.0",
    "@angular/forms": "^2.0.0",
    "@angular/http": "^2.0.0",
    "@angular/material": "^2.0.0-alpha.10",
    "@angular/platform-browser": "^2.0.0",
    "@angular/platform-browser-dynamic": "^2.0.0",
    "@angular/router": "^3.0.0",
    "@angular2-material/button": "^2.0.0-alpha.8-2",
    "@angular2-material/core": "^2.0.0-alpha.8-2",
    "@angular2-material/input": "^2.0.0-alpha.8-2",
    "angular-in-memory-web-api": "~0.1.15",
    "bootstrap": "^3.3.6",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.12",
    "socket.io-client": "^1.4.8",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@types/hammerjs": "^2.0.32",
    "browserify": "^13.0.1",
    "concurrently": "^2.2.0",
    "jasmine-core": "^2.5.2",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-jasmine": "^1.0.2",
    "lite-server": "^2.2.2",
    "typescript": "^2.0.2",
    "typings": "^1.3.2",
    "uglifyjs": "^2.4.10"
  }
}

错误追溯到此文件(我无法识别任何问题):

// Type definitions for Hammer.js 2.0.8
// Project: http://hammerjs.github.io/
// Definitions by: Philip Bulley <https://github.com/milkisevil/>, Han Lin Yap <https://github.com/codler>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare var Hammer:HammerStatic;

declare module "hammerjs" {
    export = Hammer;
}

interface HammerStatic
{
  new( element:HTMLElement | SVGElement, options?:HammerOptions ): HammerManager;

  defaults:HammerDefaults;

  VERSION: number;

  INPUT_START:  number;
  INPUT_MOVE:   number;
  INPUT_END:    number;
  INPUT_CANCEL: number;

  STATE_POSSIBLE:   number;
  STATE_BEGAN:      number;
  STATE_CHANGED:    number;
  STATE_ENDED:      number;
  STATE_RECOGNIZED: number;
  STATE_CANCELLED:  number;
  STATE_FAILED:     number;

  DIRECTION_NONE:       number;
  DIRECTION_LEFT:       number;
  DIRECTION_RIGHT:      number;
  DIRECTION_UP:         number;
  DIRECTION_DOWN:       number;
  DIRECTION_HORIZONTAL: number;
  DIRECTION_VERTICAL:   number;
  DIRECTION_ALL:        number;

  Manager:     HammerManagerConstructor;
  Input:       HammerInput;
  TouchAction: TouchAction;

  TouchInput:        TouchInput;
  MouseInput:        MouseInput;
  PointerEventInput: PointerEventInput;
  TouchMouseInput:   TouchMouseInput;
  SingleTouchInput:  SingleTouchInput;

  Recognizer:     RecognizerStatic;
  AttrRecognizer: AttrRecognizerStatic;
  Tap:            TapRecognizerStatic;
  Pan:            PanRecognizerStatic;
  Swipe:          SwipeRecognizerStatic;
  Pinch:          PinchRecognizerStatic;
  Rotate:         RotateRecognizerStatic;
  Press:          PressRecognizerStatic;

  on( target:EventTarget, types:string, handler:Function ):void;
  off( target:EventTarget, types:string, handler:Function ):void;
  each( obj:any, iterator:Function, context:any ):     void;
  merge( dest:any, src:any ):    any;
  extend( dest:any, src:any, merge:boolean ):   any;
  inherit( child:Function, base:Function, properties:any ):any;
  bindFn( fn:Function, context:any ):Function;
  prefixed( obj:any, property:string ):string;
}

type RecognizerTuple =
  [RecognizerStatic]
  | [RecognizerStatic, RecognizerOptions]
  | [RecognizerStatic, RecognizerOptions, string | string[]]
  | [RecognizerStatic, RecognizerOptions, string | string[], (string | Recognizer) | (string | Recognizer)[]];

interface HammerDefaults extends HammerOptions
{
  domEvents:boolean;
  enable:boolean;
  preset:RecognizerTuple[];
  touchAction:string;
  cssProps:CssProps;

  inputClass:() => void;
  inputTarget:EventTarget;
}

interface CssProps
{
  contentZooming:string;
  tapHighlightColor:string;
  touchCallout:string;
  touchSelect:string;
  userDrag:string;
  userSelect:string;
}

interface HammerOptions
{
  cssProps?:CssProps;
  domEvents?:boolean;
  enable?:boolean | ((manager: HammerManager) => boolean);
  preset?:RecognizerTuple[];
  touchAction?:string;
  recognizers?:RecognizerTuple[];

  inputClass?:() => void;
  inputTarget?:EventTarget;
}

interface HammerManagerConstructor {
  new( element:EventTarget, options?:HammerOptions ):HammerManager;
}

interface HammerListener {
  (event:HammerInput): void
}

interface HammerManager
{
  add( recogniser:Recognizer ):Recognizer;
  add( recogniser:Recognizer ):HammerManager;
  add( recogniser:Recognizer[] ):Recognizer;
  add( recogniser:Recognizer[] ):HammerManager;
  destroy():void;
  emit( event:string, data:any ):void;
  get( recogniser:Recognizer ):Recognizer;
  get( recogniser:string ):Recognizer;
  off( events:string, handler?:HammerListener ):void;
  on( events:string, handler:HammerListener ):void;
  recognize( inputData:any ):void;
  remove( recogniser:Recognizer ):HammerManager;
  remove( recogniser:string ):HammerManager;
  set( options:HammerOptions ):HammerManager;
  stop( force:boolean ):void;
}

declare class HammerInput
{
  constructor( manager:HammerManager, callback:Function );

  destroy():void;
  handler():void;
  init():void;

  /** Name of the event. Like panstart. */
  type:string;

  /** Movement of the X axis. */
  deltaX:number;

  /** Movement of the Y axis. */
  deltaY:number;

  /** Total time in ms since the first input. */
  deltaTime:number;

  /** Distance moved. */
  distance:number;

  /** Angle moved. */
  angle:number;

  /** Velocity on the X axis, in px/ms. */
  velocityX:number;

  /** Velocity on the Y axis, in px/ms */
  velocityY:number;

  /** Highest velocityX/Y value. */
  velocity:number;

  /** Direction moved. Matches the DIRECTION constants. */
  direction:number;

  /** Direction moved from it's starting point. Matches the DIRECTION constants. */
  offsetDirection:number;

  /** Scaling that has been done when multi-touch. 1 on a single touch. */
  scale:number;

  /** Rotation that has been done when multi-touch. 0 on a single touch. */
  rotation:number;

  /** Center position for multi-touch, or just the single pointer. */
  center:HammerPoint;

  /** Source event object, type TouchEvent, MouseEvent or PointerEvent. */
  srcEvent:TouchEvent | MouseEvent | PointerEvent;

  /** Target that received the event. */
  target:HTMLElement;

  /** Primary pointer type, could be touch, mouse, pen or kinect. */
  pointerType:string;

  /** Event type, matches the INPUT constants. */
  eventType:number;

  /** true when the first input. */
  isFirst:boolean;

  /** true when the final (last) input. */
  isFinal:boolean;

  /** Array with all pointers, including the ended pointers (touchend, mouseup). */
  pointers:any[];

  /** Array with all new/moved/lost pointers. */
  changedPointers:any[];

  /** Reference to the srcEvent.preventDefault() method. Only for experts! */
  preventDefault:Function;
}

declare class MouseInput extends HammerInput
{
  constructor( manager:HammerManager, callback:Function );
}

declare class PointerEventInput extends HammerInput
{
  constructor( manager:HammerManager, callback:Function );
}

declare class SingleTouchInput extends HammerInput
{
  constructor( manager:HammerManager, callback:Function );
}

declare class TouchInput extends HammerInput
{
  constructor( manager:HammerManager, callback:Function );
}

declare class TouchMouseInput extends HammerInput
{
  constructor( manager:HammerManager, callback:Function );
}

interface RecognizerOptions {
  direction?: number;
  enable?: boolean | ((recognizer: Recognizer, inputData: HammerInput) => boolean);
  event?: string;
  interval?: number;
  pointers?: number;
  posThreshold?: number;
  taps?: number
  threshold?: number;
  time?: number;
  velocity?: number;
}

interface RecognizerStatic
{
  new( options?:RecognizerOptions ):Recognizer;
}

interface Recognizer
{
  defaults:any;

  canEmit():boolean;
  canRecognizeWith( otherRecognizer:Recognizer ):boolean;
  dropRecognizeWith( otherRecognizer:Recognizer ):Recognizer;
  dropRecognizeWith( otherRecognizer:string ):Recognizer;
  dropRequireFailure( otherRecognizer:Recognizer ):Recognizer;
  dropRequireFailure( otherRecognizer:string ):Recognizer;
  emit( input:HammerInput ):void;
  getTouchAction():any[];
  hasRequireFailures():boolean;
  process( inputData:HammerInput ):string;
  recognize( inputData:HammerInput ):void;
  recognizeWith( otherRecognizer:Recognizer ):Recognizer;
  recognizeWith( otherRecognizer:string ):Recognizer;
  requireFailure( otherRecognizer:Recognizer ):Recognizer;
  requireFailure( otherRecognizer:string ):Recognizer;
  reset():void;
  set( options?:RecognizerOptions ):Recognizer;
  tryEmit( input:HammerInput ):void;
}

interface AttrRecognizerStatic
{
  attrTest( input:HammerInput ):boolean;
  process( input:HammerInput ):any;
}

interface AttrRecognizer extends Recognizer
{
  new( options?:RecognizerOptions ):AttrRecognizer;
}

interface PanRecognizerStatic
{
  new( options?:RecognizerOptions ):PanRecognizer;
}

interface PanRecognizer extends AttrRecognizer
{
}

interface PinchRecognizerStatic
{
  new( options?:RecognizerOptions ):PinchRecognizer;
}

interface PinchRecognizer extends AttrRecognizer
{
}

interface PressRecognizerStatic
{
  new( options?:RecognizerOptions ):PressRecognizer;
}

interface PressRecognizer extends AttrRecognizer
{
}

interface RotateRecognizerStatic
{
  new( options?:RecognizerOptions ):RotateRecognizer;
}

interface RotateRecognizer extends AttrRecognizer
{
}

interface SwipeRecognizerStatic
{
  new( options?:RecognizerOptions ):SwipeRecognizer;
}

interface SwipeRecognizer extends AttrRecognizer
{
}

interface TapRecognizerStatic
{
  new( options?:RecognizerOptions ):TapRecognizer;
}

interface TapRecognizer extends AttrRecognizer
{
}

declare class TouchAction
{
  constructor( manager:HammerManager, value:string );

  compute():string;
  preventDefaults( input:HammerInput ):void;
  preventSrc( srcEvent:any ):void;
  set( value:string ):void;
  update():void;
}

interface HammerPoint
{
  x: number;
  y: number;
}

0 个答案:

没有答案