jsr icon indicating copy to clipboard operation
jsr copied to clipboard

Negative infinity in a type causes "Failed ensuring public API type output is valid."

Open cshaa opened this issue 1 year ago • 2 comments
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.

cshaa avatar Jun 23 '24 14:06 cshaa

That looks like a bug!

lucacasonato avatar Jul 12 '24 15:07 lucacasonato

Upstream bug in SWC: https://github.com/swc-project/swc/issues/9223

lucacasonato avatar Jul 12 '24 15:07 lucacasonato

The bug seems to be resolved – I can't reproduce it anymore!

cshaa avatar Sep 16 '24 20:09 cshaa