@scriptc/compiler 0.4.8 → 0.4.9
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/node-fallback/buffer.d.ts +2 -0
- package/ambient/node-fallback/child_process.d.ts +9 -3
- package/ambient/node-fallback/dns-promises.d.ts +25 -0
- package/ambient/node-fallback/dns.d.ts +29 -0
- package/ambient/node-fallback/test.d.ts +7 -0
- package/ambient/scriptc-node-fallback.d.ts +145 -2
- package/ambient/scriptc-overrides.d.ts +22 -13
- package/dist/backend/build-cache.d.ts +1 -1
- package/dist/backend/build-cache.js +1 -1
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/cache-root.d.ts +7 -0
- package/dist/backend/cache-root.js +27 -0
- package/dist/backend/cache-root.js.map +1 -1
- package/dist/backend/executable-features.js +5 -1
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/link-plan.js +7 -1
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.d.ts +12 -1
- package/dist/backend/llvm/bytes-loop-versions.js +107 -30
- package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +96 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/checked-value-lifetimes.js +1 -0
- package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +16 -5
- package/dist/backend/llvm/classes.js +34 -6
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +21 -2
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +9 -0
- package/dist/backend/llvm/common.js +9 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/cpu-dispatch.d.ts +36 -2
- package/dist/backend/llvm/cpu-dispatch.js +96 -2
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +5 -2
- package/dist/backend/llvm/dense-array-access.js +16 -12
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +3 -1
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +24 -0
- package/dist/backend/llvm/dyn.js +117 -3
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +6 -0
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-journal.d.ts +1 -0
- package/dist/backend/llvm/emit-journal.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +48 -5
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-module.test.js +41 -0
- package/dist/backend/llvm/emit-module.test.js.map +1 -1
- package/dist/backend/llvm/emit-statements.js +11 -0
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +87 -7
- package/dist/backend/llvm/emitter.js +136 -15
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +28 -6
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +19 -5
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +29 -1
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +104 -6
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.js +15 -1
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +53 -5
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/inline-arrays.js +1 -1
- package/dist/backend/llvm/inline-arrays.js.map +1 -1
- package/dist/backend/llvm/js-ic.js +126 -2
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lanes.d.ts +38 -0
- package/dist/backend/llvm/lanes.js +778 -0
- package/dist/backend/llvm/lanes.js.map +1 -0
- package/dist/backend/llvm/lanes.test.d.ts +1 -0
- package/dist/backend/llvm/lanes.test.js +402 -0
- package/dist/backend/llvm/lanes.test.js.map +1 -0
- package/dist/backend/llvm/lib-dispatch.js +9 -4
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +20 -0
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +27 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-test.js +11 -0
- package/dist/backend/llvm/lib-test.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +2 -2
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.js +8 -2
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.js +5 -2
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +3 -0
- package/dist/backend/llvm/publish.js +2 -2
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +1 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/region-groups.js +43 -4
- package/dist/backend/llvm/region-groups.js.map +1 -1
- package/dist/backend/llvm/region-groups.test.js +79 -0
- package/dist/backend/llvm/region-groups.test.js.map +1 -1
- package/dist/backend/llvm/runtime-registries.test.js +32 -1
- package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
- package/dist/backend/llvm/shapes.js +10 -1
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +1 -1
- package/dist/backend/llvm/string-reads.js +1 -1
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.js +24 -2
- package/dist/backend/llvm/unwind-abi.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.test.js +38 -0
- package/dist/backend/llvm/unwind-abi.test.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +3 -0
- package/dist/backend/llvm/walkers.js +20 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +15 -3
- package/dist/backend/native/executable.js +19 -5
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +20 -0
- package/dist/backend/native-codegen-core.js +15 -0
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +5 -0
- package/dist/backend/native-codegen.js +62 -8
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +48 -8
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +27 -3
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.test.js +17 -1
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +1 -1
- package/dist/backend/native-toolchain.js +1 -1
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +14 -1
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/runtime-pack-core.d.ts +9 -3
- package/dist/backend/runtime-pack-core.js +6 -1
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +32 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/targets.d.ts +9 -1
- package/dist/backend/targets.js +11 -2
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +6 -0
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/cli/command.js +15 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +6 -0
- package/dist/cli/mcp.d.ts +72 -0
- package/dist/cli/mcp.js +601 -0
- package/dist/cli/mcp.js.map +1 -0
- package/dist/cli/mcp.test.d.ts +1 -0
- package/dist/cli/mcp.test.js +380 -0
- package/dist/cli/mcp.test.js.map +1 -0
- package/dist/cli/output-options.d.ts +1 -0
- package/dist/cli/output-options.js +3 -0
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/usage.d.ts +51 -1
- package/dist/cli/usage.js +709 -186
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.js +9 -4
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +17 -0
- package/dist/coverage/report.d.ts +5 -9
- package/dist/coverage/report.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +17 -3
- package/dist/executable/executable-cache.js +17 -3
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/prepare.js +87 -10
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +3 -2
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/canon-map.js +13 -8
- package/dist/frontend/canon-map.js.map +1 -1
- package/dist/frontend/decl-projection.d.ts +18 -0
- package/dist/frontend/decl-projection.js +90 -22
- package/dist/frontend/decl-projection.js.map +1 -1
- package/dist/frontend/decl-projection.test.js +47 -1
- package/dist/frontend/decl-projection.test.js.map +1 -1
- package/dist/frontend/default-library.d.ts +10 -0
- package/dist/frontend/default-library.js +43 -0
- package/dist/frontend/default-library.js.map +1 -0
- package/dist/frontend/fork-target.js +54 -9
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/fork-target.test.js +82 -0
- package/dist/frontend/fork-target.test.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.test.js +73 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/lowering/abstract-equality.d.ts +2 -1
- package/dist/frontend/lowering/abstract-equality.js +7 -1
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +2 -2
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/assertion-members.js +52 -2
- package/dist/frontend/lowering/assertion-members.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +5 -0
- package/dist/frontend/lowering/builtin-namespaces.js +19 -12
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtins/callable-aliases.js +42 -6
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.d.ts +12 -11
- package/dist/frontend/lowering/builtins/child-process.js +235 -38
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +6 -1
- package/dist/frontend/lowering/builtins/compression.js +3 -3
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/constants.js +2 -2
- package/dist/frontend/lowering/builtins/constants.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +3 -1
- package/dist/frontend/lowering/builtins/crypto.js +9 -1
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.js +26 -6
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/environment.d.ts +13 -1
- package/dist/frontend/lowering/builtins/environment.js +15 -4
- package/dist/frontend/lowering/builtins/environment.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-bindings.d.ts +33 -0
- package/dist/frontend/lowering/builtins/module-bindings.js +213 -11
- package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +9 -2
- package/dist/frontend/lowering/builtins/module-resolution.js +187 -19
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/performance.js +1 -1
- package/dist/frontend/lowering/builtins/performance.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.js +40 -2
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +33 -0
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +9 -5
- package/dist/frontend/lowering/builtins/readline.js +184 -75
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.d.ts +4 -0
- package/dist/frontend/lowering/builtins/url.js +6 -0
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.js +15 -0
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/callable-properties.d.ts +34 -0
- package/dist/frontend/lowering/callable-properties.js +210 -0
- package/dist/frontend/lowering/callable-properties.js.map +1 -0
- package/dist/frontend/lowering/cjs-inline-require.d.ts +16 -0
- package/dist/frontend/lowering/cjs-inline-require.js +105 -0
- package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
- package/dist/frontend/lowering/cjs-inline-require.test.d.ts +1 -0
- package/dist/frontend/lowering/cjs-inline-require.test.js +61 -0
- package/dist/frontend/lowering/cjs-inline-require.test.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +82 -2
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +57 -4
- package/dist/frontend/lowering/class-protocols.js +597 -30
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-unions.js +2 -2
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +12 -0
- package/dist/frontend/lowering/coercions/function-adapters.js +62 -0
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +56 -1
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +9 -4
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/collection-ingestion.d.ts +9 -0
- package/dist/frontend/lowering/collection-ingestion.js +115 -41
- package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +16 -0
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +66 -10
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +61 -5
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.js +11 -0
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.d.ts +15 -0
- package/dist/frontend/lowering/containers/indexed-objects.js +213 -30
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/error-name-order.d.ts +16 -0
- package/dist/frontend/lowering/error-name-order.js +61 -0
- package/dist/frontend/lowering/error-name-order.js.map +1 -1
- package/dist/frontend/lowering/expressions/asserted-receiver.d.ts +17 -0
- package/dist/frontend/lowering/expressions/asserted-receiver.js +123 -1
- package/dist/frontend/lowering/expressions/asserted-receiver.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +147 -20
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +63 -14
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/erased-delete.d.ts +59 -0
- package/dist/frontend/lowering/expressions/erased-delete.js +247 -0
- package/dist/frontend/lowering/expressions/erased-delete.js.map +1 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +10 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js +48 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +20 -0
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +7 -2
- package/dist/frontend/lowering/expressions/narrowing.js +77 -45
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +62 -19
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +19 -0
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +7 -7
- package/dist/frontend/lowering/expressions/property-access.js +247 -48
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.d.ts +1 -0
- package/dist/frontend/lowering/expressions/relational.js +18 -8
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.js +11 -5
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +121 -11
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/function-context.d.ts +10 -0
- package/dist/frontend/lowering/function-context.js +36 -0
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/function-returns.js +8 -8
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.d.ts +62 -3
- package/dist/frontend/lowering/handle-properties.js +674 -26
- package/dist/frontend/lowering/handle-properties.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.test.js +95 -2
- package/dist/frontend/lowering/handle-properties.test.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +12 -0
- package/dist/frontend/lowering/lower-builtin-values.js +44 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +328 -136
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +82 -17
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +113 -9
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.d.ts +13 -21
- package/dist/frontend/lowering/lower-expando.js +90 -126
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +2 -2
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +65 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +471 -0
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +36 -10
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.js +28 -0
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +53 -7
- package/dist/frontend/lowering/lower-server.js +213 -42
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +50 -7
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +24 -0
- package/dist/frontend/lowering/lower-stmts.js +463 -220
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +2 -2
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.js +71 -2
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +81 -10
- package/dist/frontend/lowering/lowerer.js +319 -72
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/new-target.js +10 -2
- package/dist/frontend/lowering/new-target.js.map +1 -1
- package/dist/frontend/lowering/nullish-empty-pattern.js +3 -3
- package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -1
- package/dist/frontend/lowering/partial-assertions.js +30 -5
- package/dist/frontend/lowering/partial-assertions.js.map +1 -1
- package/dist/frontend/lowering/primitive-throws.js +91 -1
- package/dist/frontend/lowering/primitive-throws.js.map +1 -1
- package/dist/frontend/lowering/primitive-wrappers.d.ts +9 -0
- package/dist/frontend/lowering/primitive-wrappers.js +2 -2
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
- package/dist/frontend/lowering/promise-executor-adapter.js +5 -2
- package/dist/frontend/lowering/promise-executor-adapter.js.map +1 -1
- package/dist/frontend/lowering/record-links.js +7 -2
- package/dist/frontend/lowering/record-links.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +4 -0
- package/dist/frontend/lowering/surfaces.js +118 -2
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/surfaces.test.d.ts +1 -0
- package/dist/frontend/lowering/surfaces.test.js +31 -0
- package/dist/frontend/lowering/surfaces.test.js.map +1 -0
- package/dist/frontend/mock-shapes.js +3 -3
- package/dist/frontend/mock-shapes.js.map +1 -1
- package/dist/frontend/npm-static-ladder.d.ts +21 -0
- package/dist/frontend/npm-static-ladder.js +2 -0
- package/dist/frontend/npm-static-ladder.js.map +1 -0
- package/dist/frontend/npm-static-ladder.test.d.ts +1 -0
- package/dist/frontend/npm-static-ladder.test.js +138 -0
- package/dist/frontend/npm-static-ladder.test.js.map +1 -0
- package/dist/frontend/npm-static-status.d.ts +15 -0
- package/dist/frontend/npm-static-status.js +2 -0
- package/dist/frontend/npm-static-status.js.map +1 -0
- package/dist/frontend/package-shims.js +1 -1
- package/dist/frontend/package-shims.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +1 -1
- package/dist/frontend/pipeline.js +222 -25
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program-analysis.d.ts +4 -0
- package/dist/frontend/program-analysis.js +6 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program.js +258 -32
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +30 -0
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/resolve.js +29 -5
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.js +40 -0
- package/dist/frontend/resolve.test.js.map +1 -1
- package/dist/frontend/services.d.ts +8 -0
- package/dist/frontend/services.js +7 -0
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +7 -0
- package/dist/frontend/ts7/checker.js +12 -0
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +1 -0
- package/dist/frontend/ts7/checker.test.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +39 -2
- package/dist/frontend/ts7/program-host.js +62 -8
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +33 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/session-cache.d.ts +5 -1
- package/dist/frontend/ts7/session-cache.js +7 -1
- package/dist/frontend/ts7/session-cache.js.map +1 -1
- package/dist/frontend/ts7/session-cache.test.js +37 -0
- package/dist/frontend/ts7/session-cache.test.js.map +1 -1
- package/dist/frontend/ts7/session.js +19 -1
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/ts7/source-parser.d.ts +17 -2
- package/dist/frontend/ts7/source-parser.js +61 -2
- package/dist/frontend/ts7/source-parser.js.map +1 -1
- package/dist/frontend/ts7/source-parser.test.js +55 -2
- package/dist/frontend/ts7/source-parser.test.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +3 -2
- package/dist/frontend/tsc-codes.js +129 -22
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +5 -11
- package/dist/frontend/type-mapper.js +380 -70
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +67 -7
- package/dist/index.js.map +1 -1
- package/dist/ir/builtin-effects.js +29 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +72 -6
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/codec.generated.d.ts +1 -1
- package/dist/ir/codec.generated.js +321 -263
- package/dist/ir/codec.generated.js.map +1 -1
- package/dist/ir/constant-length-clones.d.ts +26 -0
- package/dist/ir/constant-length-clones.js +589 -0
- package/dist/ir/constant-length-clones.js.map +1 -0
- package/dist/ir/constant-length-clones.test.d.ts +1 -0
- package/dist/ir/constant-length-clones.test.js +292 -0
- package/dist/ir/constant-length-clones.test.js.map +1 -0
- package/dist/ir/constant-tables.d.ts +10 -5
- package/dist/ir/constant-tables.js +83 -17
- package/dist/ir/constant-tables.js.map +1 -1
- package/dist/ir/constant-tables.test.js +58 -1
- package/dist/ir/constant-tables.test.js.map +1 -1
- package/dist/ir/fields.generated.js +5 -2
- package/dist/ir/fields.generated.js.map +1 -1
- package/dist/ir/function-references.js +2 -0
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +13 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/integer-loops.js +1 -0
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +16 -0
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/ir.d.ts +50 -6
- package/dist/ir/ir.js +44 -2
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +83 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/js-groups.js +5 -1
- package/dist/ir/js-groups.js.map +1 -1
- package/dist/ir/js-ic.d.ts +20 -0
- package/dist/ir/js-ic.js +81 -4
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +8 -1
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/lane-plans.d.ts +86 -0
- package/dist/ir/lane-plans.js +589 -0
- package/dist/ir/lane-plans.js.map +1 -0
- package/dist/ir/lane-plans.test.d.ts +1 -0
- package/dist/ir/lane-plans.test.js +549 -0
- package/dist/ir/lane-plans.test.js.map +1 -0
- package/dist/ir/runtime-features.d.ts +68 -10
- package/dist/ir/runtime-features.js +285 -17
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +190 -1
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/validate.js +61 -24
- package/dist/ir/validate.js.map +1 -1
- package/dist/native/cache.d.ts +5 -0
- package/dist/native/cache.js +23 -1
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +29 -1
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +4 -2
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.d.ts +11 -3
- package/dist/native/compiler.js +102 -16
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/compiler.test.js +244 -2
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/prepare.d.ts +14 -1
- package/dist/native/prepare.js +79 -29
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +3 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/unchanged.d.ts +80 -0
- package/dist/native/unchanged.js +301 -0
- package/dist/native/unchanged.js.map +1 -0
- package/dist/native/unchanged.test.d.ts +1 -0
- package/dist/native/unchanged.test.js +249 -0
- package/dist/native/unchanged.test.js.map +1 -0
- package/dist/node-islands/boundary.d.ts +16 -0
- package/dist/node-islands/boundary.js +70 -7
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/boundary.test.js +59 -14
- package/dist/node-islands/boundary.test.js.map +1 -1
- package/dist/node-islands/detect.js +203 -47
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +45 -0
- package/dist/node-islands/detect.test.js.map +1 -1
- package/dist/node-islands/growth.js +4 -16
- package/dist/node-islands/growth.js.map +1 -1
- package/dist/node-islands/modules.d.ts +3 -0
- package/dist/node-islands/modules.js +143 -12
- package/dist/node-islands/modules.js.map +1 -1
- package/dist/node-islands/modules.test.js +125 -0
- package/dist/node-islands/modules.test.js.map +1 -1
- package/dist/node-islands/report.d.ts +1 -1
- package/dist/node-islands/report.js +2 -1
- package/dist/node-islands/report.js.map +1 -1
- package/package.json +20 -20
- package/shims/undici/core/request.ts +7 -1
- package/surface-manifest.json +380 -2
|
@@ -4,7 +4,7 @@ import { contentDigest } from "./lowering/unit-journal.js";
|
|
|
4
4
|
import { mockCallRecordType, mockContextType } from "./mock-shapes.js";
|
|
5
5
|
import * as ts from "./ts7/adapter.js";
|
|
6
6
|
import { bodyReadsArguments } from "./arguments-usage.js";
|
|
7
|
-
import { BYTES_ELEMENT_NAME, arrayOf, isDynTypedRefType, BOOL, bytesOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, CHILD_T, CRYPTOHASH_T, CRYPTOHMAC_T, DATE_T, DYN, FOREIGN, F64, funcOf, isSupportedArrayElem, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, iterableArmsElem, isUnitType, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, ZLIB_STREAM_MODES, setOf, STRING, SYMBOL_T, typeEquals, typeKey, maybePromiseUnionArmsOk, unionContainerArmsOk, UNDEFINED_T, VOID, } from "../ir/ir.js";
|
|
7
|
+
import { BYTES_ELEMENT_NAME, arrayOf, isDynTypedRefType, BOOL, bytesOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, CHILD_T, CRYPTOHASH_T, CRYPTOHMAC_T, DATE_T, DYN, FOREIGN, F64, funcOf, isSupportedArrayElem, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, iterableArmsElem, isUnitType, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, ZLIB_STREAM_MODES, setOf, STRING, SYMBOL_T, typeEquals, sortArms, typeKey, maybePromiseUnionArmsOk, unionContainerArmsOk, UNDEFINED_T, VOID, } from "../ir/ir.js";
|
|
8
8
|
import { BIGINT_T, KEY_ORDER_FIELD } from "../ir/ir.js";
|
|
9
9
|
import { literalValues } from "./literal-values.js";
|
|
10
10
|
import { remapUnionDiscriminant } from "./union-discriminants.js";
|
|
@@ -299,7 +299,11 @@ export class ShapeRegistry {
|
|
|
299
299
|
keyOf(fields, tuple, indexValue) {
|
|
300
300
|
return ((tuple ? "tuple!" : "") +
|
|
301
301
|
(indexValue ? `idx<${typeKey(indexValue)}>!` : "") +
|
|
302
|
-
|
|
302
|
+
// An absentable optional dyn field carries a third element in the
|
|
303
|
+
// key; every other entry keeps the historical two-element spelling,
|
|
304
|
+
// so a shape without one hashes exactly as before (zero-cost
|
|
305
|
+
// identity for programs that use no optional `unknown`/`any`).
|
|
306
|
+
JSON.stringify(fields.map((f) => f.optional === true ? [f.name, typeKey(f.type), 1] : [f.name, typeKey(f.type)])));
|
|
303
307
|
}
|
|
304
308
|
/** Runs one lowering unit under its historical emit-order rank. Shape
|
|
305
309
|
* ids remain demand-assigned; only first-seen declaration-order metadata
|
|
@@ -1336,6 +1340,15 @@ function genChannels(yieldTs, retTs, nextTs, ctx) {
|
|
|
1336
1340
|
* fallback for it. */
|
|
1337
1341
|
const MAP_TYPE_MAX_DEPTH = 64;
|
|
1338
1342
|
let mapTypeDepth = 0;
|
|
1343
|
+
/** The overload sets whose signatures the equal-modulo-union-order arm is
|
|
1344
|
+
* mapping, outermost first. Mapping a signature maps its parameter and return
|
|
1345
|
+
* types, which can name the set again — `interface R { (x: number): R; (x:
|
|
1346
|
+
* string): R }` declared in a package, which isOverloadedCallableMemberType
|
|
1347
|
+
* does not claim. Each level would map every signature again, so a recursive
|
|
1348
|
+
* set expands exponentially until MAP_TYPE_MAX_DEPTH cuts every branch off. A
|
|
1349
|
+
* set already being expanded is refused instead (null, as every other
|
|
1350
|
+
* unmappable type), and the slot reports the overload diagnostic. */
|
|
1351
|
+
const overloadExpansion = [];
|
|
1339
1352
|
/** Bumped whenever mapType resolves a type through CONTEXT-SENSITIVE or
|
|
1340
1353
|
* collection-sensitive hooks (a generic body's type parameter, a mixin
|
|
1341
1354
|
* instantiation, a generic class instance) — mappings that can make the same
|
|
@@ -2347,7 +2360,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2347
2360
|
}
|
|
2348
2361
|
if (hasNum && hasStr) {
|
|
2349
2362
|
const arms = [F64, STRING];
|
|
2350
|
-
arms
|
|
2363
|
+
sortArms(arms);
|
|
2351
2364
|
return { kind: "union", unionId: unions.intern(arms) };
|
|
2352
2365
|
}
|
|
2353
2366
|
return hasStr ? STRING : F64;
|
|
@@ -2982,7 +2995,9 @@ function mapTypeInner(type, ctx) {
|
|
|
2982
2995
|
// in a declaration file, which recordProvenanceOk rightly refuses for
|
|
2983
2996
|
// lib type worlds. Map it manually with the executor's own scriptc
|
|
2984
2997
|
// field shapes (plain-value resolve — () => void for Promise<void> —
|
|
2985
|
-
// and the
|
|
2998
|
+
// and the reject the promise's own reason representation picks: Error
|
|
2999
|
+
// for a typed payload, the checked-dynamic value for a promise whose
|
|
3000
|
+
// settled value is unknown), so both the destructured and the
|
|
2986
3001
|
// record-holding binding forms compile. User-declared literals with
|
|
2987
3002
|
// these member names keep the ordinary record path (their declarations
|
|
2988
3003
|
// are not in declaration files).
|
|
@@ -3005,7 +3020,7 @@ function mapTypeInner(type, ctx) {
|
|
|
3005
3020
|
name: "reject",
|
|
3006
3021
|
type: {
|
|
3007
3022
|
kind: "func",
|
|
3008
|
-
params: [{ kind: "object", className: "%Error" }],
|
|
3023
|
+
params: [inner.kind === "dyn" ? DYN : { kind: "object", className: "%Error" }],
|
|
3009
3024
|
ret: VOID,
|
|
3010
3025
|
},
|
|
3011
3026
|
},
|
|
@@ -3302,7 +3317,8 @@ function mapTypeInner(type, ctx) {
|
|
|
3302
3317
|
isStdlibInterface("SharedArrayBuffer") ||
|
|
3303
3318
|
isStdlibInterface("PropertyDescriptor") ||
|
|
3304
3319
|
isStdlibInterface("ProcessVersions") ||
|
|
3305
|
-
isStdlibInterface("ProcessRelease")
|
|
3320
|
+
isStdlibInterface("ProcessRelease") ||
|
|
3321
|
+
isStdlibInterface("ProcessReport"))
|
|
3306
3322
|
return DYN;
|
|
3307
3323
|
if (Object.values(BYTES_ELEMENT_NAME).some((name) => isStdlibInterface(`${name}Constructor`)))
|
|
3308
3324
|
return DYN;
|
|
@@ -3965,7 +3981,7 @@ function mapTypeInner(type, ctx) {
|
|
|
3965
3981
|
const optStr = withUndefinedArm(STRING, ctx.unions);
|
|
3966
3982
|
const optNum = withUndefinedArm(F64, ctx.unions);
|
|
3967
3983
|
const optBool = withUndefinedArm(BOOL, ctx.unions);
|
|
3968
|
-
const stdioArms = [arrayOf(STRING), STRING, UNDEFINED_T]
|
|
3984
|
+
const stdioArms = sortArms([arrayOf(STRING), STRING, UNDEFINED_T]);
|
|
3969
3985
|
const stdio = { kind: "union", unionId: ctx.unions.intern(stdioArms) };
|
|
3970
3986
|
if (!optStr || !optNum || !optBool)
|
|
3971
3987
|
return null;
|
|
@@ -3998,19 +4014,25 @@ function mapTypeInner(type, ctx) {
|
|
|
3998
4014
|
const optBool = withUndefinedArm(BOOL, ctx.unions);
|
|
3999
4015
|
const stdioArms = [arrayOf(STRING), STRING, UNDEFINED_T].sort((a, b) => typeKey(a) < typeKey(b) ? -1 : 1);
|
|
4000
4016
|
const stdio = { kind: "union", unionId: ctx.unions.intern(stdioArms) };
|
|
4001
|
-
|
|
4017
|
+
// `env?: NodeJS.ProcessEnv` — the same record the inline literal builds
|
|
4018
|
+
// its [k,v,...] pairs from. A runtime record can carry a replacement
|
|
4019
|
+
// environment, so the member maps rather than staying literal-only.
|
|
4020
|
+
const envProp = ctx.checker.getPropertyOfType(type, "env");
|
|
4021
|
+
const env = envProp ? mapType(ctx.checker.getTypeOfSymbol(envProp), ctx) : null;
|
|
4022
|
+
if (!optStr || !optNum || !optBool || !env || env.kind !== "union")
|
|
4002
4023
|
return null;
|
|
4003
4024
|
return {
|
|
4004
4025
|
kind: "record",
|
|
4005
4026
|
shapeId: ctx.shapes.intern([
|
|
4006
4027
|
{ name: "cwd", type: optStr },
|
|
4007
4028
|
{ name: "encoding", type: STRING },
|
|
4029
|
+
{ name: "env", type: env },
|
|
4008
4030
|
{ name: "input", type: optStr },
|
|
4009
4031
|
{ name: "shell", type: optBool },
|
|
4010
4032
|
{ name: "stdio", type: stdio },
|
|
4011
4033
|
{ name: "timeout", type: optNum },
|
|
4012
4034
|
{ name: "windowsHide", type: optBool },
|
|
4013
|
-
], false, undefined, ["encoding", "cwd", "input", "timeout", "shell", "stdio", "windowsHide"]),
|
|
4035
|
+
], false, undefined, ["encoding", "cwd", "env", "input", "timeout", "shell", "stdio", "windowsHide"]),
|
|
4014
4036
|
};
|
|
4015
4037
|
}
|
|
4016
4038
|
if (isStdlibInterface("AddressInfo")) {
|
|
@@ -4212,7 +4234,7 @@ function mapTypeInner(type, ctx) {
|
|
|
4212
4234
|
if (!t || t.kind !== "string")
|
|
4213
4235
|
return null;
|
|
4214
4236
|
}
|
|
4215
|
-
const shellArms = [NULL_T, STRING]
|
|
4237
|
+
const shellArms = sortArms([NULL_T, STRING]);
|
|
4216
4238
|
const shell = { kind: "union", unionId: ctx.unions.intern(shellArms) };
|
|
4217
4239
|
return {
|
|
4218
4240
|
kind: "record",
|
|
@@ -4463,7 +4485,7 @@ function mapTypeInner(type, ctx) {
|
|
|
4463
4485
|
if (isStdlibInterface("NetworkInterfaceInfoIPv4") ||
|
|
4464
4486
|
isStdlibInterface("NetworkInterfaceInfoIPv6")) {
|
|
4465
4487
|
const v6 = ts.symbolName(psym) === "NetworkInterfaceInfoIPv6";
|
|
4466
|
-
const cidrArms = [NULL_T, STRING]
|
|
4488
|
+
const cidrArms = sortArms([NULL_T, STRING]);
|
|
4467
4489
|
const cidr = { kind: "union", unionId: ctx.unions.intern(cidrArms) };
|
|
4468
4490
|
const scopeid = v6 ? F64 : withUndefinedArm(F64, ctx.unions);
|
|
4469
4491
|
if (!scopeid)
|
|
@@ -4544,9 +4566,18 @@ function mapTypeInner(type, ctx) {
|
|
|
4544
4566
|
// the plain-func mapping below (historic behavior: the properties drop
|
|
4545
4567
|
// from the type).
|
|
4546
4568
|
if (widened.isIntersectionType() && checker.getConstructSignatures(widened).length === 0) {
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4569
|
+
// node:test's `Mock<F>` (`F & { mock: MockFunctionContext<F> }`) keeps
|
|
4570
|
+
// its hybrid `%call` record: the `mock` member is the runner's live
|
|
4571
|
+
// call log, which the mock lowering builds and mutates, not data the
|
|
4572
|
+
// closure's own-property table could carry yet.
|
|
4573
|
+
if (isMockHybridIntersection(widened, ctx)) {
|
|
4574
|
+
const hybrid = mapHybridCallableRecord(widened, ctx);
|
|
4575
|
+
if (hybrid)
|
|
4576
|
+
return hybrid;
|
|
4577
|
+
}
|
|
4578
|
+
const callable = mapCallableIntersection(widened, ctx);
|
|
4579
|
+
if (callable)
|
|
4580
|
+
return callable;
|
|
4550
4581
|
// Recursive and Symbol-keyed callable objects need their complete live
|
|
4551
4582
|
// property table; dropping those members into a plain closure loses data.
|
|
4552
4583
|
if (checker.getCallSignatures(widened).length > 0 &&
|
|
@@ -4600,6 +4631,30 @@ function mapTypeInner(type, ctx) {
|
|
|
4600
4631
|
if (erased !== undefined)
|
|
4601
4632
|
return erased;
|
|
4602
4633
|
}
|
|
4634
|
+
// An overload set whose signatures are the SAME once union members are
|
|
4635
|
+
// read as a set is one signature: `typeof fetch` merges lib.dom's
|
|
4636
|
+
// `(input: URL | RequestInfo, ...)` with undici's `(input: string |
|
|
4637
|
+
// Request | URL, ...)`, which spell the same members in a different
|
|
4638
|
+
// order. Union interning keeps arm order, so the two mapped signatures
|
|
4639
|
+
// differ by unionId alone; a set whose signatures genuinely differ (a
|
|
4640
|
+
// rest parameter elsewhere, another result type) keeps its fence.
|
|
4641
|
+
// Erasable sets (isOverloadedCallableMemberType) already have their one
|
|
4642
|
+
// compiled signature and keep it: this arm is for the sets no erasure
|
|
4643
|
+
// reaches, such as a merged library declaration.
|
|
4644
|
+
// The signatures are mapped LAZILY, and only while the set is not already
|
|
4645
|
+
// being mapped higher up the stack: mapping a signature maps its parameter
|
|
4646
|
+
// and return types, so a recursive result type (`interface R { (x: number):
|
|
4647
|
+
// R; (x: string): R }` in a package declaration) re-enters the set and
|
|
4648
|
+
// would otherwise map every signature again at every level — exponential
|
|
4649
|
+
// until MAP_TYPE_MAX_DEPTH cuts each branch, stalling the build instead of
|
|
4650
|
+
// reporting the refusal (see overloadSetBeingExpanded).
|
|
4651
|
+
if (callSigs.length > 1 &&
|
|
4652
|
+
!isOverloadedCallableMemberType(widened, checker) &&
|
|
4653
|
+
!overloadSetBeingExpanded(widened)) {
|
|
4654
|
+
const agreed = mapAgreeingOverloadSignature(callSigs, widened, ctx);
|
|
4655
|
+
if (agreed !== null)
|
|
4656
|
+
return agreed;
|
|
4657
|
+
}
|
|
4603
4658
|
if (callSigs.length === 1)
|
|
4604
4659
|
return mapCallSignature(callSigs[0], ctx);
|
|
4605
4660
|
// Records: object types whose members are all data properties (shorthand
|
|
@@ -5008,7 +5063,7 @@ function mapTypeInner(type, ctx) {
|
|
|
5008
5063
|
!maybePromiseUnionOk(parts, mergedArms, ctx)) {
|
|
5009
5064
|
return null;
|
|
5010
5065
|
}
|
|
5011
|
-
mergedArms
|
|
5066
|
+
sortArms(mergedArms);
|
|
5012
5067
|
const discriminant = unionDiscriminant(recordParts, mergedArms, ctx) ??
|
|
5013
5068
|
(substitutedUnions.length === 1
|
|
5014
5069
|
? remapUnionDiscriminant(substitutedUnions[0], mergedArms)
|
|
@@ -5107,6 +5162,89 @@ function isStdlibStreamWriteOverloads(sigs, ctx) {
|
|
|
5107
5162
|
ctx.isStdlibFile(ts.getSourceFileOfNode(decl)));
|
|
5108
5163
|
});
|
|
5109
5164
|
}
|
|
5165
|
+
/** An overloaded set's identity for the expansion guard. A generic set
|
|
5166
|
+
* re-enters under a FRESH type object at each level (`interface R<T> { (x:
|
|
5167
|
+
* T): R<T[]> }`), so the declaration a type instantiation names stands in for
|
|
5168
|
+
* the type; an anonymous type literal is interned by the checker, so the type
|
|
5169
|
+
* itself is its own identity. */
|
|
5170
|
+
function overloadSetKey(type) {
|
|
5171
|
+
return type.getAliasSymbol() ?? type.getSymbol() ?? type;
|
|
5172
|
+
}
|
|
5173
|
+
/** True when `type` is already being expanded, or a chain of sets is
|
|
5174
|
+
* expanding that led back to it: mapping the set again can only repeat the
|
|
5175
|
+
* mapping that is already in progress, so the set has no single compiled
|
|
5176
|
+
* signature (see overloadExpansion). */
|
|
5177
|
+
function overloadSetBeingExpanded(type) {
|
|
5178
|
+
return overloadExpansion.includes(overloadSetKey(type));
|
|
5179
|
+
}
|
|
5180
|
+
/** The one signature `sigs` agree on, or null when they disagree or any of
|
|
5181
|
+
* them does not map. Signatures are mapped lazily — a set whose first two
|
|
5182
|
+
* signatures disagree costs two mappings — and the set stays on the expansion
|
|
5183
|
+
* stack throughout, so a signature naming the set again refuses it. */
|
|
5184
|
+
function mapAgreeingOverloadSignature(sigs, set, ctx) {
|
|
5185
|
+
overloadExpansion.push(overloadSetKey(set));
|
|
5186
|
+
try {
|
|
5187
|
+
const first = mapCallSignature(sigs[0], ctx);
|
|
5188
|
+
if (first === null)
|
|
5189
|
+
return null;
|
|
5190
|
+
for (let i = 1; i < sigs.length; i++) {
|
|
5191
|
+
const next = mapCallSignature(sigs[i], ctx);
|
|
5192
|
+
if (next === null || !sameTypeUpToUnionOrder(first, next, ctx, 0))
|
|
5193
|
+
return null;
|
|
5194
|
+
}
|
|
5195
|
+
return first;
|
|
5196
|
+
}
|
|
5197
|
+
finally {
|
|
5198
|
+
overloadExpansion.pop();
|
|
5199
|
+
}
|
|
5200
|
+
}
|
|
5201
|
+
/** Two mapped types that agree once every union's arms are read as a SET.
|
|
5202
|
+
* `URL | RequestInfo` and `string | Request | URL` name the same members
|
|
5203
|
+
* but intern as different unions (arm order is part of a union's identity),
|
|
5204
|
+
* so the overload dedupe below cannot use typeKey or typeEquals. Records and
|
|
5205
|
+
* handles compare by identity; the composite forms recurse. */
|
|
5206
|
+
function sameTypeUpToUnionOrder(a, b, ctx, depth) {
|
|
5207
|
+
if (typeKey(a) === typeKey(b))
|
|
5208
|
+
return true;
|
|
5209
|
+
if (depth > 16)
|
|
5210
|
+
return false;
|
|
5211
|
+
if (a.kind === "union" && b.kind === "union") {
|
|
5212
|
+
const armsA = ctx.unions.get(a.unionId)?.arms ?? [];
|
|
5213
|
+
const armsB = ctx.unions.get(b.unionId)?.arms ?? [];
|
|
5214
|
+
if (armsA.length !== armsB.length)
|
|
5215
|
+
return false;
|
|
5216
|
+
const rest = [...armsB];
|
|
5217
|
+
for (const arm of armsA) {
|
|
5218
|
+
const at = rest.findIndex((candidate) => sameTypeUpToUnionOrder(arm, candidate, ctx, depth + 1));
|
|
5219
|
+
if (at < 0)
|
|
5220
|
+
return false;
|
|
5221
|
+
rest.splice(at, 1);
|
|
5222
|
+
}
|
|
5223
|
+
return true;
|
|
5224
|
+
}
|
|
5225
|
+
switch (a.kind) {
|
|
5226
|
+
case "array":
|
|
5227
|
+
return b.kind === "array" && sameTypeUpToUnionOrder(a.elem, b.elem, ctx, depth + 1);
|
|
5228
|
+
case "promise":
|
|
5229
|
+
return b.kind === "promise" && sameTypeUpToUnionOrder(a.inner, b.inner, ctx, depth + 1);
|
|
5230
|
+
case "map":
|
|
5231
|
+
return (b.kind === "map" &&
|
|
5232
|
+
sameTypeUpToUnionOrder(a.key, b.key, ctx, depth + 1) &&
|
|
5233
|
+
sameTypeUpToUnionOrder(a.value, b.value, ctx, depth + 1));
|
|
5234
|
+
case "set":
|
|
5235
|
+
return b.kind === "set" && sameTypeUpToUnionOrder(a.elem, b.elem, ctx, depth + 1);
|
|
5236
|
+
case "func":
|
|
5237
|
+
return (b.kind === "func" &&
|
|
5238
|
+
a.params.length === b.params.length &&
|
|
5239
|
+
(a.rest ?? false) === (b.rest ?? false) &&
|
|
5240
|
+
(a.restAbi ?? null) === (b.restAbi ?? null) &&
|
|
5241
|
+
(a.argumentsAll ?? false) === (b.argumentsAll ?? false) &&
|
|
5242
|
+
a.params.every((p, i) => sameTypeUpToUnionOrder(p, b.params[i], ctx, depth + 1)) &&
|
|
5243
|
+
sameTypeUpToUnionOrder(a.ret, b.ret, ctx, depth + 1));
|
|
5244
|
+
default:
|
|
5245
|
+
return false;
|
|
5246
|
+
}
|
|
5247
|
+
}
|
|
5110
5248
|
function mapCallSignature(sig, ctx) {
|
|
5111
5249
|
const { checker } = ctx;
|
|
5112
5250
|
if (sig.getTypeParameters().length && ctx.erasingSignature !== sig)
|
|
@@ -5158,27 +5296,36 @@ function mapCallSignature(sig, ctx) {
|
|
|
5158
5296
|
let pt = mapType(checker.getTypeOfSymbol(p), ctx);
|
|
5159
5297
|
// A parameter a TypeScript program types `any` takes whatever the
|
|
5160
5298
|
// caller passes: the checked-dynamic slot, as an `any`-typed binding
|
|
5161
|
-
// already is (dynFallbackType).
|
|
5162
|
-
//
|
|
5299
|
+
// already is (dynFallbackType). This holds in every declaration world
|
|
5300
|
+
// the program or a package writes — program source and `.d.ts`
|
|
5301
|
+
// declaration files alike, since a published declaration is the same
|
|
5302
|
+
// contract as the implementation source. The standard library keeps
|
|
5303
|
+
// its existing paths: its ambient signatures are the language's own
|
|
5304
|
+
// surface, so admitting them would change the static shape of every
|
|
5305
|
+
// typed program that calls one (`PropertyDescriptor.get`'s `this: any`,
|
|
5306
|
+
// `map`'s `thisArg?: any`), which the zero-cost gate forbids. Only
|
|
5307
|
+
// function declarations, spelled function types, method and call
|
|
5163
5308
|
// signatures of interfaces and type literals (`execute(params: any):
|
|
5164
|
-
// Promise<R>`), and lambda parameters whose
|
|
5165
|
-
// of their type (`(n = lookup() ?? 5) =>
|
|
5166
|
-
// other lambdas and methods in object
|
|
5167
|
-
// checked-dynamic story.
|
|
5309
|
+
// Promise<R>`), ambient class methods, and lambda parameters whose
|
|
5310
|
+
// default is the only source of their type (`(n = lookup() ?? 5) =>
|
|
5311
|
+
// ...` with an `any` lookup): other lambdas and methods in object
|
|
5312
|
+
// literals keep their existing checked-dynamic story.
|
|
5168
5313
|
if (!pt &&
|
|
5169
5314
|
!rest &&
|
|
5170
5315
|
decl !== undefined &&
|
|
5171
5316
|
ts.isParameter(decl) &&
|
|
5172
5317
|
decl.parent !== undefined &&
|
|
5318
|
+
!(ts.getSourceFileOfNode(decl).isDeclarationFile &&
|
|
5319
|
+
ctx.isStdlibFile(ts.getSourceFileOfNode(decl))) &&
|
|
5173
5320
|
(ts.isFunctionDeclaration(decl.parent) ||
|
|
5174
5321
|
ts.isFunctionTypeNode(decl.parent) ||
|
|
5175
5322
|
ts.isMethodSignatureDeclaration(decl.parent) ||
|
|
5176
5323
|
ts.isCallSignatureDeclaration(decl.parent) ||
|
|
5324
|
+
(ts.isMethodDeclaration(decl.parent) && ts.getSourceFileOfNode(decl).isDeclarationFile) ||
|
|
5177
5325
|
((ts.isArrowFunction(decl.parent) || ts.isFunctionExpression(decl.parent)) &&
|
|
5178
5326
|
decl.initializer !== undefined &&
|
|
5179
5327
|
decl.type === undefined &&
|
|
5180
5328
|
!isJsSourceFile(ts.getSourceFileOfNode(decl)))) &&
|
|
5181
|
-
!ts.getSourceFileOfNode(decl).isDeclarationFile &&
|
|
5182
5329
|
(checker.getTypeOfSymbol(p).flags & ts.TypeFlags.Any) !== 0)
|
|
5183
5330
|
pt = DYN;
|
|
5184
5331
|
if (decl &&
|
|
@@ -6047,7 +6194,7 @@ function mapGenericIndexedAccess(type, ctx) {
|
|
|
6047
6194
|
}
|
|
6048
6195
|
if (arms.length === 1)
|
|
6049
6196
|
return arms[0];
|
|
6050
|
-
arms
|
|
6197
|
+
sortArms(arms);
|
|
6051
6198
|
return { kind: "union", unionId: ctx.unions.intern(arms) };
|
|
6052
6199
|
}
|
|
6053
6200
|
/** A distributive conditional (`T extends "a" ? A : T extends "b" ? B :
|
|
@@ -6162,7 +6309,7 @@ function mapDistributedConditional(type, ctx) {
|
|
|
6162
6309
|
return arms[0];
|
|
6163
6310
|
if (!unionContainerArmsOk(arms))
|
|
6164
6311
|
return null;
|
|
6165
|
-
arms
|
|
6312
|
+
sortArms(arms);
|
|
6166
6313
|
return { kind: "union", unionId: ctx.unions.intern(arms) };
|
|
6167
6314
|
}
|
|
6168
6315
|
/** `keyof T extends never ? A : B` over a bound record T (the lib's
|
|
@@ -6241,13 +6388,18 @@ function mapBoundMappedType(widened, ctx) {
|
|
|
6241
6388
|
const optional = modifier === ts.SyntaxKind.MinusToken
|
|
6242
6389
|
? false
|
|
6243
6390
|
: modifier !== undefined || (property.flags & ts.SymbolFlags.Optional) !== 0;
|
|
6391
|
+
let absentable = false;
|
|
6244
6392
|
if (optional) {
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6393
|
+
if (type.kind === "dyn")
|
|
6394
|
+
absentable = true;
|
|
6395
|
+
else {
|
|
6396
|
+
const armed = withUndefinedArm(type, unions);
|
|
6397
|
+
if (!armed)
|
|
6398
|
+
return null;
|
|
6399
|
+
type = armed;
|
|
6400
|
+
}
|
|
6249
6401
|
}
|
|
6250
|
-
fields.push({ name, type });
|
|
6402
|
+
fields.push({ name, type, ...(absentable ? { optional: true } : {}) });
|
|
6251
6403
|
order.push(name);
|
|
6252
6404
|
}
|
|
6253
6405
|
fields.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
@@ -6588,6 +6740,12 @@ function mapGenericUtilityAlias(widened, ctx) {
|
|
|
6588
6740
|
return null;
|
|
6589
6741
|
const fields = [];
|
|
6590
6742
|
for (const f of shape.fields) {
|
|
6743
|
+
// Partial makes every property optional: a checked-dynamic slot becomes
|
|
6744
|
+
// absentable, every other one gains the undefined arm.
|
|
6745
|
+
if (f.type.kind === "dyn") {
|
|
6746
|
+
fields.push({ name: f.name, type: f.type, optional: true });
|
|
6747
|
+
continue;
|
|
6748
|
+
}
|
|
6591
6749
|
const armed = withUndefinedArm(f.type, unions);
|
|
6592
6750
|
if (!armed)
|
|
6593
6751
|
return null;
|
|
@@ -6615,7 +6773,7 @@ function mapGenericUtilityAlias(widened, ctx) {
|
|
|
6615
6773
|
* that could inhabit the extra arm. */
|
|
6616
6774
|
export function unitOnlyUnion(unions) {
|
|
6617
6775
|
const arms = [NULL_T, UNDEFINED_T];
|
|
6618
|
-
arms
|
|
6776
|
+
sortArms(arms);
|
|
6619
6777
|
return { kind: "union", unionId: unions.intern(arms) };
|
|
6620
6778
|
}
|
|
6621
6779
|
/** `Iterable<T>`: a union whose arms are the sources that keep their own
|
|
@@ -6649,7 +6807,7 @@ export function iterableUnionType(elem, shapes, unions) {
|
|
|
6649
6807
|
isSupportedMapValue(v.type))
|
|
6650
6808
|
arms.push({ kind: "map", key: k.type, value: v.type });
|
|
6651
6809
|
}
|
|
6652
|
-
arms
|
|
6810
|
+
sortArms(arms);
|
|
6653
6811
|
return { kind: "union", unionId: unions.intern(arms) };
|
|
6654
6812
|
}
|
|
6655
6813
|
/** The IteratorResult record of a generator's value channels: `{ done:
|
|
@@ -6699,7 +6857,7 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
6699
6857
|
valueT = unitOnlyUnion(unions);
|
|
6700
6858
|
}
|
|
6701
6859
|
else {
|
|
6702
|
-
arms
|
|
6860
|
+
sortArms(arms);
|
|
6703
6861
|
valueT = { kind: "union", unionId: unions.intern(arms) };
|
|
6704
6862
|
}
|
|
6705
6863
|
}
|
|
@@ -6775,6 +6933,13 @@ export const X509_FIELDS = [
|
|
|
6775
6933
|
export function withUndefinedArm(t, unions) {
|
|
6776
6934
|
return withUnitArm(t, "undefinedT", unions);
|
|
6777
6935
|
}
|
|
6936
|
+
/** A record property declared `?:` whose mapped type is the checked-dynamic
|
|
6937
|
+
* slot. Only such a field's shape carries an ABSENT state of its own (the
|
|
6938
|
+
* absent marker); every other optional property maps to an undefined-armed
|
|
6939
|
+
* union, whose absence is the union's ABSENT state. */
|
|
6940
|
+
function optionalCheckedDyn(p, type) {
|
|
6941
|
+
return type.kind === "dyn" && (p.flags & ts.SymbolFlags.Optional) !== 0;
|
|
6942
|
+
}
|
|
6778
6943
|
/** Preserve a nullish runtime value that JavaScript inference omitted. */
|
|
6779
6944
|
export function withUnitArm(t, kind, unions) {
|
|
6780
6945
|
const unit = { kind };
|
|
@@ -6788,7 +6953,7 @@ export function withUnitArm(t, kind, unions) {
|
|
|
6788
6953
|
// Date and Promise arms beside other data arms have no union home.
|
|
6789
6954
|
if (!unionContainerArmsOk(arms))
|
|
6790
6955
|
return null;
|
|
6791
|
-
arms
|
|
6956
|
+
sortArms(arms);
|
|
6792
6957
|
return { kind: "union", unionId: unions.transform(def, arms) };
|
|
6793
6958
|
}
|
|
6794
6959
|
if (t.kind === "void" ||
|
|
@@ -6799,7 +6964,7 @@ export function withUnitArm(t, kind, unions) {
|
|
|
6799
6964
|
return null;
|
|
6800
6965
|
}
|
|
6801
6966
|
const arms = [t, unit];
|
|
6802
|
-
arms
|
|
6967
|
+
sortArms(arms);
|
|
6803
6968
|
return { kind: "union", unionId: unions.intern(arms) };
|
|
6804
6969
|
}
|
|
6805
6970
|
/** The chalk-shape recognizer behind mapType's hybrid branch: an
|
|
@@ -6878,7 +7043,68 @@ function mapClassExpandoIntersection(widened, ctx) {
|
|
|
6878
7043
|
}
|
|
6879
7044
|
return DYN;
|
|
6880
7045
|
}
|
|
6881
|
-
|
|
7046
|
+
/** `F & { data }` maps to the CALLABLE part's func type: the members live in
|
|
7047
|
+
* the closure's own-property table (lowering/callable-properties.ts), so the
|
|
7048
|
+
* value IS the function — identity, aliasing, `typeof`, enumeration and
|
|
7049
|
+
* inspect all answer as Node's function object does. The parts that cannot
|
|
7050
|
+
* share that one representation (a recursive or `this`-typed member, a
|
|
7051
|
+
* symbol-keyed member, an accessor, a class or index-signature part) return
|
|
7052
|
+
* null, and the caller keeps the DYN mapping. */
|
|
7053
|
+
function mapCallableIntersection(widened, ctx) {
|
|
7054
|
+
const { checker } = ctx;
|
|
7055
|
+
if (!widened.isIntersectionType())
|
|
7056
|
+
return null;
|
|
7057
|
+
if (checker.getCallSignatures(widened).length !== 1)
|
|
7058
|
+
return null;
|
|
7059
|
+
let funcPart = null;
|
|
7060
|
+
for (const part of ts.constituentTypes(widened)) {
|
|
7061
|
+
if (checker.getCallSignatures(part).length > 0) {
|
|
7062
|
+
if (funcPart)
|
|
7063
|
+
return null; // exactly one callable part
|
|
7064
|
+
funcPart = part;
|
|
7065
|
+
continue;
|
|
7066
|
+
}
|
|
7067
|
+
const partSym = part.getSymbol();
|
|
7068
|
+
if ((part.flags & ts.TypeFlags.Object) === 0 ||
|
|
7069
|
+
checker.getConstructSignatures(part).length > 0 ||
|
|
7070
|
+
(partSym !== undefined && (partSym.flags & ts.SymbolFlags.Class) !== 0) ||
|
|
7071
|
+
checker.getIndexInfosOfType(part).length > 0) {
|
|
7072
|
+
return null;
|
|
7073
|
+
}
|
|
7074
|
+
}
|
|
7075
|
+
if (!funcPart)
|
|
7076
|
+
return null;
|
|
7077
|
+
const properties = checker.getPropertiesOfType(widened);
|
|
7078
|
+
if (properties.length === 0)
|
|
7079
|
+
return null; // no properties — it is just F
|
|
7080
|
+
for (const p of properties) {
|
|
7081
|
+
if (p.flags & (ts.SymbolFlags.GetAccessor | ts.SymbolFlags.SetAccessor))
|
|
7082
|
+
return null;
|
|
7083
|
+
// A symbol-keyed member has no string key in the table.
|
|
7084
|
+
if (ts.symbolName(p).startsWith("__@"))
|
|
7085
|
+
return null;
|
|
7086
|
+
}
|
|
7087
|
+
const fn = mapType(funcPart, ctx);
|
|
7088
|
+
return fn?.kind === "func" ? fn : null;
|
|
7089
|
+
}
|
|
7090
|
+
/** Whether `widened` is node:test's `Mock<F>` — an intersection carrying a
|
|
7091
|
+
* `mock: MockFunctionContext<F>` member declared in the ambient `test`
|
|
7092
|
+
* module (the same provenance check MockFunctionContext's own mapping
|
|
7093
|
+
* uses). */
|
|
7094
|
+
function isMockHybridIntersection(widened, ctx) {
|
|
7095
|
+
if (!widened.isIntersectionType())
|
|
7096
|
+
return false;
|
|
7097
|
+
const mock = ctx.checker.getPropertyOfType(widened, "mock");
|
|
7098
|
+
if (mock === undefined)
|
|
7099
|
+
return false;
|
|
7100
|
+
const sym = ctx.checker.getTypeOfSymbol(mock).getSymbol();
|
|
7101
|
+
return (sym !== undefined &&
|
|
7102
|
+
ts.symbolName(sym) === "MockFunctionContext" &&
|
|
7103
|
+
sym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
|
|
7104
|
+
ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
|
|
7105
|
+
isDeclaredInAmbientModule(d, "test")));
|
|
7106
|
+
}
|
|
7107
|
+
function mapHybridCallableRecord(widened, ctx) {
|
|
6882
7108
|
const { checker, shapes } = ctx;
|
|
6883
7109
|
if (!widened.isIntersectionType())
|
|
6884
7110
|
return null;
|
|
@@ -6913,7 +7139,11 @@ function mapHybridCallableIntersection(widened, ctx) {
|
|
|
6913
7139
|
const pt = mapType(checker.getTypeOfSymbol(p), ctx);
|
|
6914
7140
|
if (!pt || pt.kind === "void")
|
|
6915
7141
|
return null;
|
|
6916
|
-
fields.push({
|
|
7142
|
+
fields.push({
|
|
7143
|
+
name: ts.symbolName(p),
|
|
7144
|
+
type: pt,
|
|
7145
|
+
...(optionalCheckedDyn(p, pt) ? { optional: true } : {}),
|
|
7146
|
+
});
|
|
6917
7147
|
declaredOrder.push(ts.symbolName(p));
|
|
6918
7148
|
}
|
|
6919
7149
|
if (fields.length === 1)
|
|
@@ -6921,8 +7151,12 @@ function mapHybridCallableIntersection(widened, ctx) {
|
|
|
6921
7151
|
fields.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
6922
7152
|
return { kind: "record", shapeId: shapes.intern(fields, false, undefined, declaredOrder) };
|
|
6923
7153
|
}
|
|
6924
|
-
/** The
|
|
6925
|
-
* intersections maps to, or null when a part does not map to the same one.
|
|
7154
|
+
/** The representation every part of a union of function-with-properties
|
|
7155
|
+
* intersections maps to, or null when a part does not map to the same one.
|
|
7156
|
+
* Each part maps exactly as it does alone — an ordinary callable
|
|
7157
|
+
* intersection to the callable's func type (its members ARE the closure's
|
|
7158
|
+
* own properties), node:test's `Mock<F>` to its hybrid `%call` record — so a
|
|
7159
|
+
* union never reintroduces the record a value no longer has. */
|
|
6926
7160
|
function mapUniformHybridUnion(widened, ctx) {
|
|
6927
7161
|
const parts = ts.constituentTypes(widened);
|
|
6928
7162
|
if (!parts.every((p) => p.isIntersectionType()))
|
|
@@ -6931,7 +7165,9 @@ function mapUniformHybridUnion(widened, ctx) {
|
|
|
6931
7165
|
for (const part of parts) {
|
|
6932
7166
|
if (ctx.checker.getConstructSignatures(part).length > 0)
|
|
6933
7167
|
return null;
|
|
6934
|
-
const mapped =
|
|
7168
|
+
const mapped = isMockHybridIntersection(part, ctx)
|
|
7169
|
+
? mapHybridCallableRecord(part, ctx)
|
|
7170
|
+
: mapCallableIntersection(part, ctx);
|
|
6935
7171
|
if (!mapped || (first && typeKey(mapped) !== typeKey(first)))
|
|
6936
7172
|
return null;
|
|
6937
7173
|
first ??= mapped;
|
|
@@ -7021,9 +7257,10 @@ function mapErrorMetadataIntersection(type, ctx) {
|
|
|
7021
7257
|
/** A conventional primitive brand has one runtime-carrying primitive part
|
|
7022
7258
|
* and one or more phantom object parts whose fields are literal marker
|
|
7023
7259
|
* values. The marker can use a string or unique-symbol key, can be imported
|
|
7024
|
-
* from a declaration file,
|
|
7025
|
-
* none of those facts changes the runtime
|
|
7026
|
-
* the marker-free form of the same
|
|
7260
|
+
* from a declaration file, can be expressed through a generic alias, and can
|
|
7261
|
+
* nest tables of further markers; none of those facts changes the runtime
|
|
7262
|
+
* value. Empty `{}` refinements are the marker-free form of the same
|
|
7263
|
+
* primitive narrowing.
|
|
7027
7264
|
*
|
|
7028
7265
|
* Arbitrary primitive/object intersections do not erase here. A companion
|
|
7029
7266
|
* with a class identity, call/construct/index signature, accessor, or a
|
|
@@ -7059,7 +7296,7 @@ function mapBrandedPrimitiveIntersection(widened, ctx) {
|
|
|
7059
7296
|
}
|
|
7060
7297
|
return null;
|
|
7061
7298
|
};
|
|
7062
|
-
const markerValue = (value) => {
|
|
7299
|
+
const markerValue = (value, seen = new Set()) => {
|
|
7063
7300
|
if (value.flags &
|
|
7064
7301
|
(ts.TypeFlags.StringLiteral |
|
|
7065
7302
|
ts.TypeFlags.NumberLiteral |
|
|
@@ -7074,15 +7311,42 @@ function mapBrandedPrimitiveIntersection(widened, ctx) {
|
|
|
7074
7311
|
return true;
|
|
7075
7312
|
}
|
|
7076
7313
|
if (value.isUnionType())
|
|
7077
|
-
return ts.constituentTypes(value).every(markerValue);
|
|
7314
|
+
return ts.constituentTypes(value).every((part) => markerValue(part, seen));
|
|
7078
7315
|
if (value.flags & ts.TypeFlags.TypeParameter) {
|
|
7079
7316
|
const bound = resolveTypeParamTs?.(value) ?? null;
|
|
7080
7317
|
if (bound) {
|
|
7081
7318
|
contextResolutions++;
|
|
7082
|
-
return markerValue(bound);
|
|
7319
|
+
return markerValue(bound, seen);
|
|
7083
7320
|
}
|
|
7084
7321
|
}
|
|
7085
|
-
|
|
7322
|
+
// A NESTED marker table (`{ readonly ["~effect/Brand"]: { readonly
|
|
7323
|
+
// ProviderDriverKind: "ProviderDriverKind" } }`): an object whose own
|
|
7324
|
+
// members are all markers describes no runtime data, so the nesting
|
|
7325
|
+
// does not make the marker observable. Class identity, call, construct
|
|
7326
|
+
// or index signatures, accessors, and non-literal value fields stay
|
|
7327
|
+
// outside the rule, because those can describe runtime behavior.
|
|
7328
|
+
if ((value.flags & ts.TypeFlags.Object) === 0)
|
|
7329
|
+
return false;
|
|
7330
|
+
if (seen.has(value))
|
|
7331
|
+
return false;
|
|
7332
|
+
seen.add(value);
|
|
7333
|
+
// `seen` holds the types on the current path only: two sibling fields
|
|
7334
|
+
// that name the same marker type both erase, while a table that refers
|
|
7335
|
+
// to itself stays outside the rule.
|
|
7336
|
+
let marker = false;
|
|
7337
|
+
const sym = value.getSymbol();
|
|
7338
|
+
if (sym === undefined || (sym.flags & ts.SymbolFlags.Class) === 0) {
|
|
7339
|
+
marker =
|
|
7340
|
+
checker.getCallSignatures(value).length === 0 &&
|
|
7341
|
+
checker.getConstructSignatures(value).length === 0 &&
|
|
7342
|
+
checker.getIndexInfosOfType(value).length === 0 &&
|
|
7343
|
+
checker
|
|
7344
|
+
.getPropertiesOfType(value)
|
|
7345
|
+
.every((prop) => (prop.flags & (ts.SymbolFlags.GetAccessor | ts.SymbolFlags.SetAccessor)) === 0 &&
|
|
7346
|
+
markerValue(checker.getTypeOfSymbol(prop), seen));
|
|
7347
|
+
}
|
|
7348
|
+
seen.delete(value);
|
|
7349
|
+
return marker;
|
|
7086
7350
|
};
|
|
7087
7351
|
let primitive = null;
|
|
7088
7352
|
let markerParts = 0;
|
|
@@ -7301,7 +7565,14 @@ export function packageTypeIsData(type, ctx) {
|
|
|
7301
7565
|
if (!data)
|
|
7302
7566
|
return false;
|
|
7303
7567
|
}
|
|
7304
|
-
|
|
7568
|
+
if (declared)
|
|
7569
|
+
return true;
|
|
7570
|
+
// A union spelled through a package type alias whose members all come
|
|
7571
|
+
// from elsewhere (`type RawData = Buffer | ArrayBuffer | Buffer[]`):
|
|
7572
|
+
// no member carries the package's provenance, but the alias declaration
|
|
7573
|
+
// is the package's data shape, so the type is still data the program
|
|
7574
|
+
// builds and never a value the package's implementation produces.
|
|
7575
|
+
return packageDataPart(type, ctx) === true;
|
|
7305
7576
|
}
|
|
7306
7577
|
/** The record path's provenance fence. Declared shapes (object literals,
|
|
7307
7578
|
* interfaces, type literals) must come from user code or an explicitly
|
|
@@ -7517,7 +7788,7 @@ function joinOverloadTypes(types, ctx) {
|
|
|
7517
7788
|
}
|
|
7518
7789
|
}
|
|
7519
7790
|
if (scalar && [...arms.values()].some((arm) => !isUnitType(arm))) {
|
|
7520
|
-
const sorted = [...arms.values()]
|
|
7791
|
+
const sorted = sortArms([...arms.values()]);
|
|
7521
7792
|
return { kind: "union", unionId: ctx.unions.intern(sorted) };
|
|
7522
7793
|
}
|
|
7523
7794
|
if (types.every((t) => t.kind === "dyn" ||
|
|
@@ -7578,8 +7849,12 @@ export function erasedOverloadMemberType(t, ctx) {
|
|
|
7578
7849
|
/** Why an overloaded member's set has no erased type
|
|
7579
7850
|
* (erasedOverloadMemberType): the first overload, and within it the first
|
|
7580
7851
|
* parameter or result, that does not map; otherwise the join itself. A
|
|
7581
|
-
* message tail after "its member 'name'".
|
|
7582
|
-
|
|
7852
|
+
* message tail after "its member 'name'". `depth` and `seen` continue the
|
|
7853
|
+
* enclosing description's walk: an overload whose parameter or result
|
|
7854
|
+
* names the record being described (`interface Chain { attach(next:
|
|
7855
|
+
* Chain): Chain }`) must answer from that walk, not restart it, or each
|
|
7856
|
+
* overload tail would describe the same set again without end. */
|
|
7857
|
+
function describeOverloadSetBlocker(t, ctx, depth, seen) {
|
|
7583
7858
|
const { checker } = ctx;
|
|
7584
7859
|
for (const sig of checker.getCallSignatures(t)) {
|
|
7585
7860
|
const own = new Set(sig.getTypeParameters());
|
|
@@ -7602,10 +7877,10 @@ function describeOverloadSetBlocker(t, ctx) {
|
|
|
7602
7877
|
for (const param of sig.getParameters()) {
|
|
7603
7878
|
const paramTs = checker.getTypeOfSymbol(param);
|
|
7604
7879
|
if (!mapType(paramTs, sigCtx))
|
|
7605
|
-
return `is an overload set, and its ${which} has parameter '${ts.symbolName(param)}' of type '${checker.typeToString(paramTs)}', which does not compile`;
|
|
7880
|
+
return `is an overload set, and its ${which} has parameter '${ts.symbolName(param)}' of type '${checker.typeToString(paramTs)}', which does not compile${slotReason(paramTs, ctx, depth + 1, seen)}`;
|
|
7606
7881
|
}
|
|
7607
7882
|
const retTs = checker.getReturnTypeOfSignature(sig);
|
|
7608
|
-
return `is an overload set, and its ${which} returns '${checker.typeToString(retTs)}', which does not compile`;
|
|
7883
|
+
return `is an overload set, and its ${which} returns '${checker.typeToString(retTs)}', which does not compile${slotReason(retTs, ctx, depth + 1, seen)}`;
|
|
7609
7884
|
}
|
|
7610
7885
|
return "is an overload set whose signatures do not join into one stored function (a void result beside a value result, or positions whose differing types do not cross the checked-dynamic boundary)";
|
|
7611
7886
|
}
|
|
@@ -7875,7 +8150,7 @@ function dictSpreadLiteralShape(widened, parts, ctx) {
|
|
|
7875
8150
|
return null;
|
|
7876
8151
|
if (![...arms.values()].some((arm) => !isUnitType(arm)))
|
|
7877
8152
|
return null;
|
|
7878
|
-
const sorted = [...arms.values()]
|
|
8153
|
+
const sorted = sortArms([...arms.values()]);
|
|
7879
8154
|
const slot = sorted.length === 1 ? sorted[0] : { kind: "union", unionId: unions.intern(sorted) };
|
|
7880
8155
|
return shapes.intern([], false, slot, []);
|
|
7881
8156
|
}
|
|
@@ -8137,7 +8412,7 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
8137
8412
|
slotDef.arms.some((a) => a.kind === "array" && a.elem.kind === "string") &&
|
|
8138
8413
|
slotDef.arms.every(armOk)) {
|
|
8139
8414
|
const armsRaw = [F64, STRING, arrayOf(STRING), UNDEFINED_T];
|
|
8140
|
-
armsRaw
|
|
8415
|
+
sortArms(armsRaw);
|
|
8141
8416
|
const canonical = { kind: "union", unionId: ctx.unions.intern(armsRaw) };
|
|
8142
8417
|
const fits = (t) => {
|
|
8143
8418
|
if (!t)
|
|
@@ -8370,7 +8645,11 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
8370
8645
|
if (accessorSlotProp(ts.symbolName(p)) !== null)
|
|
8371
8646
|
return null;
|
|
8372
8647
|
// an options record with `signal?: AbortSignal` must not turn its
|
|
8373
|
-
fields.push({
|
|
8648
|
+
fields.push({
|
|
8649
|
+
name: ts.symbolName(p),
|
|
8650
|
+
type: pt,
|
|
8651
|
+
...(optionalCheckedDyn(p, pt) ? { optional: true } : {}),
|
|
8652
|
+
});
|
|
8374
8653
|
}
|
|
8375
8654
|
// getPropertiesOfType yields DECLARATION order (interface/alias/literal
|
|
8376
8655
|
// source order) — captured before the canonical sort so Object.keys/
|
|
@@ -8582,7 +8861,7 @@ function mergePromiseArms(arms, ctx) {
|
|
|
8582
8861
|
: payload.every((arm) => armHasUnionHome(arm))
|
|
8583
8862
|
? {
|
|
8584
8863
|
kind: "union",
|
|
8585
|
-
unionId: ctx.unions.intern([...payload]
|
|
8864
|
+
unionId: ctx.unions.intern(sortArms([...payload])),
|
|
8586
8865
|
}
|
|
8587
8866
|
: null;
|
|
8588
8867
|
const merged = inner === null ? null : { kind: "promise", inner };
|
|
@@ -8618,14 +8897,37 @@ function armHasUnionHome(arm) {
|
|
|
8618
8897
|
return true;
|
|
8619
8898
|
}
|
|
8620
8899
|
}
|
|
8900
|
+
/** The deeper story of why an ABI slot (a container argument, union arm,
|
|
8901
|
+
* array/tuple element, function parameter or return type) does not compile,
|
|
8902
|
+
* as a tail for its "... does not compile" sentence: the record member or
|
|
8903
|
+
* nested component actually at fault. Empty when the slot's own type is the
|
|
8904
|
+
* blocker, which keeps the flat message. Naming the member matters for the
|
|
8905
|
+
* shapes a real program passes around — a 33-member `ExtensionAPI` is not a
|
|
8906
|
+
* useful answer. `depth` bounds the recursion over self-referential shapes
|
|
8907
|
+
* (`type F = (f: F) => void`); `innerBlockedMember`'s own `seen` set cannot
|
|
8908
|
+
* see across the describeComponentBlocker call. */
|
|
8909
|
+
function slotReason(t, ctx, depth, seen = new Set()) {
|
|
8910
|
+
// A self-referential shape (`type F = () => F`) reaches the same type
|
|
8911
|
+
// again at every step: saying the same sentence twice adds nothing.
|
|
8912
|
+
if (depth >= 3 || seen.has(t))
|
|
8913
|
+
return "";
|
|
8914
|
+
seen.add(t);
|
|
8915
|
+
const why = describeRecordMemberBlocker(t, ctx, depth, seen) ??
|
|
8916
|
+
describeComponentBlocker(t, ctx, depth + 1, seen);
|
|
8917
|
+
return why === null ? "" : `: ${why}`;
|
|
8918
|
+
}
|
|
8621
8919
|
/** When an unmapped type is a SUPPORTED container/composite whose failure
|
|
8622
8920
|
* lives in a component, answer a message tail naming the component (the
|
|
8623
8921
|
* SC2009 story); null when the shape itself is the blocker (the caller
|
|
8624
8922
|
* falls through to the other fences). Stdlib container heads (Map, Set,
|
|
8625
8923
|
* Promise, generators) ALWAYS answer — their shapes have lowerings, so a
|
|
8626
8924
|
* later "no lowering" claim about them would be false. */
|
|
8627
|
-
export function describeComponentBlocker(widened, ctx) {
|
|
8925
|
+
export function describeComponentBlocker(widened, ctx, depth = 0, inherited) {
|
|
8628
8926
|
const { checker } = ctx;
|
|
8927
|
+
// The type under description is already spoken for: a component that
|
|
8928
|
+
// leads back to it (`type F = () => F`) has nothing to add.
|
|
8929
|
+
const seen = inherited ?? new Set();
|
|
8930
|
+
seen.add(widened);
|
|
8629
8931
|
const text = (t) => checker.typeToString(t);
|
|
8630
8932
|
// Stdlib container references (provenance, not the name — a user's own
|
|
8631
8933
|
// `interface Map` is a record shape and keeps the record stories).
|
|
@@ -8643,7 +8945,7 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
8643
8945
|
const role = spec.role(i);
|
|
8644
8946
|
const mapped = mapType(arg, ctx);
|
|
8645
8947
|
if (!mapped) {
|
|
8646
|
-
return `the ${container} shape is supported, but its ${role} type '${text(arg)}' does not compile`;
|
|
8948
|
+
return `the ${container} shape is supported, but its ${role} type '${text(arg)}' does not compile${slotReason(arg, ctx, depth, seen)}`;
|
|
8647
8949
|
}
|
|
8648
8950
|
if ((container === "Map" || container === "ReadonlyMap") &&
|
|
8649
8951
|
i === 0 &&
|
|
@@ -8673,7 +8975,7 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
8673
8975
|
return null;
|
|
8674
8976
|
const elem = mapType(elemTs, ctx);
|
|
8675
8977
|
if (!elem) {
|
|
8676
|
-
return `the array shape is supported, but its element type '${text(elemTs)}' does not compile`;
|
|
8978
|
+
return `the array shape is supported, but its element type '${text(elemTs)}' does not compile${slotReason(elemTs, ctx, depth, seen)}`;
|
|
8677
8979
|
}
|
|
8678
8980
|
return `the array shape is supported, but '${text(elemTs)}' elements have no array representation yet`;
|
|
8679
8981
|
}
|
|
@@ -8686,7 +8988,7 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
8686
8988
|
if (et?.kind === "void" && isUnitOnlyTsType(arg, ctx.resolveTypeParam))
|
|
8687
8989
|
continue;
|
|
8688
8990
|
if (!et || et.kind === "void") {
|
|
8689
|
-
return `the tuple shape is supported, but its element type '${text(arg)}' does not compile`;
|
|
8991
|
+
return `the tuple shape is supported, but its element type '${text(arg)}' does not compile${slotReason(arg, ctx, depth, seen)}`;
|
|
8690
8992
|
}
|
|
8691
8993
|
}
|
|
8692
8994
|
return null;
|
|
@@ -8716,7 +9018,7 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
8716
9018
|
}
|
|
8717
9019
|
for (const { p: part, mapped } of mappedArms) {
|
|
8718
9020
|
if (!mapped) {
|
|
8719
|
-
return `the union shape is supported, but its arm '${text(part)}' does not compile`;
|
|
9021
|
+
return `the union shape is supported, but its arm '${text(part)}' does not compile${slotReason(part, ctx, depth, seen)}`;
|
|
8720
9022
|
}
|
|
8721
9023
|
if (!armHasUnionHome(mapped)) {
|
|
8722
9024
|
return `the union shape is supported, but '${text(part)}' arms have no home in a compiled union yet (no runtime narrowing test exists against sibling arms)`;
|
|
@@ -8758,12 +9060,12 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
8758
9060
|
for (const p of sig.getParameters()) {
|
|
8759
9061
|
const pTs = checker.getTypeOfSymbol(p);
|
|
8760
9062
|
if (!mapType(pTs, ctx)) {
|
|
8761
|
-
return `the function shape is supported, but its parameter '${ts.symbolName(p)}' has type '${text(pTs)}', which does not compile`;
|
|
9063
|
+
return `the function shape is supported, but its parameter '${ts.symbolName(p)}' has type '${text(pTs)}', which does not compile${slotReason(pTs, ctx, depth, seen)}`;
|
|
8762
9064
|
}
|
|
8763
9065
|
}
|
|
8764
9066
|
const retTs = checker.getReturnTypeOfSignature(sig);
|
|
8765
9067
|
if ((retTs.flags & ts.TypeFlags.Never) === 0 && !mapType(retTs, ctx)) {
|
|
8766
|
-
return `the function shape is supported, but its return type '${text(retTs)}' does not compile`;
|
|
9068
|
+
return `the function shape is supported, but its return type '${text(retTs)}' does not compile${slotReason(retTs, ctx, depth, seen)}`;
|
|
8767
9069
|
}
|
|
8768
9070
|
return null;
|
|
8769
9071
|
}
|
|
@@ -8774,8 +9076,10 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
8774
9076
|
* signature routing, so what reaches it is a plain data shape; a null
|
|
8775
9077
|
* answer (no member pinpointed — provenance fences, accessor rules, shape
|
|
8776
9078
|
* knots) keeps the residual SC2001 story. */
|
|
8777
|
-
export function describeRecordMemberBlocker(widened, ctx) {
|
|
9079
|
+
export function describeRecordMemberBlocker(widened, ctx, depth = 0, inherited) {
|
|
8778
9080
|
const { checker } = ctx;
|
|
9081
|
+
const seen = inherited ?? new Set();
|
|
9082
|
+
seen.add(widened);
|
|
8779
9083
|
if ((widened.flags & ts.TypeFlags.Object) === 0)
|
|
8780
9084
|
return null;
|
|
8781
9085
|
if (checker.getCallSignatures(widened).length > 0)
|
|
@@ -8811,7 +9115,7 @@ export function describeRecordMemberBlocker(widened, ctx) {
|
|
|
8811
9115
|
if (isOverloadedCallableMemberType(fieldTs, checker)) {
|
|
8812
9116
|
if (erasedOverloadMemberType(fieldTs, ctx) !== undefined)
|
|
8813
9117
|
continue;
|
|
8814
|
-
return `the record shape is supported, but its member '${ts.symbolName(p)}' ${describeOverloadSetBlocker(fieldTs, ctx)}`;
|
|
9118
|
+
return `the record shape is supported, but its member '${ts.symbolName(p)}' ${describeOverloadSetBlocker(fieldTs, ctx, depth, seen)}`;
|
|
8815
9119
|
}
|
|
8816
9120
|
if (memberMaps(fieldTs, ctx, p))
|
|
8817
9121
|
continue;
|
|
@@ -8820,7 +9124,7 @@ export function describeRecordMemberBlocker(widened, ctx) {
|
|
|
8820
9124
|
// its outermost member.
|
|
8821
9125
|
const inner = innerBlockedMember(fieldTs, ctx, new Set());
|
|
8822
9126
|
if (inner !== null && inner.path !== "") {
|
|
8823
|
-
return `the record shape is supported, but its member '${ts.symbolName(p)}${inner.path}' has type '${checker.typeToString(inner.type)}', which does not compile`;
|
|
9127
|
+
return `the record shape is supported, but its member '${ts.symbolName(p)}${inner.path}' has type '${checker.typeToString(inner.type)}', which does not compile${slotReason(inner.type, ctx, depth + 1, seen)}`;
|
|
8824
9128
|
}
|
|
8825
9129
|
return `the record shape is supported, but its member '${ts.symbolName(p)}' has type '${checker.typeToString(fieldTs)}', which does not compile`;
|
|
8826
9130
|
}
|
|
@@ -8859,8 +9163,8 @@ function memberMaps(fieldTs, ctx, member) {
|
|
|
8859
9163
|
}
|
|
8860
9164
|
/** The member path inside the unmapped type `t` that its failure comes
|
|
8861
9165
|
* from, and that member's type: `.name` steps into record members, `[]`
|
|
8862
|
-
* into array elements, `()` into a function
|
|
8863
|
-
* promise payloads are transparent. The empty path means `t` itself is
|
|
9166
|
+
* into array elements, `(param)` into a function parameter, `()` into a
|
|
9167
|
+
* function's return; union arms and promise payloads are transparent. The empty path means `t` itself is
|
|
8864
9168
|
* the blocker; null means `t` maps (or is `any`). */
|
|
8865
9169
|
function innerBlockedMember(t, ctx, seen) {
|
|
8866
9170
|
const { checker } = ctx;
|
|
@@ -8902,8 +9206,14 @@ function innerBlockedMember(t, ctx, seen) {
|
|
|
8902
9206
|
const sig = calls[0];
|
|
8903
9207
|
if (sig.getTypeParameters().length > 0)
|
|
8904
9208
|
return here;
|
|
8905
|
-
|
|
8906
|
-
|
|
9209
|
+
// A parameter carries the failure as often as the result does (an
|
|
9210
|
+
// event handler's `ctx`, a factory's `theme`): name that parameter's
|
|
9211
|
+
// slot instead of stopping at the function.
|
|
9212
|
+
for (const param of sig.getParameters()) {
|
|
9213
|
+
const paramTs = checker.getTypeOfSymbol(param);
|
|
9214
|
+
if (mapType(paramTs, ctx) === null)
|
|
9215
|
+
return step(`(${ts.symbolName(param)})`, paramTs);
|
|
9216
|
+
}
|
|
8907
9217
|
return step("()", checker.getReturnTypeOfSignature(sig));
|
|
8908
9218
|
}
|
|
8909
9219
|
if (calls.length > 0 ||
|