@scriptc/compiler 0.1.2 → 0.1.4
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 +258 -64
- package/dist/backend/c/async.d.ts +30 -0
- package/dist/backend/c/async.js +224 -0
- package/dist/backend/c/async.js.map +1 -1
- package/dist/backend/c/c-emitter.d.ts +13 -0
- package/dist/backend/c/c-emitter.js +28 -9
- package/dist/backend/c/c-emitter.js.map +1 -1
- package/dist/backend/c/exprs.d.ts +8 -1
- package/dist/backend/c/exprs.js +445 -60
- package/dist/backend/c/exprs.js.map +1 -1
- package/dist/backend/c/shapes.js +15 -13
- package/dist/backend/c/shapes.js.map +1 -1
- package/dist/backend/c/types.d.ts +4 -0
- package/dist/backend/c/types.js +20 -1
- package/dist/backend/c/types.js.map +1 -1
- package/dist/backend/c/types.test.js +8 -1
- package/dist/backend/c/types.test.js.map +1 -1
- package/dist/backend/c/walkers.js +32 -11
- package/dist/backend/c/walkers.js.map +1 -1
- package/dist/backend/json-literal.d.ts +7 -0
- package/dist/backend/json-literal.js +17 -0
- package/dist/backend/json-literal.js.map +1 -0
- package/dist/backend/json-literal.test.d.ts +1 -0
- package/dist/backend/json-literal.test.js +17 -0
- package/dist/backend/json-literal.test.js.map +1 -0
- package/dist/backend/link-plan.d.ts +2 -1
- package/dist/backend/link-plan.js +6 -1
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/classes.js +8 -7
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +4 -0
- package/dist/backend/llvm/common.js +6 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/common.test.d.ts +1 -0
- package/dist/backend/llvm/common.test.js +9 -0
- package/dist/backend/llvm/common.test.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +4 -0
- package/dist/backend/llvm/dyn.js +24 -13
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +54 -12
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +1 -1
- package/dist/backend/llvm/expr-bytes.js +8 -8
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +9 -0
- package/dist/backend/llvm/expr-callbacks.js +125 -0
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +18 -2
- package/dist/backend/llvm/expr-dispatch.js +1 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +9 -0
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +1 -1
- package/dist/backend/llvm/expr-primitives.js +38 -9
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.d.ts +1 -0
- package/dist/backend/llvm/expr-primitives.test.js +38 -0
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -0
- package/dist/backend/llvm/expr-records.js +3 -3
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +2 -1
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +6 -0
- package/dist/backend/llvm/expr-stream-callbacks.js +122 -0
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +22 -0
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +68 -10
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +18 -2
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +206 -11
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +82 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +23 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/shapes.js +10 -8
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/walkers.js +7 -5
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native-link-info.d.ts +2 -1
- package/dist/backend/native-link-info.js +4 -0
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-link-info.test.js +24 -1
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +11 -6
- package/dist/backend/native-toolchain.js +30 -13
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +36 -1
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +29 -10
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/targets.d.ts +9 -0
- package/dist/backend/targets.js +22 -0
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +13 -1
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/coverage/surface-manifest.js +9 -0
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.js +4 -4
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -0
- package/dist/executable/executable-cache.js +4 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +1 -0
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/fork-target.d.ts +17 -0
- package/dist/frontend/fork-target.js +256 -0
- package/dist/frontend/fork-target.js.map +1 -0
- package/dist/frontend/lowering/abstract-equality.d.ts +6 -0
- package/dist/frontend/lowering/abstract-equality.js +250 -0
- package/dist/frontend/lowering/abstract-equality.js.map +1 -0
- package/dist/frontend/lowering/containers/bytes.d.ts +0 -4
- package/dist/frontend/lowering/containers/bytes.js +112 -28
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +87 -12
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +72 -44
- package/dist/frontend/lowering/lower-builtins.js +1323 -165
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +37 -27
- package/dist/frontend/lowering/lower-calls.js +682 -132
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +39 -8
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.js +162 -8
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +212 -21
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +238 -87
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
- package/dist/frontend/lowering/lower-inspect.js +8 -1
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +6 -3
- package/dist/frontend/lowering/lower-island.js +165 -6
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +6 -0
- package/dist/frontend/lowering/lower-modules.js +192 -38
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +7 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +1 -1
- package/dist/frontend/lowering/lower-server.js +130 -27
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +5 -4
- package/dist/frontend/lowering/lower-stmts.js +141 -21
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +3 -0
- package/dist/frontend/lowering/lower-stream.js +7 -0
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +90 -13
- package/dist/frontend/lowering/lowerer.js +416 -76
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +31 -3
- package/dist/frontend/lowering/surfaces.js +173 -90
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm-static-declarations.d.ts +4 -0
- package/dist/frontend/npm-static-declarations.js +83 -14
- package/dist/frontend/npm-static-declarations.js.map +1 -1
- package/dist/frontend/npm-static-declarations.test.js +33 -2
- package/dist/frontend/npm-static-declarations.test.js.map +1 -1
- package/dist/frontend/npm-static.js +6 -5
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +15 -3
- package/dist/frontend/npm.js +80 -8
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +76 -9
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/program.js +110 -12
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.d.ts +28 -7
- package/dist/frontend/resolve.js +90 -26
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.js +21 -1
- package/dist/frontend/resolve.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +5 -0
- package/dist/frontend/type-mapper.js +115 -33
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.js +1 -0
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/ir.d.ts +155 -66
- package/dist/ir/ir.js +143 -6
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +14 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/serialize.d.ts +1 -1
- package/dist/ir/serialize.js +1 -1
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/validate.js +242 -18
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/int-infer.test.js.map +1 -1
- package/dist/library/library-cache.d.ts +1 -0
- package/dist/library/library-cache.js +1 -0
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +18 -5
- package/dist/library/library-cache.test.js.map +1 -1
- package/package.json +17 -17
- package/surface-manifest.json +163 -54
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InternalCompilerError } from "../errors.js";
|
|
2
2
|
import * as ts from "./ts7/adapter.js";
|
|
3
|
-
import { arrayOf, BOOL, bytesOf, canConvertToDyn, CHILD_T, DATE_T, DYN, F64, funcOf, isSupportedArrayElem, 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/ir.js";
|
|
3
|
+
import { arrayOf, BOOL, bytesOf, canConvertToDyn, CHILD_T, CRYPTOHASH_T, CRYPTOHMAC_T, DATE_T, DYN, F64, funcOf, isSupportedArrayElem, 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/ir.js";
|
|
4
|
+
import { BIGINT_T } from "../ir/ir.js";
|
|
4
5
|
import { isJsSourceFile, isNodeTypesPath } from "./program.js";
|
|
5
6
|
import { accessorSlotProp } from "../ir/ir.js";
|
|
6
7
|
// typeKey moved to ir/ir.ts (the backend needs it too, for per-type
|
|
@@ -472,6 +473,8 @@ export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
|
472
473
|
return "URLSearchParams";
|
|
473
474
|
case "symbol":
|
|
474
475
|
return "symbol";
|
|
476
|
+
case "bigint":
|
|
477
|
+
return "bigint";
|
|
475
478
|
case "stats":
|
|
476
479
|
return "Stats";
|
|
477
480
|
case "fileHandle":
|
|
@@ -500,12 +503,20 @@ export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
|
500
503
|
return "ClientRequest";
|
|
501
504
|
case "secureCtx":
|
|
502
505
|
return "SecureContext";
|
|
506
|
+
case "cryptoHash":
|
|
507
|
+
return "Hash";
|
|
508
|
+
case "cryptoHmac":
|
|
509
|
+
return "Hmac";
|
|
503
510
|
case "fsWatcher":
|
|
504
511
|
return "FSWatcher";
|
|
505
512
|
case "childStream":
|
|
506
513
|
return "Readable";
|
|
514
|
+
case "childWriter":
|
|
515
|
+
return "Writable";
|
|
507
516
|
case "procStream":
|
|
508
517
|
return "WriteStream";
|
|
518
|
+
case "moduleNs":
|
|
519
|
+
return `module namespace '${t.moduleId}'`;
|
|
509
520
|
case "promise":
|
|
510
521
|
return `Promise<${formatIrType(t.inner, shapes, unions, seen)}>`;
|
|
511
522
|
case "generator":
|
|
@@ -728,6 +739,20 @@ function classExprNeverRegisters(decl) {
|
|
|
728
739
|
}
|
|
729
740
|
function mapTypeInner(type, ctx) {
|
|
730
741
|
const { checker, unions, classNamer, resolveTypeParam } = ctx;
|
|
742
|
+
if (!ctx.dynamic) {
|
|
743
|
+
const moduleId = ctx.moduleNamespaceId?.(type) ?? null;
|
|
744
|
+
if (moduleId !== null)
|
|
745
|
+
return { kind: "moduleNs", moduleId };
|
|
746
|
+
}
|
|
747
|
+
// @types/node spells child_process.ExecFileException as an intersection
|
|
748
|
+
// type alias over two Error-derived metadata interfaces. The value is
|
|
749
|
+
// still one ordinary Error; recognize the owned alias before generic
|
|
750
|
+
// intersection mapping decomposes it into unsupported utility types.
|
|
751
|
+
const directAlias = type.getAliasSymbol();
|
|
752
|
+
if (directAlias?.name === "ExecFileException" &&
|
|
753
|
+
checker.declarationsOf(directAlias).some((decl) => ctx.isStdlibFile(decl.getSourceFile()))) {
|
|
754
|
+
return { kind: "object", className: "%Error" };
|
|
755
|
+
}
|
|
731
756
|
if (resolveTypeParam && type.flags & ts.TypeFlags.TypeParameter) {
|
|
732
757
|
const bound = resolveTypeParam(type);
|
|
733
758
|
if (bound) {
|
|
@@ -831,6 +856,8 @@ function mapTypeInner(type, ctx) {
|
|
|
831
856
|
// map to the symbol identity kind.
|
|
832
857
|
if (flags & (ts.TypeFlags.ESSymbol | ts.TypeFlags.UniqueESSymbol))
|
|
833
858
|
return SYMBOL_T;
|
|
859
|
+
if (flags & (ts.TypeFlags.BigInt | ts.TypeFlags.BigIntLiteral))
|
|
860
|
+
return BIGINT_T;
|
|
834
861
|
// STANDALONE undefined (and void) map to VOID: return-type mapping flows
|
|
835
862
|
// through here, and `(): void | undefined` functions must stay void.
|
|
836
863
|
// Inside a union, undefined becomes the undefinedT unit ARM instead (see
|
|
@@ -935,15 +962,11 @@ function mapTypeInner(type, ctx) {
|
|
|
935
962
|
})) {
|
|
936
963
|
return ctx.dynamic ? JSVAL : null;
|
|
937
964
|
}
|
|
938
|
-
//
|
|
939
|
-
//
|
|
940
|
-
//
|
|
941
|
-
//
|
|
942
|
-
//
|
|
943
|
-
// bindings (builtinImportOf), and a handle mapping would reroute
|
|
944
|
-
// `import * as path` member calls into the engine — dynamic imports of
|
|
945
|
-
// builtins get their handles from the import lowering's IR type
|
|
946
|
-
// instead.
|
|
965
|
+
// Module NAMESPACE types (`typeof import("./x.mjs")`) were claimed at
|
|
966
|
+
// the top by moduleNamespaceId when they name a compiled source module
|
|
967
|
+
// or supported builtin in a static build. Declaration-only package
|
|
968
|
+
// namespaces retain the npm rule above; dynamic builds retain their
|
|
969
|
+
// jsval import-handle path.
|
|
947
970
|
// T[]: monomorphic arrays, recursively (number[][] works). An element type
|
|
948
971
|
// that doesn't map (never from a context-free `[]`) makes the whole array
|
|
949
972
|
// unsupported — null propagates. Record/object/union elements ride the
|
|
@@ -1094,7 +1117,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1094
1117
|
// no class identity of its own.
|
|
1095
1118
|
if (widened.isIntersectionType()) {
|
|
1096
1119
|
const HANDLE_KINDS = new Set([
|
|
1097
|
-
"netServer", "netSocket", "httpReq", "httpRes", "httpClientReq", "dgramSocket",
|
|
1120
|
+
"netServer", "netSocket", "httpReq", "httpRes", "httpClientReq", "dgramSocket", "childWriter",
|
|
1098
1121
|
// process.stdout's own type IS the refined intersection
|
|
1099
1122
|
// `WriteStream & { fd: 1 }` — the scalar stream kind rides the same
|
|
1100
1123
|
// refinement rule.
|
|
@@ -1597,11 +1620,16 @@ function mapTypeInner(type, ctx) {
|
|
|
1597
1620
|
ctx.isStdlibFile(d.getSourceFile()))) {
|
|
1598
1621
|
return { kind: "spawnRes" };
|
|
1599
1622
|
}
|
|
1600
|
-
// child_process.ChildProcess
|
|
1601
|
-
//
|
|
1602
|
-
|
|
1623
|
+
// child_process.ChildProcess and @types/node's stdio-refined return
|
|
1624
|
+
// interfaces: all carry the same runtime child handle; the generic
|
|
1625
|
+
// refinements only tell the checker which stdio properties are null.
|
|
1626
|
+
if (psym !== undefined &&
|
|
1627
|
+
(psym.name === "ChildProcess" ||
|
|
1628
|
+
psym.name === "ChildProcessWithoutNullStreams" ||
|
|
1629
|
+
psym.name === "ChildProcessByStdio") &&
|
|
1603
1630
|
checker.declarationsOf(psym).some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
|
|
1604
|
-
ctx.isStdlibFile(d.getSourceFile())
|
|
1631
|
+
ctx.isStdlibFile(d.getSourceFile()) &&
|
|
1632
|
+
isDeclaredInAmbientModule(d, "child_process"))) {
|
|
1605
1633
|
return { kind: "child" };
|
|
1606
1634
|
}
|
|
1607
1635
|
// net.Server / net.Socket: @types/node's classes or the fallback
|
|
@@ -1638,6 +1666,15 @@ function mapTypeInner(type, ctx) {
|
|
|
1638
1666
|
isDeclaredInAmbientModule(d, "tls"))) {
|
|
1639
1667
|
return { kind: "secureCtx" };
|
|
1640
1668
|
}
|
|
1669
|
+
// crypto.Hash / crypto.Hmac: native incremental digest handles. Keep
|
|
1670
|
+
// provenance module-qualified so user classes with these common names
|
|
1671
|
+
// retain their ordinary structural/class representation.
|
|
1672
|
+
if ((psym?.name === "Hash" || psym?.name === "Hmac") &&
|
|
1673
|
+
checker.declarationsOf(psym).some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
|
|
1674
|
+
ctx.isStdlibFile(d.getSourceFile()) &&
|
|
1675
|
+
isDeclaredInAmbientModule(d, "crypto"))) {
|
|
1676
|
+
return psym.name === "Hash" ? CRYPTOHASH_T : CRYPTOHMAC_T;
|
|
1677
|
+
}
|
|
1641
1678
|
// fs.FSWatcher: the fs.watch handle (scr_watch.c). Module-checked like
|
|
1642
1679
|
// net.Server — @types/node declares `interface FSWatcher extends
|
|
1643
1680
|
// EventEmitter` inside `declare module "fs"`, and the shipped fallback
|
|
@@ -1675,6 +1712,21 @@ function mapTypeInner(type, ctx) {
|
|
|
1675
1712
|
isDeclaredInAmbientNamespace(d, "NodeJS")))) {
|
|
1676
1713
|
return PROCSTREAM_T;
|
|
1677
1714
|
}
|
|
1715
|
+
// A piped child stdin writer. The fallback declarations give it the
|
|
1716
|
+
// dedicated ChildStdin name; @types/node spells the same value as
|
|
1717
|
+
// stream.Writable. As with stream.Readable below, unsupported producers
|
|
1718
|
+
// of the broad @types class fence where they are constructed.
|
|
1719
|
+
if ((psym?.name === "ChildStdin" &&
|
|
1720
|
+
checker.declarationsOf(psym).some((d) => ts.isInterfaceDeclaration(d) &&
|
|
1721
|
+
ctx.isStdlibFile(d.getSourceFile()) &&
|
|
1722
|
+
isDeclaredInAmbientModule(d, "child_process"))) ||
|
|
1723
|
+
(psym?.name === "Writable" &&
|
|
1724
|
+
checker.declarationsOf(psym).some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
|
|
1725
|
+
ctx.isStdlibFile(d.getSourceFile()) &&
|
|
1726
|
+
isNodeTypesPath(d.getSourceFile().fileName) &&
|
|
1727
|
+
isDeclaredInAmbientModule(d, "stream")))) {
|
|
1728
|
+
return { kind: "childWriter" };
|
|
1729
|
+
}
|
|
1678
1730
|
// The static node:stream classes (the shipped fallback declarations —
|
|
1679
1731
|
// NOT @types/node, whose stream.Readable also types child stdio; under
|
|
1680
1732
|
// @types/node the childStream mapping below keeps priority and the
|
|
@@ -2136,8 +2188,9 @@ function mapTypeInner(type, ctx) {
|
|
|
2136
2188
|
// the same way — the completed-signature contract: the TYPE spells
|
|
2137
2189
|
// `T | undefined`, the default's VALUE lives in the closure body's own
|
|
2138
2190
|
// prologue (declareParams), and the undefined arm is what triggers it.
|
|
2139
|
-
// Rest parameters keep
|
|
2140
|
-
// as
|
|
2191
|
+
// Rest parameters keep one typed-array ABI slot and mark the function
|
|
2192
|
+
// type as typed-rest. Indirect call sites pack source arguments into that
|
|
2193
|
+
// slot, so the native closure ABI remains fixed-width.
|
|
2141
2194
|
// The chalk-style FUNCTION-WITH-PROPERTIES hybrid: an intersection of
|
|
2142
2195
|
// exactly one callable part with plain data-property parts (`F & { bold:
|
|
2143
2196
|
// F }` — Object.assign(fn, {...})'s type) maps to a RECORD carrying the
|
|
@@ -2178,11 +2231,16 @@ function mapTypeInner(type, ctx) {
|
|
|
2178
2231
|
}
|
|
2179
2232
|
}
|
|
2180
2233
|
const params = [];
|
|
2234
|
+
let typedRest = false;
|
|
2181
2235
|
for (const p of sig.getParameters()) {
|
|
2182
2236
|
const decl = checker.valueDeclarationOf(p);
|
|
2183
|
-
|
|
2237
|
+
const rest = decl !== undefined && ts.isParameter(decl) && decl.dotDotDotToken !== undefined;
|
|
2238
|
+
// JavaScript rest values retain the checked-dynamic/island runtime-
|
|
2239
|
+
// arity ABI selected by lambdaSignature. Treating an inferred any[]
|
|
2240
|
+
// declaration as a typed packed-array closure would bypass its boxed
|
|
2241
|
+
// spread/error semantics and change coverage classification.
|
|
2242
|
+
if (rest && decl !== undefined && isJsSourceFile(decl.getSourceFile()))
|
|
2184
2243
|
return null;
|
|
2185
|
-
}
|
|
2186
2244
|
const optional = decl !== undefined &&
|
|
2187
2245
|
ts.isParameter(decl) &&
|
|
2188
2246
|
(decl.questionToken !== undefined || decl.initializer !== undefined);
|
|
@@ -2198,6 +2256,11 @@ function mapTypeInner(type, ctx) {
|
|
|
2198
2256
|
}
|
|
2199
2257
|
if (!pt)
|
|
2200
2258
|
return null;
|
|
2259
|
+
if (rest) {
|
|
2260
|
+
if (pt.kind !== "array")
|
|
2261
|
+
return null;
|
|
2262
|
+
typedRest = true;
|
|
2263
|
+
}
|
|
2201
2264
|
// `(value: void) => void` (Promise<void>'s resolve) is callable with
|
|
2202
2265
|
// no arguments — a void param is dropped, not a mapping failure.
|
|
2203
2266
|
if (pt.kind === "void")
|
|
@@ -2211,7 +2274,9 @@ function mapTypeInner(type, ctx) {
|
|
|
2211
2274
|
const ret = retT.flags & ts.TypeFlags.Never ? VOID : mapType(retT, ctx);
|
|
2212
2275
|
if (!ret)
|
|
2213
2276
|
return null;
|
|
2214
|
-
return
|
|
2277
|
+
return typedRest
|
|
2278
|
+
? { kind: "func", params, ret, rest: true, restAbi: "typed" }
|
|
2279
|
+
: funcOf(params, ret);
|
|
2215
2280
|
}
|
|
2216
2281
|
// Records: object types whose members are all data properties (shorthand
|
|
2217
2282
|
// methods in type position count — they're func-typed fields) with
|
|
@@ -2237,13 +2302,15 @@ function mapTypeInner(type, ctx) {
|
|
|
2237
2302
|
// NgrokChildProcess idiom — `spawn(...) as NgrokChildProcess`, declared
|
|
2238
2303
|
// so tests can hand in mocks): every member is named on the lowered
|
|
2239
2304
|
// ChildProcess surface AND at least two are the handle-defining ones
|
|
2240
|
-
// (kill/on/stdout/stderr/unref/exitCode — a data record like
|
|
2305
|
+
// (kill/on/stdin/stdout/stderr/unref/exitCode — a data record like
|
|
2241
2306
|
// `{ pid: number }` never qualifies). The TYPE maps to the child
|
|
2242
2307
|
// handle: in a compiled program the only VALUE producer is spawn
|
|
2243
2308
|
// itself (a mock object literal in this slot fences at its
|
|
2244
2309
|
// construction site), and every member the interface may declare is
|
|
2245
|
-
// exactly a lowered child member
|
|
2246
|
-
// interface and lower against the handle.
|
|
2310
|
+
// exactly a lowered child member WITH the corresponding handle type, so
|
|
2311
|
+
// uses typecheck against the interface and lower against the handle.
|
|
2312
|
+
// Names alone are insufficient: a record of stdout/stderr callbacks is
|
|
2313
|
+
// an ordinary data shape, not a child process.
|
|
2247
2314
|
if (flags & ts.TypeFlags.Object &&
|
|
2248
2315
|
callSigs.length === 0 &&
|
|
2249
2316
|
psym !== undefined &&
|
|
@@ -2251,14 +2318,30 @@ function mapTypeInner(type, ctx) {
|
|
|
2251
2318
|
checker.declarationsOf(psym).every((d) => ts.isInterfaceDeclaration(d) && !ctx.isStdlibFile(d.getSourceFile()))) {
|
|
2252
2319
|
const CHILD_SURFACE = new Set([
|
|
2253
2320
|
"pid", "exitCode", "killed", "kill", "on", "once", "off",
|
|
2254
|
-
"removeListener", "unref", "ref", "stdout", "stderr",
|
|
2321
|
+
"removeListener", "unref", "ref", "stdin", "stdout", "stderr",
|
|
2322
|
+
"send", "connected", "disconnect",
|
|
2255
2323
|
]);
|
|
2256
|
-
const CHILD_CORE = new Set(["kill", "on", "stdout", "stderr", "unref", "exitCode"]);
|
|
2324
|
+
const CHILD_CORE = new Set(["kill", "on", "stdin", "stdout", "stderr", "unref", "exitCode", "send", "connected"]);
|
|
2257
2325
|
const props = checker.getPropertiesOfType(widened);
|
|
2258
2326
|
let core = 0;
|
|
2327
|
+
const childMemberType = (p) => {
|
|
2328
|
+
if (["kill", "on", "once", "off", "removeListener", "unref", "ref"].includes(p.name)) {
|
|
2329
|
+
return checker.getCallSignatures(checker.getTypeOfSymbol(p)).length > 0;
|
|
2330
|
+
}
|
|
2331
|
+
const expected = p.name === "stdout" || p.name === "stderr" ? "childStream"
|
|
2332
|
+
: p.name === "stdin" ? "childWriter"
|
|
2333
|
+
: p.name === "killed" ? "bool" : "f64";
|
|
2334
|
+
const unit = p.name === "pid" ? "undefinedT" : p.name === "exitCode" || p.name === "stdin" || p.name === "stdout" || p.name === "stderr" ? "nullT" : null;
|
|
2335
|
+
const mapped = mapType(checker.getTypeOfSymbol(p), ctx);
|
|
2336
|
+
if (!mapped)
|
|
2337
|
+
return false;
|
|
2338
|
+
const arms = mapped.kind === "union" ? ctx.unions.get(mapped.unionId)?.arms : [mapped];
|
|
2339
|
+
return arms !== undefined && arms.some((arm) => arm.kind === expected) &&
|
|
2340
|
+
arms.every((arm) => arm.kind === expected || arm.kind === unit);
|
|
2341
|
+
};
|
|
2259
2342
|
const childShaped = props.length > 0 &&
|
|
2260
2343
|
props.every((p) => {
|
|
2261
|
-
if (!CHILD_SURFACE.has(p.name))
|
|
2344
|
+
if (!CHILD_SURFACE.has(p.name) || !childMemberType(p))
|
|
2262
2345
|
return false;
|
|
2263
2346
|
if (CHILD_CORE.has(p.name))
|
|
2264
2347
|
core++;
|
|
@@ -2884,9 +2967,11 @@ function mapBrandedPrimitiveIntersection(widened, ctx) {
|
|
|
2884
2967
|
return BOOL;
|
|
2885
2968
|
if (base.flags & (ts.TypeFlags.ESSymbol | ts.TypeFlags.UniqueESSymbol))
|
|
2886
2969
|
return SYMBOL_T;
|
|
2970
|
+
if (base.flags & (ts.TypeFlags.BigInt | ts.TypeFlags.BigIntLiteral))
|
|
2971
|
+
return BIGINT_T;
|
|
2887
2972
|
if (base.flags & ts.TypeFlags.TypeParameter) {
|
|
2888
2973
|
const bound = resolveTypeParam?.(base) ?? null;
|
|
2889
|
-
if (bound && (bound.kind === "f64" || bound.kind === "string" || bound.kind === "bool" || bound.kind === "symbol")) {
|
|
2974
|
+
if (bound && (bound.kind === "f64" || bound.kind === "bigint" || bound.kind === "string" || bound.kind === "bool" || bound.kind === "symbol")) {
|
|
2890
2975
|
contextResolutions++;
|
|
2891
2976
|
return bound;
|
|
2892
2977
|
}
|
|
@@ -3513,8 +3598,9 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
3513
3598
|
}
|
|
3514
3599
|
return null;
|
|
3515
3600
|
}
|
|
3516
|
-
// Single-signature, non-generic function types:
|
|
3517
|
-
//
|
|
3601
|
+
// Single-signature, non-generic function types: a parameter type or the
|
|
3602
|
+
// return type carries the failure. Typed rest parameters use their array
|
|
3603
|
+
// type here like any other completed ABI slot. (Generic and
|
|
3518
3604
|
// overloaded signatures have their own fences — SC2005/SC2007 — and
|
|
3519
3605
|
// badType runs those first.)
|
|
3520
3606
|
const callSigs = checker.getCallSignatures(widened);
|
|
@@ -3530,10 +3616,6 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
3530
3616
|
return `the function shape is supported, but its signature is variadic ('arguments'-reading), and a compiled signature is fixed-arity`;
|
|
3531
3617
|
}
|
|
3532
3618
|
for (const p of sig.getParameters()) {
|
|
3533
|
-
const decl = checker.valueDeclarationOf(p);
|
|
3534
|
-
if (decl !== undefined && ts.isParameter(decl) && decl.dotDotDotToken !== undefined) {
|
|
3535
|
-
return `the function shape is supported, but its rest parameter '${p.name}' has no compiled calling convention yet (a compiled signature is fixed-arity)`;
|
|
3536
|
-
}
|
|
3537
3619
|
const pTs = checker.getTypeOfSymbol(p);
|
|
3538
3620
|
if (!mapType(pTs, ctx)) {
|
|
3539
3621
|
return `the function shape is supported, but its parameter '${p.name}' has type '${text(pTs)}', which does not compile`;
|