Angular version 4.3.2
@ angular / cli version 1.2.6
我正在将TypeScript(v2.4.2)用于导入
的组件import {animate, AnimationEvent, state, style, transition, trigger} from '@angular/animations';
我收到的警告说
在'@ 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;
}
如果我将界面定义复制到我的代码中,一切正常。
所有这些与我使用过的许多其他导入非常相似,但这是唯一产生警告的导入。
如果不将接口定义复制到我的代码中,如何防止出现这些警告?
答案 0 :(得分:2)
app-module.ts :您导入了BrowserAnimationsModule吗?
请参阅文档中的here。
与羽毛example一起。
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@NgModule({
imports: [ BrowserModule, BrowserAnimationsModule ],
})
如果这还没有解决它:
请务必注明哪些步骤已修复。 ; - )