cannot be named without a reference to '../../external/npm/node_modules/@angular/animations/animations'
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
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', [
...
I'm not sure if it is the proper solution. TS should infer the type on its own.
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.