Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 --aot causes AnimationEntryMetadata failure

My code works fine with ng build and ng build --prod howerver, when I add --aot to the command, it fails with the following error:

Uncaught Error: Module build failed: Error: C:/Users/dremache/Code/control-f2/client/src/app/transitions.ts (11,14): Exported variable 'pageTransitions' has or is using name 'AnimationEntryMetadata' from external module "C:/Users/dremache/Code/control-f2/client/node_modules/@angular/core/src/animation/metadata" but cannot be named.)

This is transitions.ts:

import { trigger,
  state,
  style,
  transition,
  animate,
  keyframes } from '@angular/core';


export const pageTransitions = 

  trigger('slideInOut', [

    state('in', style({transform: 'translateX(0)'})),

    transition('void => *', [
      style({transform: 'translateX(-60px)',opacity: '0'}),
      animate('300ms ease-out')
    ]),
    transition('* => void', [
      animate('300ms ease-out', style({transform: 'translateX(-60px)'}))
    ])
  ]);

This is the component that's importing it:

//other imports
import { pageTransitions } from './transitions';

@Component({
  //other properties
  animations: [ pageTransitions, 

      trigger('items', [
         // states and transitions here.. removing for cleanliness
      ]
  })

Any ideas? I'm doing this to avoid re-defining the same animations. These animations are being applied on components that are going from void => * to create page transition animations.

like image 861
Gary Simon Avatar asked Mar 11 '23 15:03

Gary Simon


1 Answers

Fixed it!

In my transitions.ts file I needed to change:

export const pageTransitions = 

to:

export const pageTransitions: AnimationEntryMetadata = 

(as well import AnimationEntryMetadata from @angular/core)

like image 108
Gary Simon Avatar answered Mar 23 '23 18:03

Gary Simon