Skip to content

Type indexing with string literals starting with __ does not work #14268

Closed

Description

TypeScript Version: 2.3.0-dev.20170223

Code

It's very likely that this is already reported, but I couldn't find it after a quick search through the issues.

type Foo = {
  bar: string
  __typename: string
}

type A = Foo["bar"] // ok 
type B = Foo["__typename"] // Property '__typename' does not exist on type 'Foo'.

Expected behavior:

Type B should be string.

Actual behavior:

Error is thrown.

Activity

  1. guncha commented on Feb 23, 2017

    @guncha
    Author

    I did find an older similar issue: #8614

    Lo and behold:

    type B = Foo["___typename"] // three underscores, ok
  2. added a commit that references this issue on Mar 25, 2017
  3. weswigham commented on Jul 6, 2017

    @weswigham
    Member

    This should be fixed by #16915

  4. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions