0
角版本4.3.2發現角4「出口 'AnimationEvent' 不是在 '@角/動畫'
@角/ CLI版本1.2.6
我使用的打字稿(V2.4.2 )對於進口
import {animate, AnimationEvent, state, style, transition, trigger} from '@angular/animations';
我收到說
「出口‘AnimationEvent’未發現在'@角/動畫的警告組件
其他功能(動畫,狀態,樣式等)不觸發警告。我發現,在node_modules/@angular/animations.d.ts的@angular代碼包括
export * from './public_api';
和./public_api.d.ts具有
export * from './src/animations';
和./src/animations.d .TS具有
export { AnimationBuilder, AnimationFactory } from './animation_builder';
export { AnimationEvent } from './animation_event';
export { AUTO_STYLE, AnimateChildOptions, AnimateTimings, AnimationAnimateChildMetadata, AnimationAnimateMetadata, AnimationAnimateRefMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationMetadataType, AnimationOptions, AnimationQueryMetadata, AnimationQueryOptions, AnimationReferenceMetadata, AnimationSequenceMetadata, AnimationStaggerMetadata, AnimationStateMetadata, AnimationStyleMetadata, AnimationTransitionMetadata, AnimationTriggerMetadata, animate, animateChild, animation, group, keyframes, query, sequence, stagger, state, style, transition, trigger, useAnimation, ɵStyleData } from './animation_metadata';
export { AnimationPlayer, NoopAnimationPlayer } from './players/animation_player';
export * from './private_export';
和./animation_event.d.ts具有接口定義
export interface AnimationEvent {
fromState: string;
toState: string;
totalTime: number;
phaseName: string;
element: any;
triggerName: string;
}
如果我將接口定義複製到我的代碼中,一切正常。
所有這些與我用過的許多其他導入非常相似,但是這是唯一一個會產生警告的導入。
如何在不將接口定義複製到我的代碼中的情況下防止這些警告?
我確實導入了BrowserAnimationsModule,並且所有的動畫都按預期工作。事實上,除了編譯器警告之外,一切正在運行並按預期工作。 –
TL; DR通過將tsconfig.js compilerOptions.module從「es2015」更改爲「CommonJS」來修復。假設這必須是編譯器配置,我分析了Plunker中的systemjs.config.js,以與我的(Angular CLI生成的)tsconfig.app.json文件進行比較。只有兩個區別,1)noImplicitAny:true,和2)module:'commonjs'。我改變了兩個,一次一個。TypeScript文檔聲明模塊類型是CommonJS,所以我使用了它。我希望這種改變不會導致其他問題... –
https://www.typescriptlang.org/docs/handbook/compiler-options.html --noImplicitAny在表達式和聲明上引發錯誤,隱含任何'類型。所以這可能沒有必要。但很高興你解決了它。 – JGFMK