Array.isArray problem with narrowed type
Author: plehnenCreated Feb 22, 2023Updated Apr 1, 2026
Labelsbugneeds-triage
Hi, I recently saw your YT video and wanted to add ts-reset to our project. But there is an issue which I find difficult to overcome:
Basically the problem is that isArray is always adding the type unknown[] to my variable, which I know is of type T | T[].
So when I check whether it's an array, I should know it's T[], but TS now thinks it's T[] & unknown[] which is a problem.
Any advice maybe? :)
Source: mattpocock/ts-reset