Skip to content

Functions are compatible with ArrayLike<any> #18757

Closed
@cartant

Description

@cartant

TypeScript Version: 2.5.2

Code

function func() {}
const array: ArrayLike<any> = func;

See this TypeScript Playground example.

Expected behavior:

I'd have expected an error to be effected.

Actual behavior:

No error is effected if the type ArrayLike<any> is specified. It seems the absence of an index signature is not a consideration in this situation.

If the any is changed to, say, string an error is effected:

Index signature is missing in type '() => void'.

Metadata

Metadata

Labels

Breaking ChangeWould introduce errors in existing codeCommittedThe team has roadmapped this issueEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Fix AvailableA PR has been opened for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions