Skip to content

Missing Boolean.toString definition and loose valueOf definition #60517

Open
@Akindin

Description

⚙ Compilation target

ES2017

⚙ Library

lib.es5.d.ts

Missing / Incorrect Definition

interface Boolean {
    toString<T extends boolean>(this: T): `${T}`
    toString(this: Boolean): `${boolean}`
    valueOf<T extends boolean>(this: T): T
    valueOf(this: Boolean): boolean
}

TS Playground

Related issues #30225, #38347

Sample Code

const bool = true as boolean;


let a: `${boolean}` = true.toString();
let b: `${boolean}` = false.toString();
let c: `${boolean}` = bool.toString();
let d: `${boolean}` = new Boolean().toString();
let e: `${boolean}` = Boolean().toString();

let f: true = true.valueOf();
let g: false = false.valueOf();

Documentation Link

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString
https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-boolean.prototype.tostring
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf
https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-boolean.prototype.valueof

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions