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

no implicit any when indexing never #26493

Closed
sandersn opened this issue Aug 16, 2018 · 1 comment
Closed

no implicit any when indexing never #26493

sandersn opened this issue Aug 16, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript

Comments

@sandersn
Copy link
Member

sandersn commented Aug 16, 2018

// @noImplicitAny: true
function f(l: never, x: any) {
  var x = l[0] // should be implicit any error here, but 'non-matching redeclaration type' instead
  x.length  // and no error here, but 'length' not found on 'never' instead
}

Expected behavior:
With noImplicitAny on, you should get a noImplicitAny error and x: any. With it off, you should just get x: any.

Actual behavior:
x: never and you get an error on the next line that 'length' does not exist on type 'never'.

On master, but not 3.1 as of 2018/07/17

@sandersn sandersn self-assigned this Aug 16, 2018
@sandersn sandersn added the Bug A bug in TypeScript label Aug 16, 2018
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.1 milestone Aug 16, 2018
@ahejlsberg
Copy link
Member

This is an intended effect of #26340. We definitely want T[K] to be never when T is never.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants