Skip to content

JS: Allows illegal assignment to function properties #26371

@ghost

Description

TypeScript Version: 3.1.0-dev.20180810

Code

const f = () => 0;
f.call = 0;
useF(f);

/** @param {() => number} f */
function useF(f) {
    f.call(null);
}

Expected behavior:

Error on assigning f.call since that would change the type.
On this topic, f.length should be readonly.

Actual behavior:

No error (at compile time).

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions