-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Broken emit when Infinity
or ‑Infinity
ends up in a type position
#42905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Infinity
or -Infinity
ends up in a Type positionInfinity
or ‑Infinity
ends up in a type position
You're mixing a bug report and a feature request together in one. Fixing the bug would be to emit the type |
I for one have wanted function* bigintRange(low: bigint, high: bigint | Infinity, step?: bigint=1n): Generator<bigint> {
for (let i = low; i < high; i += step) {
yield i;
}
} |
@Jamesernator Just as a general advice: It tremendously helps when you explain your reasoning on why you want this, not just say "I want it for this". In your example you could just as well replace the |
The example is bigint not number. BigInts don't contain an |
More compelling explanations for why these types are needed can be found in #28682 . |
👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript. Issue body code block by @ExE-Boss 👍 Compiled export declare const PositiveInfinity: Infinity;
export declare const NegativeInfinity: -Infinity; Historical Information
|
Wouldn't it be emitting |
Bug Report
🔎 Search Terms
Infinity
NaN
🕗 Version & Regression Information
💻 Code
⏯ Playground Link
Workbench Repro
🙁 Actual behavior
TypeScript emits
Infinity
and‑Infinity
in a type position, which are intentionally invalid according to #9407 (comment):🙂 Expected behavior
The
Infinity
and‑Infinity
values are valid in a type position, so that the generated.d.ts
file is valid.Also, it’d be nice to support literal
NaN
s, which would allow forNumber.isNaN
to be typed as:Related issues
The text was updated successfully, but these errors were encountered: