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
{{ message }}
Repository navigation
Incorrect @Input size typing when strictTemplates is enabled #220
Describe the bug
AOT compilation build under Angular 9 with angularCompilerOptions.strictTemplates: true in tsconfig.app.json generates a error TS2322: Type 'string' is not assignable to type 'number' when binding <as-split-area [size]="'*'">, as the @Input size is typed as number | null in the source code, though the documentation clearly states it can also be bound to '*' in pixel mode.
Reacted by Maksym Kobieliev, Guyutongxue, teuf22, laggage, Harpush and Thomas Peugeot
I was running into an issue with the size not being settable as a string due to typescript checking when using setVisibleAreaSizes
because I was using a string that included a calc( ... ) value.
The error I got was:
this.upperSplit.setVisibleAreaSizes([size1, size2, size3]);
~~~~~
Being a very naughty programmer I altered the interface defined in angular-split/lib/interface.d.ts so that it read:
export interface IOutputAreaSizes extends Array<number | string | '*'> {
That solved my issue with no known other side effects, other than having to make that tweak any time I update.
I imagine this is causing the size property not accepting a string in strict mode as well.
I'd like to more formally request that the interface be updated to include string as a type unless there is a good a really good reason not to.
@beeman — Wasn't this incorrect typing already resolved in your ngx-split fork? We've been using that fork without the $any('*') work-around in our Angular 10 project. I see now that ngx-split is deprecated and angular-split is being actively maintained again.
@beeman — Wasn't this incorrect typing already resolved in your ngx-split fork? We've been using that fork without the $any('*') work-around in our Angular 10 project. I see now that ngx-split is deprecated and angular-split being actively maintained again.
Correct, I solved it there so I know what's the fix.
I'm deprecated my fork because the original author decided to hand over maintainence of this library.
Any timeline for merging the fix for this issue from ngx-split, @beeman?
We've been holding off on switching back from ngx-split to angular-split until this issue is closed, but now ngx-split throws a fatal error at runtime under angular@11.1.0:
core.js:6156 ERROR Error: Uncaught (in promise): Error: ASSERTION ERROR: Expecting flags [Expected=> number === boolean <=Actual]
Error: ASSERTION ERROR: Expecting flags [Expected=> number === boolean <=Actual]
thanks for the workaround.
However I wonder if this is symply a typing issue, or an actual issue with the code, as the project is in TypeScript, so the typing are generated from the actual code, and the code really expects the size Input to be a Number as seen here
changed the title [-]Incorrect @Input size typing causes `error TS2322: Type 'string' is not assignable to type 'number'` when `tsconfig.json` `angularCompilerOptions.strictTemplates: true`[/-][+]Incorrect @Input size typing when strictTemplates is enabled[/+]on Mar 1, 2021
Activity
Maximaximum commentedon Apr 29, 2020
I'm having exactly the same issue. This is clearly a bug, so I hope it will be fixed
Maximaximum commentedon Jun 5, 2020
Hm, I wonder if this project is still maintained? 😢
literalpie commentedon Jun 18, 2020
As a workaround, you can use
$anyin the templatearthur-clifford commentedon Aug 22, 2020
I was running into an issue with the size not being settable as a string due to typescript checking when using setVisibleAreaSizes
because I was using a string that included a calc( ... ) value.
The error I got was:
this.upperSplit.setVisibleAreaSizes([size1, size2, size3]);
~~~~~
node_modules/angular-split/lib/interface.d.ts:40:18
40 export interface IOutputAreaSizes extends Array<number | '*'> {
Note: size2 was a string.
Being a very naughty programmer I altered the interface defined in angular-split/lib/interface.d.ts so that it read:
export interface IOutputAreaSizes extends Array<number | string | '*'> {
That solved my issue with no known other side effects, other than having to make that tweak any time I update.
I imagine this is causing the size property not accepting a string in strict mode as well.
I'd like to more formally request that the interface be updated to include string as a type unless there is a good a really good reason not to.
ahnpnl commentedon Oct 28, 2020
Hi, any updates on this issue ?
beeman commentedon Oct 28, 2020
For now the recommend way to handle this is using
$any()as mentioned here.Once v5 is released, built using Angular 10, I will consider fixing this in v6.
KeithGillette commentedon Oct 28, 2020
@beeman — Wasn't this incorrect typing already resolved in your
ngx-splitfork? We've been using that fork without the$any('*')work-around in our Angular 10 project. I see now thatngx-splitis deprecated andangular-splitis being actively maintained again.beeman commentedon Oct 28, 2020
Correct, I solved it there so I know what's the fix.
I'm deprecated my fork because the original author decided to hand over maintainence of this library.
Just didn't get to merging back my fixes.
KeithGillette commentedon Jan 21, 2021
Any timeline for merging the fix for this issue from
ngx-split, @beeman?We've been holding off on switching back from
ngx-splittoangular-splituntil this issue is closed, but nowngx-splitthrows a fatal error at runtime underangular@11.1.0:beeman commentedon Jan 21, 2021
@KeithGillette can't really give a timeline at this point, sorry. Simply too busy with other things.
I think the workaround using
$any('*')is relatively simple, so you might consider that.lf-novelt commentedon Mar 1, 2021
thanks for the workaround.
However I wonder if this is symply a typing issue, or an actual issue with the code, as the project is in TypeScript, so the typing are generated from the actual code, and the code really expects the
sizeInput to be a Number as seen hereangular-split/projects/angular-split/src/lib/directive/split-area.directive.ts
Lines 23 to 25 in 6596943
I am trying to find where this
size === "*"case is handled in the source...beeman commentedon Mar 1, 2021
Hey @lf-novelt , if you check #289 you can see where it's set. Once I finish that PR it will work without the workaround.
[-]Incorrect @Input size typing causes `error TS2322: Type 'string' is not assignable to type 'number'` when `tsconfig.json` `angularCompilerOptions.strictTemplates: true`[/-][+]Incorrect @Input size typing when strictTemplates is enabled[/+]