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
Typescript checking same parameters
Dynamic vs Static typing Typescript
🕗 Version & Regression Information
Property 'group' does not exist on type 'string | { type: "group"; columnIndex: number; group: (string | { type: "operation"; columnType: Primitive; value: string[]; })[]; }'.
Property 'group' does not exist on type 'string'.
This code is weird because passing the same values as array index , Typescript consider them to be different (I understand how arrays are passed by reference so the array could get modified by the same the first check and the second check use that index). The only way Typescript consider those two values the same is when you pass static values . Passing Number(0) also doesn't work !!
🙂 Expected behavior
It should consider passing the same variable at least (instead of array values) make the check pass:
🔎 Search Terms
Typescript checking same parameters
Dynamic vs Static typing Typescript
🕗 Version & Regression Information
Property 'group' does not exist on type 'string | { type: "group"; columnIndex: number; group: (string | { type: "operation"; columnType: Primitive; value: string[]; })[]; }'.
Property 'group' does not exist on type 'string'.
⏯ Playground Link
https://www.typescriptlang.org/play?#code/C4TwDgpgBACgTgSwLYOAgbtAvFA5AOwFckAjCOXKAHzwGdhF8BzSm3Egew4BsIBDfLgDcAKBGhIUAMrIwvAIqFyIACrhsUABQiou6lHqMmOvTQDeJvXokQAXHiZwOhMMMtWoAYx7F8ASXwAEwgAD3siUnJRDz1HZzB7bRiYmkMEZndk-QssrJt7XA5IOD40DkFo3Jjvbl81SHt4ZFQMCEqqq3Q+WrsDBnSmAG0AXXbcgF9MvQBKEbHJ2dGxb3x6KABHJTgQexkkOQhFZXqNEbERFbWXQNKIADVupSgsd010ezTmABooCE3uj79b5QdLBMJQQYRMhwH5Q8jDab2AQgZ4APigFimugQADMtFiPDYOHjNspBqDQoMAAzDYZQACEWBwuE+LCgADJ2QSrKTtuSgpSacMAHRxFz8sGDACMtIJ0wx3L0cAgwEIcHwUAAtFKxlZJnrluUrmAbsB7o8IAB9Z6vd59Iw-P6EAH2gY-CngyHEaGw73wxFQZFohVZXH4jpQIkkrYgQbUn4y6m0hlMuhAtmcxW6Xmx+NQRNC0VOcUe6WyrLynIdZWq9VanUE-V6SYXI3AKDXW4PHqW60vKxvQEO37-bhDt0ggWeuEwqAzhFI-AorDoqvVNsGPhIc1jud+uDPKAAOX3mip011ejDSQ6UY2McGtC3O7pjOZrMomYjOcfz+7IrFMAJUpGVhjlENqxVNUNW1S9dCbeDDVWdtOzNbslF7PtbXHYEnRdVl3SnewvUiWd5wDIMVwg9dkM3bdu3CfdDxPUjNFLGkLwJa8s0jdRiXvMkn3o7pX1TFl00-LlvwfISXyLeJgJCMswIrajchraD6zgqAEJ0pDjVNHcMMwm0BztAiR2dXcLI9YiZ19UiF0DJdg0xUM8RvKo7x-GkU3fCSOSkjofIA4sgNLUDwLXdSoLrWDG3ccYgA
💻 Code
🙁 Actual behavior
This code is weird because passing the same values as array index , Typescript consider them to be different (I understand how arrays are passed by reference so the array could get modified by the same the first check and the second check use that index). The only way Typescript consider those two values the same is when you pass static values . Passing Number(0) also doesn't work !!
🙂 Expected behavior
It should consider passing the same variable at least (instead of array values) make the check pass:
Additional information about the issue
I may be wrong on how Typescript handle such cases so sorry in advance if i mis-understand things
The text was updated successfully, but these errors were encountered: