You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Angular's fullTemplateTypeCheck wants the passed type of LegendPosition to be a value from the enum. Passing in the string that represents that value causes the compiler to reject the string. You have the
To Reproduce
Manually set the LegendPosition to a string, such as right or below and compile with fullTemplateTypeCheck. You'll get an error like
Building Angular Package
------------------------------------------------------------------------------
Building entry point 'livelab'
------------------------------------------------------------------------------
✖ Compiling with Angular sources in Ivy partial compilation mode.
projects/livelab/src/lib/student-details/livelab-student-details.component.html:127:49 - error TS2322: Type '"below"' is not assignable to type 'LegendPosition'.
127 [legend]="true" [legendTitle]="''" [legendPosition]="'below'" [yScaleMax]="yScaleMax" [yScaleMin]="0"
~~~~~~~~~~~~~~
projects/livelab/src/lib/student-details/livelab-student-details.component.ts:33:16
33 templateUrl: "./livelab-student-details.component.html",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component LivelabStudentDetailsComponent.
Expected behavior
Unfortunately, this is the expected behavior because enums are bad. You want, per your documentation, that value to be a string, but it's not. The source code should be:
exporttypeLegendPosition='right'|'below';
ngx-charts version
Present on any version that uses LegendPosition enum. Experienced on 20.5.0.
Additional context
You can work around this issue using Angular's $any(), but then why enable strict type checking?
Ideally, you'd similarly convert any other enums to a union of string literals, which is almost always better anyway. I, however, only attempted to use this enum.
The text was updated successfully, but these errors were encountered:
Describe the bug
Angular's
fullTemplateTypeCheck
wants the passed type ofLegendPosition
to be a value from the enum. Passing in the string that represents that value causes the compiler to reject the string. You have theTo Reproduce
Manually set the
LegendPosition
to a string, such asright
orbelow
and compile withfullTemplateTypeCheck
. You'll get an error likeExpected behavior
Unfortunately, this is the expected behavior because enums are bad. You want, per your documentation, that value to be a string, but it's not. The source code should be:
ngx-charts version
Present on any version that uses
LegendPosition
enum. Experienced on 20.5.0.Additional context
You can work around this issue using Angular's
$any()
, but then why enable strict type checking?Ideally, you'd similarly convert any other enums to a union of string literals, which is almost always better anyway. I, however, only attempted to use this enum.
The text was updated successfully, but these errors were encountered: