angular-bazel-example icon indicating copy to clipboard operation
angular-bazel-example copied to clipboard

cannot be named without a reference to '../../external/npm/node_modules/@angular/animations/animations'

Open code2nguyen opened this issue 7 years ago • 3 comments

Hi, I'm testing to convert my project to Bazel, but now I am blocked with this problem when I run bazel build

The problem can be reproducible easily for example...when you modify src/app/app.component.ts like

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

export const showHideAnimations = trigger('showHide', [
  state(
    'show',
    style({
      opacity: 1,
      visibility: 'visible'
    })
  ),
  state(
    'hide',
    style({
      opacity: 0,
      visibility: 'hidden'
    })
  ),
  transition('show => hide', [animate('0.3s')]),
  transition('hide => show', [animate('0.2s')])
]);


@Component({
  selector: 'app-component',
  templateUrl: 'app.component.html',
  animations: [showHideAnimations]
})
export class AppComponent {}

It works well if we don't export showHideAnimations const.

Does someone have any idea or a workaround for this problem?

Thanks

code2nguyen avatar May 20 '19 23:05 code2nguyen

I found a solution for this issue, I must import AnimationTriggerMetadata and assign type of showHideAnimation is AnimationTriggerMetadata.

import {trigger, animate, style, transition, AnimationTriggerMetadata } from '@angular/animations';

export const routeOpenAnimation:AnimationTriggerMetadata = trigger('routeOpenAnimation', [
...

code2nguyen avatar May 23 '19 15:05 code2nguyen

I'm not sure if it is the proper solution. TS should infer the type on its own.

mikolajleszczynski avatar Sep 12 '19 16:09 mikolajleszczynski

I suspect the problem here isn't Bazel specifically, it's that the public API surface of your library has to be exported to .d.ts - I bet you originally didn't have declarations enabled in your tsconfig so it missed that the inferred type couldn't be named. But you didn't say what the error message was so I'm just guessing.

alexeagle avatar Sep 12 '19 19:09 alexeagle