microsoft / microsoft/TypeScript

Missing Boolean.toString definition and loose valueOf definition

Open
#60,517 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib.es5.d.ts and compare the Boolean declarations with the issue's proposed signatures and the linked ECMAScript references. Verify the sample assignments for toString and valueOf compile with the intended literal types; done means the missing and overly broad definitions are corrected.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.