@scriptc/compiler 0.0.21 → 0.0.23
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 +117 -37
- package/dist/backend/cc-cache.test.d.ts +1 -0
- package/dist/backend/cc-cache.test.js +2507 -0
- package/dist/backend/cc-cache.test.js.map +1 -0
- package/dist/backend/cc.d.ts +69 -11
- package/dist/backend/cc.js +1937 -222
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/emission/emit-async.js +3 -1
- 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 +482 -18
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-stmts.js +13 -5
- package/dist/backend/emission/emit-stmts.js.map +1 -1
- package/dist/backend/emission/emit-types.js +4 -1
- package/dist/backend/emission/emit-types.js.map +1 -1
- package/dist/backend/emission/emit-walkers.js +108 -7
- package/dist/backend/emission/emit-walkers.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +27 -1
- package/dist/backend/emission/emitter.js +84 -3
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +1 -0
- package/dist/backend/llvm/dyn.js +305 -8
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +831 -23
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.js +3 -2
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +118 -0
- package/dist/compat/fetch-profile.js +531 -0
- package/dist/compat/fetch-profile.js.map +1 -0
- package/dist/coverage/surface-manifest.js +69 -0
- 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 +24 -15
- package/dist/frontend/lowering/lower-builtins.js +217 -69
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +41 -0
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +32 -11
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +3 -3
- package/dist/frontend/lowering/lower-exprs.js +87 -15
- 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-island.d.ts +123 -7
- package/dist/frontend/lowering/lower-island.js +1976 -26
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +17 -1
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +33 -9
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +40 -0
- package/dist/frontend/lowering/lowerer.js +290 -18
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +55 -12
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/program.d.ts +20 -4
- package/dist/frontend/program.js +391 -49
- 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 +16 -9
- package/dist/frontend/types.js +119 -38
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +70 -14
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +55 -26
- package/dist/ir/nodes.js +42 -29
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +106 -9
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/int-infer.js +7 -1
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +80 -0
- package/dist/library/int-infer.test.js.map +1 -1
- package/dist/library/sidecar-validate.js +5 -0
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.d.ts +3 -0
- package/dist/library/sidecar.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +1097 -130
|
@@ -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,yBAAyB,CAAC;AAEjC,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,aAAa,EACb,WAAW,EACX,SAAS,EACT,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C;;;qCAGqC;AACrC,SAAS,cAAc,CAAI,QAAgB,EAAE,GAAW;IACtD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC;IACxE,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,KAAK,CAAC,CAAsB,CAAC;IAC/F,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,kBAAkB,GAAG,EAAE,CAAC,CAAC;IACpG,OAAO,KAAK,CAAC;AACf,CAAC;AAiBD,MAAM,CAAC,MAAM,oBAAoB,GAC/B,cAAc,CAA2B,sBAAsB,EAAE,sBAAsB,CAAC,CAAC;AAW3F,MAAM,CAAC,MAAM,mBAAmB,GAC9B,cAAc,CAA0B,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;AAGxF;;;4CAG4C;AAC5C,MAAM,UAAU,SAAS,CAAC,UAAoD,EAAE,KAAa;IAC3F,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC"}
|
|
@@ -18,7 +18,7 @@ import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
|
18
18
|
import { dirname, join, resolve } from "node:path";
|
|
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
|
+
{"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,mBAAmB,EAAE,UAAU,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAQxC;;kCAEkC;AAClC,SAAS,gBAAgB,CAAC,OAA2B;IACnD,MAAM,GAAG,GAA4B,EAAE,C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C;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
|
@@ -2,13 +2,15 @@ import * as ts from "./ts7/adapter.js";
|
|
|
2
2
|
import type { IrRecordShape, IrType, IrUnionDef } from "../ir/nodes.js";
|
|
3
3
|
import { typeKey } from "../ir/nodes.js";
|
|
4
4
|
export { typeKey };
|
|
5
|
-
/** The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
5
|
+
/** The ambient TYPE names of the fetch slice. Under --dynamic their
|
|
6
|
+
* values live in the embedded engine and map to island handles (jsval).
|
|
7
|
+
* Static fetch gives Response, RequestInit, AbortController/AbortSignal, response
|
|
8
|
+
* Headers, and the readable Web Streams slice native checked-dynamic
|
|
9
|
+
* handle representations. The Headers constructor itself remains
|
|
10
|
+
* dynamic-only even though response.headers is native.
|
|
11
|
+
* Declaration provenance is checked in mapType so user types with the
|
|
12
|
+
* same names keep their ordinary structural representation. */
|
|
13
|
+
export declare const ISLAND_AMBIENT_TYPES: readonly ["Response", "ResponseInit", "RequestInit", "Event", "EventTarget", "AbortController", "AbortSignal", "Headers", "ReadableStream", "ReadableStreamDefaultReader", "ReadableStreamDefaultController", "ReadableStreamReadResult", "ReadableStreamReadValueResult", "ReadableStreamReadDoneResult"];
|
|
12
14
|
/** The frontend's record-shape interner. Records are monomorphic structural
|
|
13
15
|
* shapes: fields sorted by name form the canonical identity, and two types
|
|
14
16
|
* with the same canonical field list share one shapeId (and later one C
|
|
@@ -215,6 +217,11 @@ export interface TypeMapperCtx {
|
|
|
215
217
|
* under --dynamic: the package's implementation runs in the embedded
|
|
216
218
|
* engine, so its values are island handles. */
|
|
217
219
|
isNpmFile: (sf: ts.SourceFile) => boolean;
|
|
220
|
+
/** True for a declaration file explicitly mapped by coverage's
|
|
221
|
+
* --external-types option. These declarations are trusted as structural
|
|
222
|
+
* type descriptions for project-owned values, but their imported runtime
|
|
223
|
+
* bindings are fenced separately by the Lowerer. */
|
|
224
|
+
isExternalTypeFile: (sf: ts.SourceFile) => boolean;
|
|
218
225
|
/** --dynamic: `any` maps to the island handle type (jsval). Off, `any`
|
|
219
226
|
* stays unmapped and the requires-dynamic diagnostic fires per site. */
|
|
220
227
|
dynamic: boolean;
|
|
@@ -272,7 +279,7 @@ export declare function unitOnlyUnion(unions: UnionRegistry): IrType;
|
|
|
272
279
|
* `.return()`, `.throw()`, the for-of desugar, and mapType's
|
|
273
280
|
* IteratorResult alias mapping all intern through here, so reads agree.
|
|
274
281
|
* Null when the combined union would be illegal (a func/set arm beside
|
|
275
|
-
* data arms, a map/regex arm — kinds with no narrowing test): such
|
|
282
|
+
* data arms, a map/regex/Date arm — kinds with no narrowing test): such
|
|
276
283
|
* generators stay unmapped. */
|
|
277
284
|
export declare function genResultRecord(yieldT: IrType, retT: IrType, shapes: ShapeRegistry, unions: UnionRegistry): (IrType & {
|
|
278
285
|
kind: "record";
|
|
@@ -286,7 +293,7 @@ export declare function genResultRecord(yieldT: IrType, retT: IrType, shapes: Sh
|
|
|
286
293
|
export declare function isUnitOnlyTsType(t: ts.Type): boolean;
|
|
287
294
|
/** IR-level `t | undefined`, canonicalized and fenced exactly like the
|
|
288
295
|
* ts-union branch of mapType (typeKey-sorted arms, deduplicated; map/
|
|
289
|
-
* regex/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
296
|
+
* regex/Date/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
290
297
|
* result is exactly the nullable-callback shape mapType's union branch
|
|
291
298
|
* admits, `(() => void) | undefined`) so the interned union is IDENTICAL
|
|
292
299
|
* to what mapping the checker's own `T | undefined` produces. */
|
package/dist/frontend/types.js
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
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
|
|
6
6
|
// helper interning); re-exported here so frontend call sites keep their
|
|
7
7
|
// import path.
|
|
8
8
|
export { typeKey };
|
|
9
|
-
/** The
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
9
|
+
/** The ambient TYPE names of the fetch slice. Under --dynamic their
|
|
10
|
+
* values live in the embedded engine and map to island handles (jsval).
|
|
11
|
+
* Static fetch gives Response, RequestInit, AbortController/AbortSignal, response
|
|
12
|
+
* Headers, and the readable Web Streams slice native checked-dynamic
|
|
13
|
+
* handle representations. The Headers constructor itself remains
|
|
14
|
+
* dynamic-only even though response.headers is native.
|
|
15
|
+
* Declaration provenance is checked in mapType so user types with the
|
|
16
|
+
* same names keep their ordinary structural representation. */
|
|
17
|
+
export const ISLAND_AMBIENT_TYPES = [
|
|
18
|
+
"Response",
|
|
19
|
+
"ResponseInit",
|
|
20
|
+
"RequestInit",
|
|
21
|
+
"Event",
|
|
22
|
+
"EventTarget",
|
|
23
|
+
"AbortController",
|
|
24
|
+
"AbortSignal",
|
|
25
|
+
"Headers",
|
|
26
|
+
"ReadableStream",
|
|
27
|
+
"ReadableStreamDefaultReader",
|
|
28
|
+
"ReadableStreamDefaultController",
|
|
29
|
+
"ReadableStreamReadResult",
|
|
30
|
+
"ReadableStreamReadValueResult",
|
|
31
|
+
"ReadableStreamReadDoneResult",
|
|
32
|
+
];
|
|
16
33
|
/** The frontend's record-shape interner. Records are monomorphic structural
|
|
17
34
|
* shapes: fields sorted by name form the canonical identity, and two types
|
|
18
35
|
* with the same canonical field list share one shapeId (and later one C
|
|
@@ -315,6 +332,8 @@ export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
|
315
332
|
return "any";
|
|
316
333
|
case "regex":
|
|
317
334
|
return "RegExp";
|
|
335
|
+
case "date":
|
|
336
|
+
return "Date";
|
|
318
337
|
case "url":
|
|
319
338
|
return "URL";
|
|
320
339
|
case "searchParams":
|
|
@@ -729,17 +748,19 @@ function mapTypeInner(type, ctx) {
|
|
|
729
748
|
// rule fires only when the type's own identity is declaration-file-
|
|
730
749
|
// declared — interfaces, classes, type literals, and aliases from the
|
|
731
750
|
// .d.ts. The standard library's declaration files are carved out (their
|
|
732
|
-
// surfaces have static lowerings),
|
|
733
|
-
//
|
|
734
|
-
//
|
|
735
|
-
//
|
|
751
|
+
// surfaces have static lowerings), as are declarations explicitly mapped
|
|
752
|
+
// by --external-types: those describe project-owned structural data while
|
|
753
|
+
// the Lowerer fences their imported runtime bindings. The program's own
|
|
754
|
+
// compiled modules are never declaration files. Without --dynamic this
|
|
755
|
+
// stays unmapped; badType reports the per-package requires-dynamic
|
|
756
|
+
// diagnostic for node_modules types and the generic story otherwise.
|
|
736
757
|
const npmSym = widened.getAliasSymbol() ?? widened.getSymbol();
|
|
737
758
|
const npmDecls = npmSym ? checker.declarationsOf(npmSym) : undefined;
|
|
738
759
|
if (npmDecls &&
|
|
739
760
|
npmDecls.length > 0 &&
|
|
740
761
|
npmDecls.every((d) => {
|
|
741
762
|
const sf = d.getSourceFile();
|
|
742
|
-
return sf.isDeclarationFile && !ctx.isStdlibFile(sf);
|
|
763
|
+
return sf.isDeclarationFile && !ctx.isStdlibFile(sf) && !ctx.isExternalTypeFile(sf);
|
|
743
764
|
})) {
|
|
744
765
|
return ctx.dynamic ? JSVAL : null;
|
|
745
766
|
}
|
|
@@ -767,7 +788,9 @@ function mapTypeInner(type, ctx) {
|
|
|
767
788
|
// declarations intern one immortal closure, and inner closures are
|
|
768
789
|
// allocated once at their definition's evaluation and flow by
|
|
769
790
|
// reference, exactly JS's function identity. map/set/regex/url/dyn and
|
|
770
|
-
// the other opaque
|
|
791
|
+
// Date (scalar-backed but identity-bearing in JS) and the other opaque
|
|
792
|
+
// handles stay unsupported as array elements; ordinary Date locals,
|
|
793
|
+
// params, fixed record/tuple fields, and promise payloads are supported.
|
|
771
794
|
if (checker.isArrayType(widened)) {
|
|
772
795
|
const elemTs = checker.getTypeArguments(widened)[0];
|
|
773
796
|
if (!elemTs)
|
|
@@ -797,6 +820,7 @@ function mapTypeInner(type, ctx) {
|
|
|
797
820
|
// JS object identity for RegExp values.
|
|
798
821
|
if (!elem ||
|
|
799
822
|
elem.kind === "void" ||
|
|
823
|
+
elem.kind === "date" ||
|
|
800
824
|
elem.kind === "map" ||
|
|
801
825
|
elem.kind === "set" ||
|
|
802
826
|
elem.kind === "url" ||
|
|
@@ -1188,23 +1212,57 @@ function mapTypeInner(type, ctx) {
|
|
|
1188
1212
|
// read has its own lowering (errno/syscall/path stay per-member fences).
|
|
1189
1213
|
if (isStdlibInterface("ErrnoException"))
|
|
1190
1214
|
return { kind: "object", className: "%Error" };
|
|
1191
|
-
// The fetch ambient slice
|
|
1192
|
-
//
|
|
1193
|
-
//
|
|
1194
|
-
//
|
|
1195
|
-
//
|
|
1196
|
-
//
|
|
1197
|
-
//
|
|
1198
|
-
//
|
|
1199
|
-
//
|
|
1200
|
-
// for a bare value of the type).
|
|
1215
|
+
// The fetch ambient slice: under --dynamic these are island handles
|
|
1216
|
+
// exactly like npm-declared types. Static fetch has one deliberately
|
|
1217
|
+
// narrower native representation: Response is an opaque checked-
|
|
1218
|
+
// dynamic capsule consumed only by the Response method lowerings, and
|
|
1219
|
+
// RequestInit is a checked-dynamic options object consumed by native
|
|
1220
|
+
// fetch. AbortSignal, response Headers, and the readable Web Streams
|
|
1221
|
+
// slice are native handles carried by that same checked-dynamic
|
|
1222
|
+
// representation. Provenance, not names: a user's own `interface
|
|
1223
|
+
// Response` maps as a record like any other.
|
|
1201
1224
|
// Interface OR class declarations (the shipped fallback declares
|
|
1202
1225
|
// interfaces; @types/node's undici-types declares Response as a class).
|
|
1226
|
+
{
|
|
1227
|
+
const alias = widened.getAliasSymbol();
|
|
1228
|
+
if (!ctx.dynamic &&
|
|
1229
|
+
alias?.name === "ReadableStreamReadResult" &&
|
|
1230
|
+
checker.declarationsOf(alias).some((d) => ts.isTypeAliasDeclaration(d) &&
|
|
1231
|
+
ctx.isStdlibFile(d.getSourceFile()))) {
|
|
1232
|
+
const elemTs = widened.getAliasTypeArguments()?.[0];
|
|
1233
|
+
const elem = elemTs && elemTs.flags & ts.TypeFlags.Any
|
|
1234
|
+
? DYN
|
|
1235
|
+
: elemTs
|
|
1236
|
+
? mapType(elemTs, ctx)
|
|
1237
|
+
: null;
|
|
1238
|
+
if (!elem)
|
|
1239
|
+
return null;
|
|
1240
|
+
return genResultRecord(elem, VOID, ctx.shapes, ctx.unions);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
if (!ctx.dynamic &&
|
|
1244
|
+
psym &&
|
|
1245
|
+
(psym.name === "ReadableStreamReadValueResult" ||
|
|
1246
|
+
psym.name === "ReadableStreamReadDoneResult") &&
|
|
1247
|
+
checker.declarationsOf(psym).some((d) => ts.isInterfaceDeclaration(d) &&
|
|
1248
|
+
ctx.isStdlibFile(d.getSourceFile()))) {
|
|
1249
|
+
const elemTs = checker.getTypeArguments(widened)[0];
|
|
1250
|
+
const elem = elemTs && elemTs.flags & ts.TypeFlags.Any
|
|
1251
|
+
? DYN
|
|
1252
|
+
: elemTs
|
|
1253
|
+
? mapType(elemTs, ctx)
|
|
1254
|
+
: null;
|
|
1255
|
+
if (!elem)
|
|
1256
|
+
return null;
|
|
1257
|
+
return genResultRecord(elem, VOID, ctx.shapes, ctx.unions);
|
|
1258
|
+
}
|
|
1203
1259
|
if (psym &&
|
|
1204
1260
|
ISLAND_AMBIENT_TYPES.includes(psym.name) &&
|
|
1261
|
+
!(psym.name === "ReadableStream" &&
|
|
1262
|
+
checker.declarationsOf(psym).some((d) => ts.isInterfaceDeclaration(d) && isDeclaredInAmbientNamespace(d, "NodeJS"))) &&
|
|
1205
1263
|
checker.declarationsOf(psym).some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
|
|
1206
1264
|
ctx.isStdlibFile(d.getSourceFile()))) {
|
|
1207
|
-
return ctx.dynamic ? JSVAL :
|
|
1265
|
+
return ctx.dynamic ? JSVAL : DYN;
|
|
1208
1266
|
}
|
|
1209
1267
|
// ReadonlyMap/ReadonlySet are the SAME runtime values as Map/Set — the
|
|
1210
1268
|
// readonly-ness is a checker-only view (no mutating members on the
|
|
@@ -1234,6 +1292,12 @@ function mapTypeInner(type, ctx) {
|
|
|
1234
1292
|
return null;
|
|
1235
1293
|
return setOf(elem);
|
|
1236
1294
|
}
|
|
1295
|
+
// Date: a TimeClip'd epoch-millisecond scalar in the static runtime.
|
|
1296
|
+
// This supports stored/passed values and the read-only getter slice;
|
|
1297
|
+
// identity and mutation stay fenced because the scalar deliberately
|
|
1298
|
+
// carries no object identity.
|
|
1299
|
+
if (isStdlibInterface("Date"))
|
|
1300
|
+
return DATE_T;
|
|
1237
1301
|
// RegExp: a reference to the lib RegExp interface — provenance, not the
|
|
1238
1302
|
// name (a user's own `interface RegExp` maps as a record). Regex values
|
|
1239
1303
|
// are literals interned as immortal statics; the kind is fenced out of
|
|
@@ -2101,7 +2165,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2101
2165
|
// arms map: `x instanceof RegExp` is their narrowing test
|
|
2102
2166
|
// (the skip-utility `string | RegExp` shape), and the arm
|
|
2103
2167
|
// rides the ref machinery like array regex elements.
|
|
2104
|
-
a.kind === "map" || a.kind === "set" || a.kind === "dyn" ||
|
|
2168
|
+
a.kind === "map" || a.kind === "set" || a.kind === "date" || a.kind === "dyn" ||
|
|
2105
2169
|
// Generator arms follow the map/set rule: no narrowing test.
|
|
2106
2170
|
a.kind === "generator" ||
|
|
2107
2171
|
// Func arms map beside ANY sibling: `typeof x === "function"`
|
|
@@ -2425,7 +2489,7 @@ export function unitOnlyUnion(unions) {
|
|
|
2425
2489
|
* `.return()`, `.throw()`, the for-of desugar, and mapType's
|
|
2426
2490
|
* IteratorResult alias mapping all intern through here, so reads agree.
|
|
2427
2491
|
* Null when the combined union would be illegal (a func/set arm beside
|
|
2428
|
-
* data arms, a map/regex arm — kinds with no narrowing test): such
|
|
2492
|
+
* data arms, a map/regex/Date arm — kinds with no narrowing test): such
|
|
2429
2493
|
* generators stay unmapped. */
|
|
2430
2494
|
export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
2431
2495
|
let valueT;
|
|
@@ -2442,7 +2506,8 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2442
2506
|
byKey.set(typeKey(a), a);
|
|
2443
2507
|
return true;
|
|
2444
2508
|
}
|
|
2445
|
-
if (t.kind === "map" || t.kind === "regex" || t.kind === "
|
|
2509
|
+
if (t.kind === "map" || t.kind === "regex" || t.kind === "date" ||
|
|
2510
|
+
t.kind === "jsval" || t.kind === "generator") {
|
|
2446
2511
|
return false; // no legal union arm exists for these kinds
|
|
2447
2512
|
}
|
|
2448
2513
|
byKey.set(typeKey(t), t);
|
|
@@ -2488,7 +2553,7 @@ export function isUnitOnlyTsType(t) {
|
|
|
2488
2553
|
}
|
|
2489
2554
|
/** IR-level `t | undefined`, canonicalized and fenced exactly like the
|
|
2490
2555
|
* ts-union branch of mapType (typeKey-sorted arms, deduplicated; map/
|
|
2491
|
-
* regex/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
2556
|
+
* regex/Date/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
2492
2557
|
* result is exactly the nullable-callback shape mapType's union branch
|
|
2493
2558
|
* admits, `(() => void) | undefined`) so the interned union is IDENTICAL
|
|
2494
2559
|
* to what mapping the checker's own `T | undefined` produces. */
|
|
@@ -2497,13 +2562,15 @@ export function withUndefinedArm(t, unions) {
|
|
|
2497
2562
|
const def = unions.get(t.unionId);
|
|
2498
2563
|
if (!def)
|
|
2499
2564
|
return null;
|
|
2565
|
+
if (def.arms.some((a) => a.kind === "date"))
|
|
2566
|
+
return null;
|
|
2500
2567
|
if (def.arms.some((a) => a.kind === "undefinedT"))
|
|
2501
2568
|
return t;
|
|
2502
2569
|
const arms = [...def.arms, UNDEFINED_T];
|
|
2503
2570
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2504
2571
|
return { kind: "union", unionId: unions.intern(arms) };
|
|
2505
2572
|
}
|
|
2506
|
-
if (t.kind === "void" || t.kind === "map" || t.kind === "dyn" ||
|
|
2573
|
+
if (t.kind === "void" || t.kind === "map" || t.kind === "date" || t.kind === "dyn" ||
|
|
2507
2574
|
// A bare unit field type cannot occur (units live only inside unions),
|
|
2508
2575
|
// but guard against constructing a single-arm union from one.
|
|
2509
2576
|
isUnitType(t)) {
|
|
@@ -2576,15 +2643,17 @@ function isMappedShape(t) {
|
|
|
2576
2643
|
(t.objectFlags & ts.ObjectFlags.Mapped) !== 0);
|
|
2577
2644
|
}
|
|
2578
2645
|
/** The record path's provenance fence. Declared shapes (object literals,
|
|
2579
|
-
* interfaces, type literals) must come from user code
|
|
2580
|
-
*
|
|
2646
|
+
* interfaces, type literals) must come from user code or an explicitly
|
|
2647
|
+
* mapped external type surface, never an arbitrary .d.ts — the empty
|
|
2648
|
+
* ambient interfaces (Object, Function, Boolean, ...) exist only to
|
|
2581
2649
|
* satisfy tsc and must not become zero-field records. Checker-COMPUTED
|
|
2582
2650
|
* shapes (mapped-type results, intersections) have no user declaration to
|
|
2583
2651
|
* point at: mapped types pass here and get per-MEMBER provenance in the
|
|
2584
2652
|
* field walk instead; an intersection passes when every part is itself an
|
|
2585
2653
|
* ordinary provenance-passing object type (class parts keep their nominal
|
|
2586
2654
|
* identity and never flatten into a struct). */
|
|
2587
|
-
function recordProvenanceOk(t,
|
|
2655
|
+
function recordProvenanceOk(t, ctx) {
|
|
2656
|
+
const { checker } = ctx;
|
|
2588
2657
|
if (t.isIntersectionType()) {
|
|
2589
2658
|
return t.getTypes().every((part) => {
|
|
2590
2659
|
const partSym = part.getSymbol();
|
|
@@ -2592,7 +2661,7 @@ function recordProvenanceOk(t, checker) {
|
|
|
2592
2661
|
!(partSym && partSym.flags & ts.SymbolFlags.Class) &&
|
|
2593
2662
|
checker.getCallSignatures(part).length === 0 &&
|
|
2594
2663
|
checker.getConstructSignatures(part).length === 0 &&
|
|
2595
|
-
recordProvenanceOk(part,
|
|
2664
|
+
recordProvenanceOk(part, ctx);
|
|
2596
2665
|
});
|
|
2597
2666
|
}
|
|
2598
2667
|
if (isMappedShape(t))
|
|
@@ -2601,7 +2670,10 @@ function recordProvenanceOk(t, checker) {
|
|
|
2601
2670
|
const decls = tSym ? checker.declarationsOf(tSym) : undefined;
|
|
2602
2671
|
if (!decls || decls.length === 0)
|
|
2603
2672
|
return false;
|
|
2604
|
-
return !decls.some((d) =>
|
|
2673
|
+
return !decls.some((d) => {
|
|
2674
|
+
const sf = d.getSourceFile();
|
|
2675
|
+
return sf.isDeclarationFile && !ctx.isExternalTypeFile(sf);
|
|
2676
|
+
});
|
|
2605
2677
|
}
|
|
2606
2678
|
/** A GENERIC-callable member type (`m<T>(x: T): T` / `f: <T>(x: T) => T` in
|
|
2607
2679
|
* an object type): pure function-shaped — call signatures only, every one
|
|
@@ -2793,7 +2865,7 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
2793
2865
|
!widened.isIntersectionType() &&
|
|
2794
2866
|
indexValue === undefined &&
|
|
2795
2867
|
checker.getPropertiesOfType(widened).length === 0;
|
|
2796
|
-
if (!recordProvenanceOk(widened,
|
|
2868
|
+
if (!recordProvenanceOk(widened, ctx) && !pureIndexShape && !anonymousEmpty)
|
|
2797
2869
|
return null;
|
|
2798
2870
|
// Checker-computed shapes (no user declaration) need two extra fences in
|
|
2799
2871
|
// the member walk below; see the comments there.
|
|
@@ -2895,7 +2967,11 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
2895
2967
|
// lib interface (`Readonly<Date>`) is still the lib's type world, not
|
|
2896
2968
|
// a data shape. Synthesized members (a literal-key Record's) have no
|
|
2897
2969
|
// declarations and pass.
|
|
2898
|
-
if (computed &&
|
|
2970
|
+
if (computed &&
|
|
2971
|
+
checker.declarationsOf(p).some((d) => {
|
|
2972
|
+
const sf = d.getSourceFile();
|
|
2973
|
+
return sf.isDeclarationFile && !ctx.isExternalTypeFile(sf);
|
|
2974
|
+
})) {
|
|
2899
2975
|
return null;
|
|
2900
2976
|
}
|
|
2901
2977
|
const fieldTs = checker.getTypeOfSymbol(p);
|
|
@@ -3015,6 +3091,7 @@ function armHasUnionHome(arm, siblingCount) {
|
|
|
3015
3091
|
case "map":
|
|
3016
3092
|
case "set":
|
|
3017
3093
|
case "regex":
|
|
3094
|
+
case "date":
|
|
3018
3095
|
case "generator":
|
|
3019
3096
|
case "dyn":
|
|
3020
3097
|
return false;
|
|
@@ -3192,7 +3269,11 @@ export function describeRecordMemberBlocker(widened, ctx) {
|
|
|
3192
3269
|
// Computed shapes over LIBRARY members (`Readonly<Date>`): the record
|
|
3193
3270
|
// fence there is per-member PROVENANCE (mapRecordTypeInner's rule), not
|
|
3194
3271
|
// any one member's type — that story stays with the residual fence.
|
|
3195
|
-
if (computed &&
|
|
3272
|
+
if (computed &&
|
|
3273
|
+
checker.declarationsOf(p).some((d) => {
|
|
3274
|
+
const sf = d.getSourceFile();
|
|
3275
|
+
return sf.isDeclarationFile && !ctx.isExternalTypeFile(sf);
|
|
3276
|
+
})) {
|
|
3196
3277
|
return null;
|
|
3197
3278
|
}
|
|
3198
3279
|
const fieldTs = checker.getTypeOfSymbol(p);
|