Skip to content

BigInt.toLocaleString does not have any arguments, and Intl.NumberFormat does not support formatting BigInt #36970

@MelnCat

Description

@MelnCat

TypeScript Version: 3.7.x-dev.201xxxxx

Search Terms:
bigint
bigint format
bigint numberformat
Code

console.log((2000n).toLocaleString("fr"));
console.log(new Intl.NumberFormat("fr").format(3000n));

Expected behavior:
The code runs without errors, and "2 000" and "3 000" is logged to the console.
Actual behavior:
The code fails to compile, with the errors

Expected 0 arguments, but got 1. ts(2554)
Argument of type '3000n' is not assignable to parameter of type 'number'. ts(2345)

It shouldn't fail. Reference
ECMA Specification
image

Playground Link: Link

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions