Skip to content

Improvement to getNarrowedType changes lodash's isArray #52827

Closed
@sandersn

Description

@sandersn
declare function isArrayLike(value: any): value is { length: number };
declare const value: { [index: number]: boolean, length: number } | undefined;

if (isArrayLike(value)) {
    const result: { length: number } = value;

} else {
    const result: undefined = value;
}

Before #52282: value: undefined in the false branch.
After #52282: value: { [index: number]: boolean, length: number } | undefined in the false branch.

This is more consistent, although the full repro at DefinitelyTyped/DefinitelyTyped#64406 seems less consistent than the 4.9 semantics.

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions