Missing Boolean.toString definition and loose valueOf definition #60517
Open
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
}
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