GeezerVison is showing github.com — Incorrect @Input size typing when strictTemplates is enabled · Issue #220 · angular-split/angular-split
Incorrect @Input size typing when strictTemplates is enabled #220DescriptionDescribe 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 ActivityMaximaximum commented on Apr 29, 2020 I'm having exactly the same issue. This is clearly a bug, so I hope it will be fixed Maximaximum commented on Jun 5, 2020 Hm, I wonder if this project is still maintained? 😢 literalpie commented on Jun 18, 2020 As a workaround, you can use $any in the template
<as-split-area [size]="$any('*')">hello</as-split-area>
Reacted by beeman and Keith Gillette arthur-clifford commented on 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 commented on Oct 28, 2020 Hi, any updates on this issue ? beeman commented on Oct 28, 2020
Hi, any updates on this issue ?
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 commented on Oct 28, 2020 @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 commented on Oct 28, 2020
@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.
Just didn't get to merging back my fixes. KeithGillette commented on 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-split to angular-split until this issue is closed, but now ngx-split throws a fatal error at runtime under [email protected]:
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]
beeman commented on 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 commented on 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 size Input to be a Number as seen here
|
private _size: number | null = null |
|
|
|
@Input() set size(v: number | null) { |
I am trying to find where this size === "*" case is handled in the source... beeman commented on 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. Reacted by Louis Frament and Thomas Peugeot 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
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|