question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variables in animation metadata fails to interpolate using compiler AOT.

See original GitHub issue

I’m submitting a … (check one with “x”)

[ x] bug report => search github for a similar issue or PR before submitting
[ x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Minimal reproduction of the problem with instructions

Something, like:

export CardStates {
static in:string = "in"
static out:string = "out"
}

@Component({
...
animations: [
  trigger('frontState', [
      state(CardStates.in, style({
        transform: 'rotateY(0deg)'
      }))
   ])
]
})

Fails with the following error:

TypeError: stateMetadata.stateNameExpr.split is not a function
    at _parseAnimationDeclarationStates (/home/jordi/Documents/lupa/node_modules/@angular/compiler/bundles/compiler.umd.js:9688:48)
    at /home/jordi/Documents/lupa/node_modules/@angular/compiler/bundles/compiler.umd.js:9640:15

Expected behavior

I’m not sure if it is a expected behaviour but in this case, I think it should fail, with a more descriptive message… For debugging the error, i have had to start tracing at compiler.umd.js. (It’s still not clear for me where is the line on what can I use when I try to compile with AOT) Also, I can’t understand why I can’t use functions on metadata… (Perhaps is related to this, but it’s not clear for me)

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

ng-cli

  • Angular version: 2.0.X

angular 2.0.1

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

  • Language: TypeScript 2.0.2

  • Node (for AoT issues): node --version = 6.7.0

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
benelliottcommented, Oct 14, 2016

@matsko More generally, is there any way to build a set of reusable animations that will still compile through AOT?

With JIT I was simply exporting a bunch of AnimationEntryMetadata objects and referencing them through my component decorator, e.g. animations: [Animations.EXPAND_WIDTH].

This doesn’t work in AOT, as animations’ state metadata are not generated correctly. I don’t want to re-declare the animation in every component decorator as they’re about 6 lines each and always the same.

1reaction
jordiccommented, Oct 10, 2016

@zoechi Can you point me on a plunker example that uses the aot? And I will write one.

It’s not a function, it’s a variable. Also, in this case, I think the compiler should complain… All I’ve got is a split error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AOT metadata errors - Angular
Adding export often works for variables referenced in metadata such as providers and animations because the compiler can generate references to the exported ......
Read more >
Ahead-of-time (AOT) Compilation - Angular 10 - W3cubDocs
This guide explains how to specify metadata and apply available compiler options to compile your applications efficiently using the AOT compiler.
Read more >
The Ahead-of-Time (AOT) compiler - Angular
This guide explains how to specify metadata and apply available compiler options to compile your applications efficiently using the AOT compiler.
Read more >
Scripting restrictions - Unity - Manual
Unity provides a common scripting API and experience across all platforms it supports. However, some platforms have inherent restrictions.
Read more >
Error encountered in metadata generated for exported symbol ...
Angular does not allow a static variable to not be initialized. The solution was to initialize with null to avoid errors.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found