Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.1 Array.isArray breaking change review #41808

Closed
RyanCavanaugh opened this issue Dec 3, 2020 · 2 comments · May be fixed by #48228 or #49855
Closed

4.1 Array.isArray breaking change review #41808

RyanCavanaugh opened this issue Dec 3, 2020 · 2 comments · May be fixed by #48228 or #49855
Assignees
Labels
Fix Available A PR has been opened for this issue Meta-Issue An issue about the team, or the direction of TypeScript Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Dec 3, 2020

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[][]
@jameswilddev
Copy link

jameswilddev commented Dec 13, 2020

Hello! Can I just confirm this is fixed in 4.1.3 (released two days ago) as hinted above? I'm having difficulty upgrading from 4.1.2 to 4.1.3 as Array.isArray guard behaviour has changed and want to make sure that any changes I'm making are correct and not mitigations for a (temporary) tool bug.

@RyanCavanaugh
Copy link
Member Author

Correct, 4.1.3 contains the revert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Meta-Issue An issue about the team, or the direction of TypeScript Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
5 participants