@scriptc/compiler 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +139 -14
- package/dist/backend/cc.d.ts +13 -0
- package/dist/backend/cc.js +11 -0
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/emission/emit-async.d.ts +4 -0
- package/dist/backend/emission/emit-async.js +34 -2
- package/dist/backend/emission/emit-async.js.map +1 -1
- package/dist/backend/emission/emit-exprs.d.ts +10 -0
- package/dist/backend/emission/emit-exprs.js +272 -22
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-shapes.js +1 -0
- package/dist/backend/emission/emit-shapes.js.map +1 -1
- package/dist/backend/emission/emit-stmts.js +36 -9
- package/dist/backend/emission/emit-stmts.js.map +1 -1
- package/dist/backend/emission/emit-types.js +14 -1
- package/dist/backend/emission/emit-types.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +19 -1
- package/dist/backend/emission/emitter.js +81 -2
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.js +578 -36
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.js +12 -3
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/mangle.d.ts +3 -0
- package/dist/backend/mangle.js +5 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +10 -0
- package/dist/compat/fetch-profile.js +55 -6
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/coverage/surface-manifest.js +16 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +10 -0
- package/dist/diagnostics/diagnostic.js +27 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +17 -16
- package/dist/frontend/lowering/lower-builtins.js +817 -117
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +3 -1
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +28 -8
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +2 -1
- package/dist/frontend/lowering/lower-containers.js +99 -32
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +1 -1
- package/dist/frontend/lowering/lower-exprs.js +78 -6
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +7 -1
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +59 -1
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +21 -0
- package/dist/frontend/lowering/lower-island.js +284 -10
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +5 -0
- package/dist/frontend/lowering/lower-server.js +1 -1
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +6 -2
- package/dist/frontend/lowering/lower-stmts.js +53 -14
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +3 -2
- package/dist/frontend/lowering/lowerer.js +17 -8
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +108 -25
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/program.d.ts +4 -4
- package/dist/frontend/program.js +264 -46
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.d.ts +10 -0
- package/dist/frontend/resolve.js +37 -0
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/ts7/enums.d.ts +9 -0
- package/dist/frontend/ts7/enums.js +8 -6
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/program.js +4 -1
- package/dist/frontend/ts7/program.js.map +1 -1
- package/dist/frontend/types.d.ts +7 -4
- package/dist/frontend/types.js +103 -8
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/ir/integer-loops.d.ts +23 -0
- package/dist/ir/integer-loops.js +82 -0
- package/dist/ir/integer-loops.js.map +1 -0
- package/dist/ir/nodes.d.ts +104 -28
- package/dist/ir/nodes.js +89 -1
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +136 -25
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/fence-eval.js +4 -3
- package/dist/library/fence-eval.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +186 -29
|
@@ -11,6 +11,15 @@ interface ModuleResolutionKindEnum {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const ModuleResolutionKind: ModuleResolutionKindEnum;
|
|
13
13
|
export type ModuleResolutionKind = number;
|
|
14
|
+
interface ModuleDetectionKindEnum {
|
|
15
|
+
readonly None: number;
|
|
16
|
+
readonly Auto: number;
|
|
17
|
+
readonly Legacy: number;
|
|
18
|
+
readonly Force: number;
|
|
19
|
+
readonly [key: string | number]: string | number;
|
|
20
|
+
}
|
|
21
|
+
export declare const ModuleDetectionKind: ModuleDetectionKindEnum;
|
|
22
|
+
export type ModuleDetectionKind = number;
|
|
14
23
|
/** Reverse-maps a numeric enum value to its TS7 key name ("ESNext",
|
|
15
24
|
* "Bundler") — the spelling tsgo's tsconfig JSON parser accepts (lowercased
|
|
16
25
|
* by the caller where needed). Symbolic by construction: the name comes from
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
* this module.
|
|
9
9
|
*
|
|
10
10
|
* Placement in 7.0.2 (probed): the AST-world enums ship from unstable/ast,
|
|
11
|
-
* the checker-world enums from unstable/sync. ModuleResolutionKind
|
|
12
|
-
* census
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* the checker-world enums from unstable/sync. ModuleResolutionKind and
|
|
12
|
+
* ModuleDetectionKind are the census/options enums the package does not
|
|
13
|
+
* re-export from any public entry point — they live in dist/enums (the
|
|
14
|
+
* #enums/* internal imports), which the exports map hides from bare-
|
|
15
|
+
* specifier imports but NOT from a direct file require; loadHiddenEnum
|
|
16
|
+
* resolves the package root and requires the enum module by path, so the
|
|
17
|
+
* values are still TypeScript 7's own, never copied numbers. */
|
|
17
18
|
import { createRequire } from "node:module";
|
|
18
19
|
import { dirname, join } from "node:path";
|
|
19
20
|
export { InternalSymbolName, ModifierFlags, NodeFlags, ScriptKind, ScriptTarget, SyntaxKind, TokenFlags, } from "typescript/unstable/ast";
|
|
@@ -32,6 +33,7 @@ function loadHiddenEnum(basename, key) {
|
|
|
32
33
|
return value;
|
|
33
34
|
}
|
|
34
35
|
export const ModuleResolutionKind = loadHiddenEnum("moduleResolutionKind", "ModuleResolutionKind");
|
|
36
|
+
export const ModuleDetectionKind = loadHiddenEnum("moduleDetectionKind", "ModuleDetectionKind");
|
|
35
37
|
/** Reverse-maps a numeric enum value to its TS7 key name ("ESNext",
|
|
36
38
|
* "Bundler") — the spelling tsgo's tsconfig JSON parser accepts (lowercased
|
|
37
39
|
* by the caller where needed). Symbolic by construction: the name comes from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/frontend/ts7/enums.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/frontend/ts7/enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;gEAgBgE;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,SAAS,EACT,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,y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
19
19
|
import { API } from "typescript/unstable/sync";
|
|
20
20
|
import { CheckerFacade } from "./checker.js";
|
|
21
|
-
import { enumKeyOf, ModuleKind, ModuleResolutionKind, ScriptTarget } from "./enums.js";
|
|
21
|
+
import { enumKeyOf, ModuleDetectionKind, ModuleKind, ModuleResolutionKind, ScriptTarget } from "./enums.js";
|
|
22
22
|
import { tsgoPath } from "../shared.js";
|
|
23
23
|
/* tsconfig JSON wants enum NAMES; the options object carries TS7's numeric
|
|
24
24
|
* enum values. The names come from the enum objects' own reverse mappings —
|
|
@@ -47,6 +47,9 @@ function serializeOptions(options) {
|
|
|
47
47
|
case "moduleResolution":
|
|
48
48
|
out[key] = enumKeyOf(ModuleResolutionKind, value)?.toLowerCase() ?? value;
|
|
49
49
|
break;
|
|
50
|
+
case "moduleDetection":
|
|
51
|
+
out[key] = enumKeyOf(ModuleDetectionKind, value)?.toLowerCase() ?? value;
|
|
52
|
+
break;
|
|
50
53
|
case "lib":
|
|
51
54
|
// 5.9.3 spells lib entries "lib.es2025.d.ts"; tsconfig wants "es2025".
|
|
52
55
|
out[key] = value.map((lib) => lib.startsWith("lib.") && lib.endsWith(".d.ts") ? lib.slice(4, -5) : lib);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../../src/frontend/ts7/program.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;iDAeiD;AAEjD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAQ/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
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,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACxC,IAAI,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,SAAS,CAAC;QACrC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED;;qCAEqC;AACrC,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,UAAU,CAAC,IAAY;QACrB,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IACrD,CAAC;IACD,QAAQ,CAAC,IAAY;QACnB,IAAI,CAAC;YACH,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,SAAS,CAAC,IAAY,EAAE,IAAY;QAClC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,eAAe,CAAC,IAAY;QAC1B,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,CAAC;IACD,mBAAmB;QACjB,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;IACvB,CAAC;IACD,yBAAyB,EAAE,IAAI;IAC/B,OAAO,EAAE,IAAI;CACd,CAAC"}
|
package/dist/frontend/types.d.ts
CHANGED
|
@@ -4,13 +4,16 @@ import { typeKey } from "../ir/nodes.js";
|
|
|
4
4
|
export { typeKey };
|
|
5
5
|
/** The ambient TYPE names of the fetch slice. Under --dynamic their
|
|
6
6
|
* values live in the embedded engine and map to island handles (jsval).
|
|
7
|
-
* Static fetch gives Response, RequestInit, AbortSignal, response
|
|
7
|
+
* Static fetch gives Response, RequestInit, AbortController/AbortSignal, response
|
|
8
8
|
* Headers, and the readable Web Streams slice native checked-dynamic
|
|
9
9
|
* handle representations. The Headers constructor itself remains
|
|
10
10
|
* dynamic-only even though response.headers is native.
|
|
11
11
|
* Declaration provenance is checked in mapType so user types with the
|
|
12
12
|
* same names keep their ordinary structural representation. */
|
|
13
|
-
export declare const ISLAND_AMBIENT_TYPES: readonly ["Response", "RequestInit", "Event", "EventTarget", "AbortSignal", "Headers", "ReadableStream", "ReadableStreamDefaultReader", "ReadableStreamDefaultController", "ReadableStreamReadResult", "ReadableStreamReadValueResult", "ReadableStreamReadDoneResult"];
|
|
13
|
+
export declare const ISLAND_AMBIENT_TYPES: readonly ["Response", "ResponseInit", "RequestInit", "Event", "EventTarget", "AbortController", "AbortSignal", "Headers", "ReadableStream", "ReadableStreamDefaultReader", "ReadableStreamDefaultController", "ReadableStreamReadResult", "ReadableStreamReadValueResult", "ReadableStreamReadDoneResult"];
|
|
14
|
+
/** True for the parseArgs type family that deliberately rides dyn. Exported
|
|
15
|
+
* for the property-read bridge after TypeScript narrows a token union arm. */
|
|
16
|
+
export declare function isParseArgsDynTypeName(name: string): boolean;
|
|
14
17
|
/** The frontend's record-shape interner. Records are monomorphic structural
|
|
15
18
|
* shapes: fields sorted by name form the canonical identity, and two types
|
|
16
19
|
* with the same canonical field list share one shapeId (and later one C
|
|
@@ -279,7 +282,7 @@ export declare function unitOnlyUnion(unions: UnionRegistry): IrType;
|
|
|
279
282
|
* `.return()`, `.throw()`, the for-of desugar, and mapType's
|
|
280
283
|
* IteratorResult alias mapping all intern through here, so reads agree.
|
|
281
284
|
* Null when the combined union would be illegal (a func/set arm beside
|
|
282
|
-
* data arms, a map/regex arm — kinds with no narrowing test): such
|
|
285
|
+
* data arms, a map/regex/Date arm — kinds with no narrowing test): such
|
|
283
286
|
* generators stay unmapped. */
|
|
284
287
|
export declare function genResultRecord(yieldT: IrType, retT: IrType, shapes: ShapeRegistry, unions: UnionRegistry): (IrType & {
|
|
285
288
|
kind: "record";
|
|
@@ -293,7 +296,7 @@ export declare function genResultRecord(yieldT: IrType, retT: IrType, shapes: Sh
|
|
|
293
296
|
export declare function isUnitOnlyTsType(t: ts.Type): boolean;
|
|
294
297
|
/** IR-level `t | undefined`, canonicalized and fenced exactly like the
|
|
295
298
|
* ts-union branch of mapType (typeKey-sorted arms, deduplicated; map/
|
|
296
|
-
* regex/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
299
|
+
* regex/Date/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
297
300
|
* result is exactly the nullable-callback shape mapType's union branch
|
|
298
301
|
* admits, `(() => void) | undefined`) so the interned union is IDENTICAL
|
|
299
302
|
* to what mapping the checker's own `T | undefined` produces. */
|
package/dist/frontend/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from "./ts7/adapter.js";
|
|
2
|
-
import { arrayOf, BOOL, bytesOf, canConvertToDyn, CHILD_T, DYN, F64, funcOf, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, JSVAL, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, setOf, STRING, SYMBOL_T, typeEquals, typeKey, UNDEFINED_T, VOID } from "../ir/nodes.js";
|
|
2
|
+
import { arrayOf, BOOL, bytesOf, canConvertToDyn, CHILD_T, DATE_T, DYN, F64, funcOf, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, JSVAL, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, setOf, STRING, SYMBOL_T, typeEquals, typeKey, UNDEFINED_T, VOID } from "../ir/nodes.js";
|
|
3
3
|
import { isJsSourceFile, isNodeTypesPath } from "./program.js";
|
|
4
4
|
import { accessorSlotProp } from "../ir/nodes.js";
|
|
5
5
|
// typeKey moved to ir/nodes.ts (the backend needs it too, for per-type
|
|
@@ -8,7 +8,7 @@ import { accessorSlotProp } from "../ir/nodes.js";
|
|
|
8
8
|
export { typeKey };
|
|
9
9
|
/** The ambient TYPE names of the fetch slice. Under --dynamic their
|
|
10
10
|
* values live in the embedded engine and map to island handles (jsval).
|
|
11
|
-
* Static fetch gives Response, RequestInit, AbortSignal, response
|
|
11
|
+
* Static fetch gives Response, RequestInit, AbortController/AbortSignal, response
|
|
12
12
|
* Headers, and the readable Web Streams slice native checked-dynamic
|
|
13
13
|
* handle representations. The Headers constructor itself remains
|
|
14
14
|
* dynamic-only even though response.headers is native.
|
|
@@ -16,9 +16,11 @@ export { typeKey };
|
|
|
16
16
|
* same names keep their ordinary structural representation. */
|
|
17
17
|
export const ISLAND_AMBIENT_TYPES = [
|
|
18
18
|
"Response",
|
|
19
|
+
"ResponseInit",
|
|
19
20
|
"RequestInit",
|
|
20
21
|
"Event",
|
|
21
22
|
"EventTarget",
|
|
23
|
+
"AbortController",
|
|
22
24
|
"AbortSignal",
|
|
23
25
|
"Headers",
|
|
24
26
|
"ReadableStream",
|
|
@@ -28,6 +30,31 @@ export const ISLAND_AMBIENT_TYPES = [
|
|
|
28
30
|
"ReadableStreamReadValueResult",
|
|
29
31
|
"ReadableStreamReadDoneResult",
|
|
30
32
|
];
|
|
33
|
+
/** node:util.parseArgs's public and @types/node helper type names. Values
|
|
34
|
+
* behind this surface use the checked-dynamic tree; see mapTypeInner. */
|
|
35
|
+
const PARSE_ARGS_DYN_TYPES = new Set([
|
|
36
|
+
"ParseArgsConfig",
|
|
37
|
+
"ParseArgsOptionDescriptor",
|
|
38
|
+
"ParseArgsOptionsConfig",
|
|
39
|
+
"ParseArgsResult",
|
|
40
|
+
"ParseArgsToken",
|
|
41
|
+
"ParsedResults",
|
|
42
|
+
"PreciseParsedResults",
|
|
43
|
+
"ParsedValues",
|
|
44
|
+
"ParsedPositionals",
|
|
45
|
+
"ParsedTokens",
|
|
46
|
+
"ParsedOptionToken",
|
|
47
|
+
"ParsedPositionalToken",
|
|
48
|
+
"PreciseTokenForOptions",
|
|
49
|
+
"TokenForOptions",
|
|
50
|
+
"OptionToken",
|
|
51
|
+
"Token",
|
|
52
|
+
]);
|
|
53
|
+
/** True for the parseArgs type family that deliberately rides dyn. Exported
|
|
54
|
+
* for the property-read bridge after TypeScript narrows a token union arm. */
|
|
55
|
+
export function isParseArgsDynTypeName(name) {
|
|
56
|
+
return PARSE_ARGS_DYN_TYPES.has(name);
|
|
57
|
+
}
|
|
31
58
|
/** The frontend's record-shape interner. Records are monomorphic structural
|
|
32
59
|
* shapes: fields sorted by name form the canonical identity, and two types
|
|
33
60
|
* with the same canonical field list share one shapeId (and later one C
|
|
@@ -330,6 +357,8 @@ export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
|
330
357
|
return "any";
|
|
331
358
|
case "regex":
|
|
332
359
|
return "RegExp";
|
|
360
|
+
case "date":
|
|
361
|
+
return "Date";
|
|
333
362
|
case "url":
|
|
334
363
|
return "URL";
|
|
335
364
|
case "searchParams":
|
|
@@ -338,6 +367,8 @@ export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
|
338
367
|
return "symbol";
|
|
339
368
|
case "stats":
|
|
340
369
|
return "Stats";
|
|
370
|
+
case "fileHandle":
|
|
371
|
+
return "FileHandle";
|
|
341
372
|
case "spawnRes":
|
|
342
373
|
return "SpawnSyncReturns";
|
|
343
374
|
case "child":
|
|
@@ -617,6 +648,23 @@ function mapTypeInner(type, ctx) {
|
|
|
617
648
|
return STRING;
|
|
618
649
|
if (flags & ts.TypeFlags.Boolean || flags & ts.TypeFlags.BooleanLiteral)
|
|
619
650
|
return BOOL;
|
|
651
|
+
// node:util.parseArgs config/results are declaration-heavy conditional
|
|
652
|
+
// and discriminated-union types over a value that is naturally a checked-
|
|
653
|
+
// dynamic tree. Keep the named public surface (plus @types/node's private
|
|
654
|
+
// helper aliases that survive instantiation) in that representation:
|
|
655
|
+
// typed member reads still exit through ordinary dyn checks, while the
|
|
656
|
+
// runtime can preserve the three token variants and null-prototype values
|
|
657
|
+
// object without inventing one false static record shape. Provenance keeps
|
|
658
|
+
// user aliases with the same names on the normal structural path.
|
|
659
|
+
{
|
|
660
|
+
const parseArgsSym = widened.getAliasSymbol() ?? widened.getSymbol();
|
|
661
|
+
if (parseArgsSym &&
|
|
662
|
+
PARSE_ARGS_DYN_TYPES.has(parseArgsSym.name) &&
|
|
663
|
+
checker.declarationsOf(parseArgsSym).some((d) => ctx.isStdlibFile(d.getSourceFile()) &&
|
|
664
|
+
isDeclaredInAmbientModule(d, "util"))) {
|
|
665
|
+
return DYN;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
620
668
|
// The lib's BOXED wrapper interfaces used as TYPES (`const n: Number =
|
|
621
669
|
// 5`): every value such a slot can hold IS the primitive — `new
|
|
622
670
|
// Number(...)` construction is fenced, so no box object ever exists —
|
|
@@ -784,7 +832,9 @@ function mapTypeInner(type, ctx) {
|
|
|
784
832
|
// declarations intern one immortal closure, and inner closures are
|
|
785
833
|
// allocated once at their definition's evaluation and flow by
|
|
786
834
|
// reference, exactly JS's function identity. map/set/regex/url/dyn and
|
|
787
|
-
// the other opaque
|
|
835
|
+
// Date (scalar-backed but identity-bearing in JS) and the other opaque
|
|
836
|
+
// handles stay unsupported as array elements; ordinary Date locals,
|
|
837
|
+
// params, fixed record/tuple fields, and promise payloads are supported.
|
|
788
838
|
if (checker.isArrayType(widened)) {
|
|
789
839
|
const elemTs = checker.getTypeArguments(widened)[0];
|
|
790
840
|
if (!elemTs)
|
|
@@ -814,11 +864,13 @@ function mapTypeInner(type, ctx) {
|
|
|
814
864
|
// JS object identity for RegExp values.
|
|
815
865
|
if (!elem ||
|
|
816
866
|
elem.kind === "void" ||
|
|
867
|
+
elem.kind === "date" ||
|
|
817
868
|
elem.kind === "map" ||
|
|
818
869
|
elem.kind === "set" ||
|
|
819
870
|
elem.kind === "url" ||
|
|
820
871
|
elem.kind === "searchParams" ||
|
|
821
872
|
elem.kind === "stats" ||
|
|
873
|
+
elem.kind === "fileHandle" ||
|
|
822
874
|
elem.kind === "spawnRes" ||
|
|
823
875
|
elem.kind === "netSocket" ||
|
|
824
876
|
elem.kind === "dgramSocket" ||
|
|
@@ -1285,6 +1337,12 @@ function mapTypeInner(type, ctx) {
|
|
|
1285
1337
|
return null;
|
|
1286
1338
|
return setOf(elem);
|
|
1287
1339
|
}
|
|
1340
|
+
// Date: a TimeClip'd epoch-millisecond scalar in the static runtime.
|
|
1341
|
+
// This supports stored/passed values and the read-only getter slice;
|
|
1342
|
+
// identity and mutation stay fenced because the scalar deliberately
|
|
1343
|
+
// carries no object identity.
|
|
1344
|
+
if (isStdlibInterface("Date"))
|
|
1345
|
+
return DATE_T;
|
|
1288
1346
|
// RegExp: a reference to the lib RegExp interface — provenance, not the
|
|
1289
1347
|
// name (a user's own `interface RegExp` maps as a record). Regex values
|
|
1290
1348
|
// are literals interned as immortal statics; the kind is fenced out of
|
|
@@ -1383,6 +1441,15 @@ function mapTypeInner(type, ctx) {
|
|
|
1383
1441
|
ctx.isStdlibFile(d.getSourceFile()))) {
|
|
1384
1442
|
return { kind: "stats" };
|
|
1385
1443
|
}
|
|
1444
|
+
// fs/promises.FileHandle: an owned descriptor object. Module provenance
|
|
1445
|
+
// distinguishes it from user interfaces with the same name; both the
|
|
1446
|
+
// fallback and @types/node declare it in "fs/promises".
|
|
1447
|
+
if (psym?.name === "FileHandle" &&
|
|
1448
|
+
checker.declarationsOf(psym).some((d) => ts.isInterfaceDeclaration(d) &&
|
|
1449
|
+
ctx.isStdlibFile(d.getSourceFile()) &&
|
|
1450
|
+
isDeclaredInAmbientModule(d, "fs/promises"))) {
|
|
1451
|
+
return { kind: "fileHandle" };
|
|
1452
|
+
}
|
|
1386
1453
|
// child_process.SpawnSyncReturns: @types/node's generic interface (the
|
|
1387
1454
|
// Buffer/string split is re-checked at the stdout/stderr READ — status
|
|
1388
1455
|
// reads work either way) or the fallback declarations' plain interface.
|
|
@@ -1734,6 +1801,30 @@ function mapTypeInner(type, ctx) {
|
|
|
1734
1801
|
], false, undefined, ["address", "family", "port"]),
|
|
1735
1802
|
};
|
|
1736
1803
|
}
|
|
1804
|
+
// fs/promises FileReadResult<T> / FileWriteResult<T>: the two-field
|
|
1805
|
+
// null-prototype objects returned by FileHandle.read/write. The native
|
|
1806
|
+
// record does not model the prototype (unobservable through the lowered
|
|
1807
|
+
// surface); it preserves the caller buffer/string by reference.
|
|
1808
|
+
if ((psym?.name === "FileReadResult" || psym?.name === "FileWriteResult") &&
|
|
1809
|
+
checker.declarationsOf(psym).some((d) => ts.isInterfaceDeclaration(d) &&
|
|
1810
|
+
ctx.isStdlibFile(d.getSourceFile()) &&
|
|
1811
|
+
isDeclaredInAmbientModule(d, "fs/promises"))) {
|
|
1812
|
+
const args = checker.getTypeArguments(widened);
|
|
1813
|
+
if (args.length !== 1)
|
|
1814
|
+
return null;
|
|
1815
|
+
const payload = mapType(args[0], ctx);
|
|
1816
|
+
if (!payload || !(payload.kind === "string" || (payload.kind === "bytes" && payload.elem === "u8"))) {
|
|
1817
|
+
return null;
|
|
1818
|
+
}
|
|
1819
|
+
const count = psym.name === "FileReadResult" ? "bytesRead" : "bytesWritten";
|
|
1820
|
+
return {
|
|
1821
|
+
kind: "record",
|
|
1822
|
+
shapeId: ctx.shapes.intern([
|
|
1823
|
+
{ name: "buffer", type: payload },
|
|
1824
|
+
{ name: count, type: F64 },
|
|
1825
|
+
], false, undefined, [count, "buffer"]),
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1737
1828
|
// fs.Dirent (readdirSync's withFileTypes rows): interned explicitly on
|
|
1738
1829
|
// the AddressInfo pattern. The VISIBLE fields are Node's own keys (name,
|
|
1739
1830
|
// parentPath — Object.keys order matches Node via declaredOrder); the
|
|
@@ -2152,7 +2243,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2152
2243
|
// arms map: `x instanceof RegExp` is their narrowing test
|
|
2153
2244
|
// (the skip-utility `string | RegExp` shape), and the arm
|
|
2154
2245
|
// rides the ref machinery like array regex elements.
|
|
2155
|
-
a.kind === "map" || a.kind === "set" || a.kind === "dyn" ||
|
|
2246
|
+
a.kind === "map" || a.kind === "set" || a.kind === "date" || a.kind === "dyn" ||
|
|
2156
2247
|
// Generator arms follow the map/set rule: no narrowing test.
|
|
2157
2248
|
a.kind === "generator" ||
|
|
2158
2249
|
// Func arms map beside ANY sibling: `typeof x === "function"`
|
|
@@ -2476,7 +2567,7 @@ export function unitOnlyUnion(unions) {
|
|
|
2476
2567
|
* `.return()`, `.throw()`, the for-of desugar, and mapType's
|
|
2477
2568
|
* IteratorResult alias mapping all intern through here, so reads agree.
|
|
2478
2569
|
* Null when the combined union would be illegal (a func/set arm beside
|
|
2479
|
-
* data arms, a map/regex arm — kinds with no narrowing test): such
|
|
2570
|
+
* data arms, a map/regex/Date arm — kinds with no narrowing test): such
|
|
2480
2571
|
* generators stay unmapped. */
|
|
2481
2572
|
export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
2482
2573
|
let valueT;
|
|
@@ -2493,7 +2584,8 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2493
2584
|
byKey.set(typeKey(a), a);
|
|
2494
2585
|
return true;
|
|
2495
2586
|
}
|
|
2496
|
-
if (t.kind === "map" || t.kind === "regex" || t.kind === "
|
|
2587
|
+
if (t.kind === "map" || t.kind === "regex" || t.kind === "date" ||
|
|
2588
|
+
t.kind === "jsval" || t.kind === "generator") {
|
|
2497
2589
|
return false; // no legal union arm exists for these kinds
|
|
2498
2590
|
}
|
|
2499
2591
|
byKey.set(typeKey(t), t);
|
|
@@ -2539,7 +2631,7 @@ export function isUnitOnlyTsType(t) {
|
|
|
2539
2631
|
}
|
|
2540
2632
|
/** IR-level `t | undefined`, canonicalized and fenced exactly like the
|
|
2541
2633
|
* ts-union branch of mapType (typeKey-sorted arms, deduplicated; map/
|
|
2542
|
-
* regex/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
2634
|
+
* regex/Date/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
2543
2635
|
* result is exactly the nullable-callback shape mapType's union branch
|
|
2544
2636
|
* admits, `(() => void) | undefined`) so the interned union is IDENTICAL
|
|
2545
2637
|
* to what mapping the checker's own `T | undefined` produces. */
|
|
@@ -2548,13 +2640,15 @@ export function withUndefinedArm(t, unions) {
|
|
|
2548
2640
|
const def = unions.get(t.unionId);
|
|
2549
2641
|
if (!def)
|
|
2550
2642
|
return null;
|
|
2643
|
+
if (def.arms.some((a) => a.kind === "date"))
|
|
2644
|
+
return null;
|
|
2551
2645
|
if (def.arms.some((a) => a.kind === "undefinedT"))
|
|
2552
2646
|
return t;
|
|
2553
2647
|
const arms = [...def.arms, UNDEFINED_T];
|
|
2554
2648
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2555
2649
|
return { kind: "union", unionId: unions.intern(arms) };
|
|
2556
2650
|
}
|
|
2557
|
-
if (t.kind === "void" || t.kind === "map" || t.kind === "dyn" ||
|
|
2651
|
+
if (t.kind === "void" || t.kind === "map" || t.kind === "date" || t.kind === "dyn" ||
|
|
2558
2652
|
// A bare unit field type cannot occur (units live only inside unions),
|
|
2559
2653
|
// but guard against constructing a single-arm union from one.
|
|
2560
2654
|
isUnitType(t)) {
|
|
@@ -3075,6 +3169,7 @@ function armHasUnionHome(arm, siblingCount) {
|
|
|
3075
3169
|
case "map":
|
|
3076
3170
|
case "set":
|
|
3077
3171
|
case "regex":
|
|
3172
|
+
case "date":
|
|
3078
3173
|
case "generator":
|
|
3079
3174
|
case "dyn":
|
|
3080
3175
|
return false;
|