Skip to content

4.1 Array.isArray breaking change review #41808

Closed
@RyanCavanaugh

Description

@RyanCavanaugh

Categorizing breaks we've seen from this

#41658, #41714

type Comparable = string | undefined | Array<string>;
export function check<T extends Comparable>(a: T) {
	if (Array.isArray(a)) {
		// 4.0: m: string
		// 4.1: Error, cannot index
		const m = a[0];
	}
}

#41610

const aggregatedResults: (number[] | null | 'loading')[] = [[1, 2], null, [3, 4], 'loading', [5, 6]]
// 4.0: onlyTheArrays: number[][]
// 4:1 Error, no overload matches this
const onlyTheArrays = aggregatedResults.filter<number[]>(Array.isArray) // number[][]

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueMeta-IssueAn issue about the team, or the direction of TypeScriptRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions