-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed as not planned
Description
π Search Terms
isarray 5.8
π Version & Regression Information
- This changed between versions 5.7 and 5.8
β― Playground Link
π» Code
export const enum Category {
metadata = "__metadata",
toplevel = "toplevel",
timeline = "devtools.timeline",
cpuProfiler = "v8.cpu_profiler",
disabledByDefault_timeline = "disabled-by-default-devtools.timeline",
disabledByDefault_cpuProfiler = "disabled-by-default-v8.cpu_profiler",
}
export type Categories<C extends Category = Category> =
| ((string | void) & { [" _commaSeparatedCategory"]: C; })
| C;
export function joinCategories<C extends Category>(categories: C[]): Categories<C> {
return categories.join(",") as Categories<C>;
}
export function toCategories(categories: Categories | readonly Category[]): Categories {
return Array.isArray(categories)
? joinCategories(categories)
: categories;
}
π Actual behavior
5.8 and 5.9 say narrow categories
to any[]
instead of readonly Category[]
, and the else side is still the union, leading to an error.
π Expected behavior
Categories should be the right array type, and the else branch should just be Categories
.
Additional information about the issue
Noticed this while updating typescript-benchmarking past 5.7.
I think I remember an Anders PR in 5.8 that is related to this, but I can't remember what it is anymore.
Metadata
Metadata
Assignees
Labels
No labels