You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can see how that is related, but I don't think it is a duplicate.
That logic does make sense for JS operators, where the coercion is reasonably well defined. That doesn't apply to the types in the BigInt constructor though. In the more general case, I don't think it's correct to change TS to allow wrapped objects everywhere that the valueOf return type matches a given type. See this playground for some examples where this doesn't work.
I would hope that if this behavior was desirable for authors of a function they would be able to opt into it explicitly (strawman: function example(x: number|HasValueOf<number>) where HasValueOf<T> matches any object whose valueOf returns type T). If this were the case, I'd expect the BigInt typings to be updated to include it, but as it stands today that doesn't exist and object is the best that can be done.
lib Update Request
Missing / Incorrect Definition
BigIntConstructor
does not acceptobject
, which it should as the spec defines it as being able to convert any object to a primitive.Sample Code
Documentation Link
https://tc39.es/ecma262/#sec-bigint-constructor-number-value
The text was updated successfully, but these errors were encountered: