Skip to content

Boolean["toString"] inconsistency #30225

Open
@sirian

Description

@sirian

TypeScript Version: 3.4.0-dev.20190305

Code

const key: keyof Boolean = "toString"; // error - "toString" is not assignable to "valueOf"

const x: {toString(): string} = new Boolean(); // no error
const y: Boolean["toString"] = true.toString; // no error

class Bool extends Boolean { 
     protected toString() { // also no error, but should be
          return "";
     }
}

Expected behavior:
keyof Boolean should be "toString" | "valueOf"
Playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions