TypeError: BigInt is not a constructor
- Dominant language
- Java
- Stars
- 170
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new). Attempting to construct it with new throws a [TypeError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError).
https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-bigint-constructor
> The BigInt [constructor](https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#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](https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#constructor) will cause an exception.
Currently generated code in 1.2.3:
```java
@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...
Contributor guide
Assessment
This issue has not been assessed yet.