Possibly Undefined Error
I have two arrays that I am expecting to contain the same values, but possibly in a different order.
Example
Arr1 = [1, 2, 3]
Arr2 = [3, 1, 2]
However, it is possible that they do NOT contain the same values, and this should be treated as an error in my api. TypeScript is detecting this, but does not seem to be smart enough to know I am checking that they contain the same values. How can I fix this? Thanks!
2 Replies
there does not seem to be any errors in the ts playground which I found weird, but it occurs when trying to sort. Maybe its a ts setting specific to t3 stack? I tried to ts ignore it but that also gives me a linter message saying not to use ts ignore haha. Any advice is appreciated.
https://www.typescriptlang.org/play?#code/MYewdgzgLgBANgSzAawjAvDA2gbwQEwC4YAiARhIBoYoEo4BTYkgMxBCpgFcAnOZgEYBDHiQC+1PEVIAmTrXpNSbDtV79Sw0RJhTmAZnl1GzFZ3WCR4gLoBuAFChIsHgwCOGXQJD4AnsRwQHnwGHmIsck4SOWoSABYSazExGCE0ITBfB0dwaHgkZAAFEAg6BFziACUGUGCAHmgeJABzajAuAFsBUIA+TxwxB1c3ADpvPxGgkJ4Rth4AUSFgAAsACnsYTZhVgmJGluokEIAPYnau0IBKDD7VxBRi0tpcrAJrTyOGY8v7S+ynPJOKBCJAQACCcDgnlWIh4ZD2UCaYGaWGs1FhMgRSJR1mu6B6Gy2GJGDAAbqFfKsYTweDIAJJQBgdPF9WFkEZIYBwLghCDU2kMpmXP72HLOGAQIQdBgAWSZ3R4aEw-PhEsRLVR6JpmLV2NRLMJmyBIMgELgKq1tOuADJrTBjaCzfyZJayCKxRAQIwRnAQM07gUICMOkIAA5U+7IFn5FAc-DCj1ehg+v2rYZjHy+SbBK6ihAsbaGiVS2Xy0J8ouRoMh8MBlDRyNxy6UIvp8ZZqahVJofbI1FFn7XHBFgFJlP+gDkIagKxaE5+WxjqBGnp4UCpQmoAgbBUeZReQjj7wAtEu989IFgBEeRSkGHAIAxdCPcmPfZOwCBYNPZ8j5-YxCAA