公司項目每次新導入從新編譯的時候,fastclick總會報錯,顯示以下:node
Property 'attach' does not exist on type 'typeof fastclick'複製代碼
以前在百度裏面搜索了半天,才找到了解決方案git
修改node——module中@type下fastclick相應文件,詳細可閱讀github github
// Type definitions for FastClick v1.0.3
// Project: https://github.com/ftlabs/fastclick
// Definitions by: Shinnosuke Watanabe <https://github.com/shinnn>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface FastClickObject {
lastTouchIdentifier: number;
layer: Element;
tapDelay: number;
targetElement: any;
touchBoundary: number;
touchStartX: number;
touchStartY: number;
trackingClick: boolean;
trackingClickStart: number;
destroy(): void;
determineEventType(targetElement: any): string;
findControl(labelElement: any /* EventTarget | HTMLLabelElement */): any;
focus(targetElement: any /* EventTarget | Element */): void;
getTargetElementFromEventTarget(eventTarget: EventTarget): any;
needsClick(target: any /* EventTarget | Element */): boolean;
needsFocus(target: any /* EventTarget | Element */): boolean;
}
interface FastClickOptions {
touchBoundary?: number;
tapDelay?: number;
}
interface FastClickStatic {
new(layer: any, options?: FastClickOptions): FastClickObject;
attach(layer: any, options?: FastClickOptions): FastClickObject;
}
declare module "fastclick" {
var FastClick: FastClickStatic;
export = FastClick;
}
declare var FastClick: FastClickStatic;複製代碼