Skip to content

TypeError: BigInt is not a constructor #171

@niloc132

Description

@niloc132

The elemental2.core.BigInt class exposes a constructor, but one that cannot be called without a runtime error.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt

Note: BigInt() can only be called without new. Attempting to construct it with new throws a TypeError.

https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-bigint-constructor

The BigInt constructor:
...
is not intended to be used with the new operator or to be subclassed. It may be used as the value of an extends clause of a class definition but a super call to the BigInt constructor will cause an exception.

Currently generated code in 1.2.3:

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public class BigInt {
  //...

  public BigInt(BigInt.ConstructorArgUnionType arg) {}

  public BigInt(JsBigint arg) {}

  public BigInt(String arg) {}

  public BigInt(double arg) {}
  //...
}

Arguably this is a closure-compiler externs issue, but I'm unclear how externs would define this type to have a prototype and methods, but the "constructor" is just a function...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions