Cannot export "non-angular" classes with non-initialized static attributes
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
When trying to export (amongs other things) a “non-angular” class with an uninitiailized static attribute, the packaging of the library fails with the error:
Error: C:/dev/ng-packagr-not-ng/src/app/core/my-class.ts:1:1: Error encountered in metadata generated for exported symbol 'MyClass':
C:/dev/ng-packagr-not-ng/src/app/core/my-class.ts:2:18: Metadata collected contains an error that will be reported at runtime: Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler.
Maybe we could add something to the config to prevent metadata generation for specified files ?
How To Reproduce
Clone this repository, do yarn install
(npm install
should do the trick too), then run npm run build:lib
. The problematic file is src/app/core/my-class.ts
Expected Behaviour
The library is build without error
Version Information
ng-packagr: 2.4.1
@angular/compiler: 5.2.9
@angular/compiler-cli: 5.2.9
rollup: 0.55.5
tsickle: 0.27.2
typescript: 2.5.3
node: 8.9.0
yarn: 1.2.1
Kind regards,
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Can't access class attribute within html and angular
You will have to define a variable in you app.component.ts from type "User" and than you can access the variable: Here an example:...
Read more >C++ Tutorial: Static Variables and Static Class Members - 2020
It cannot be accessed outside of the function/block. Class: static members exist as members of the class rather than as an instance in...
Read more >Static initialization blocks - JavaScript - MDN Web Docs
Static initialization blocks are a special feature of a class that enable more flexible initialization of static properties than can be achieved using ......
Read more >Typed properties in PHP 7.4 - Stitcher.io
Typed class properties have been added in PHP 7.4 and provide a major ... You cannot read from uninitialized properties, doing so will ......
Read more >How to export class with static methods in Node.js
We know JS static keyword defines static properties and methods for a class. Static method or properties can not be called from instances...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
if you use static in your class , you need // @dynamic.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem. This action has been performed automatically by a bot.