mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-27 06:43:19 +08:00
`const C = zlib.Gzip` stopped at SC2020, and `instanceof zlib.Gzip` (any zlib class) stopped at SC1090. A const binding of a zlib class is now a compile-time alias with no runtime slot: `new C()`, `typeof C`, `C.name` and `C === zlib.Gzip` lower at the use. `instanceof` against a zlib class asks the runtime for the stream's mode when the operand is a Transform, tests for a Transform first when it is typed as one of Transform's bases, and answers false for other static types, as in Node. Other uses of an alias as a value report SC1090 at the use.
12 lines
370 B
TypeScript
12 lines
370 B
TypeScript
// A zlib class alias owns no runtime value: construction, instanceof,
|
|
// typeof and .name compile, other uses report at the use. instanceof on
|
|
// an untyped operand reports as well.
|
|
import * as zlib from "node:zlib";
|
|
|
|
const Gz = zlib.Gzip;
|
|
const classes = [Gz];
|
|
console.log(classes.length);
|
|
|
|
const parsed: unknown = JSON.parse("{}");
|
|
console.log(parsed instanceof Gz);
|