jsr
jsr copied to clipboard
Negative infinity in a type causes "Failed ensuring public API type output is valid."
trafficstars
In TypeScript, there are ways to make a numeric literal representing Infinity and -Infinity:
export type PositiveInfinity = 1e999;
export type NegativeInfinity = -1e999;
However, trying to publish those to JSR, deno publish fails with the following:
Checking for slow types in the public API...
error: Failed ensuring public API type output is valid.
TS1110 [ERROR]: Type expected.
export type NegativeInfinity = -Infinity;
^
TS2749 [ERROR]: 'Infinity' refers to a value, but is being used as a type here. Did you mean 'typeof Infinity'?
export type PositiveInfinity = Infinity;
~~~~~~~~
Found 2 errors.
You may have discovered a bug in Deno. Please open an issue at: https://github.com/denoland/deno/issues/
Note that the TypeScript error shows a different "source" than the actual source file.
For the PositiveInfinity, there is a way around it:
export type PositiveInfinity = typeof Infinity;
However, there is no similar walkaround for the NegativeInfinity type.
That looks like a bug!
Upstream bug in SWC: https://github.com/swc-project/swc/issues/9223
The bug seems to be resolved – I can't reproduce it anymore!