Calling and indexing on type 'never' is allowed #11412
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
Given that a property accesses and newing isn't allowed on something of type never,
declare var f: never;
// Error: Cannot use 'new' with an expression which lacks a construct signature.
new f();
// Error: Property 'x' does not exist on type 'never'.
f.x;I was surprised to find that never is still callable and indexable.
declare var f: never;
// All okay
f();
f[100]
f["x"]Is this intentional?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Activity
ahejlsberg commentedon Nov 3, 2017
It's definitely a bug that we don't error on the call expression. The element access expressions are permitted because anything can be indexed to produce an implicit
any. You'll get an error if you turn on--noImplicitAny, so I think that is behaving as expected.