@scriptc/compiler 0.1.6 → 0.2.0
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 +73 -25
- package/ambient/scriptc-overrides.d.ts +10 -6
- package/ambient/scriptc.d.ts +28 -5
- package/dist/backend/build-cache.d.ts +1 -3
- package/dist/backend/build-cache.js +3 -22
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/cache-root.d.ts +3 -0
- package/dist/backend/cache-root.js +23 -0
- package/dist/backend/cache-root.js.map +1 -0
- package/dist/backend/cycle-analysis.d.ts +15 -0
- package/dist/backend/cycle-analysis.js +107 -0
- package/dist/backend/cycle-analysis.js.map +1 -0
- package/dist/backend/cycle-analysis.test.js +124 -0
- package/dist/backend/cycle-analysis.test.js.map +1 -0
- package/dist/backend/debug-symbols.d.ts +8 -0
- package/dist/backend/debug-symbols.js +52 -0
- package/dist/backend/debug-symbols.js.map +1 -0
- package/dist/backend/executable-features.d.ts +4 -0
- package/dist/backend/executable-features.js +42 -0
- package/dist/backend/executable-features.js.map +1 -0
- package/dist/backend/external-c.d.ts +5 -27
- package/dist/backend/external-c.js +5 -40
- package/dist/backend/external-c.js.map +1 -1
- package/dist/backend/ffi-callbacks.d.ts +2 -3
- package/dist/backend/ffi-callbacks.js +2 -3
- package/dist/backend/ffi-callbacks.js.map +1 -1
- package/dist/backend/library-identity-markers.d.ts +4 -9
- package/dist/backend/library-identity-markers.js +11 -49
- package/dist/backend/library-identity-markers.js.map +1 -1
- package/dist/backend/library-pack.d.ts +5 -0
- package/dist/backend/library-pack.js +123 -0
- package/dist/backend/library-pack.js.map +1 -0
- package/dist/backend/link-plan-core.d.ts +20 -0
- package/dist/backend/link-plan-core.js +18 -0
- package/dist/backend/link-plan-core.js.map +1 -0
- package/dist/backend/link-plan.d.ts +2 -1
- package/dist/backend/link-plan.js +18 -17
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/link-trace.d.ts +2 -0
- package/dist/backend/link-trace.js +24 -0
- package/dist/backend/link-trace.js.map +1 -0
- package/dist/backend/linker.js +9 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/literals.d.ts +9 -0
- package/dist/backend/literals.js +35 -0
- package/dist/backend/literals.js.map +1 -0
- package/dist/backend/literals.test.d.ts +1 -0
- package/dist/backend/literals.test.js +53 -0
- package/dist/backend/literals.test.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +4 -0
- package/dist/backend/llvm/blocks.js +25 -4
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/blocks.test.d.ts +1 -0
- package/dist/backend/llvm/blocks.test.js +91 -0
- package/dist/backend/llvm/blocks.test.js.map +1 -0
- package/dist/backend/llvm/classes.d.ts +14 -8
- package/dist/backend/llvm/classes.js +70 -28
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +5 -1
- package/dist/backend/llvm/common.js +45 -4
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/debug-info.d.ts +32 -0
- package/dist/backend/llvm/debug-info.js +198 -0
- package/dist/backend/llvm/debug-info.js.map +1 -0
- package/dist/backend/llvm/debug-info.test.d.ts +1 -0
- package/dist/backend/llvm/debug-info.test.js +110 -0
- package/dist/backend/llvm/debug-info.test.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +16 -2
- package/dist/backend/llvm/dyn.js +498 -175
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +598 -1
- package/dist/backend/llvm/emitter.js +739 -409
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.d.ts +1 -0
- package/dist/backend/llvm/emitter.test.js +179 -0
- package/dist/backend/llvm/emitter.test.js.map +1 -0
- package/dist/backend/llvm/expr-async.js +23 -14
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +1 -1
- package/dist/backend/llvm/expr-bytes.js +32 -14
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +1 -1
- package/dist/backend/llvm/expr-callbacks.js +25 -22
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +136 -35
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +1 -1
- package/dist/backend/llvm/expr-containers.js +43 -14
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +5 -260
- package/dist/backend/llvm/expr-control.js +9 -5
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.d.ts +1 -1
- package/dist/backend/llvm/expr-dispatch.js +2 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +72 -74
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-island.d.ts +1 -1
- package/dist/backend/llvm/expr-island.js +11 -7
- package/dist/backend/llvm/expr-island.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +1 -1
- package/dist/backend/llvm/expr-primitives.js +51 -30
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +1 -1
- package/dist/backend/llvm/expr-records.d.ts +5 -1
- package/dist/backend/llvm/expr-records.js +43 -4
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +4 -4
- package/dist/backend/llvm/expr-stream-bridges.js +102 -121
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.d.ts +1 -0
- package/dist/backend/llvm/expr-stream-bridges.test.js +55 -0
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -0
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.js +12 -12
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/layouts.d.ts +19 -0
- package/dist/backend/llvm/layouts.js +12 -0
- package/dist/backend/llvm/layouts.js.map +1 -0
- package/dist/backend/llvm/lib-abi.d.ts +19 -0
- package/dist/backend/llvm/lib-abi.js +82 -0
- package/dist/backend/llvm/lib-abi.js.map +1 -0
- package/dist/backend/llvm/lib-connect.d.ts +2 -0
- package/dist/backend/llvm/lib-connect.js +51 -0
- package/dist/backend/llvm/lib-connect.js.map +1 -0
- package/dist/backend/llvm/lib-datagram.d.ts +2 -0
- package/dist/backend/llvm/lib-datagram.js +135 -0
- package/dist/backend/llvm/lib-datagram.js.map +1 -0
- package/dist/backend/llvm/lib-dispatch.js +50 -6
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +59 -18
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.d.ts +2 -0
- package/dist/backend/llvm/lib-http2.js +215 -0
- package/dist/backend/llvm/lib-http2.js.map +1 -0
- package/dist/backend/llvm/lib-lookup.d.ts +2 -0
- package/dist/backend/llvm/lib-lookup.js +39 -0
- package/dist/backend/llvm/lib-lookup.js.map +1 -0
- package/dist/backend/llvm/lib-network.js +25 -2
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +21 -16
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +125 -1
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +3 -2
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/lib-test.d.ts +2 -0
- package/dist/backend/llvm/lib-test.js +34 -0
- package/dist/backend/llvm/lib-test.js.map +1 -0
- package/dist/backend/llvm/lib-tls.d.ts +2 -0
- package/dist/backend/llvm/lib-tls.js +82 -0
- package/dist/backend/llvm/lib-tls.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +10 -9
- package/dist/backend/llvm/shapes.js +35 -130
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/split.js +4 -1
- package/dist/backend/llvm/split.js.map +1 -1
- package/dist/backend/llvm/split.test.js +26 -1
- package/dist/backend/llvm/split.test.js.map +1 -1
- package/dist/backend/llvm/unsupported.d.ts +1 -0
- package/dist/backend/llvm/unsupported.js +1 -2
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.js +1 -7
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/mangle.d.ts +2 -2
- package/dist/backend/mangle.js +16 -5
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/{c/may-throw.d.ts → may-throw.d.ts} +1 -1
- package/dist/backend/{c/may-throw.js → may-throw.js} +51 -46
- package/dist/backend/may-throw.js.map +1 -0
- package/dist/backend/may-throw.test.d.ts +1 -0
- package/dist/backend/may-throw.test.js +58 -0
- package/dist/backend/may-throw.test.js.map +1 -0
- package/dist/backend/native-codegen-core.d.ts +22 -0
- package/dist/backend/native-codegen-core.js +44 -0
- package/dist/backend/native-codegen-core.js.map +1 -0
- package/dist/backend/native-codegen.d.ts +3 -19
- package/dist/backend/native-codegen.js +5 -44
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +2 -2
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +94 -0
- package/dist/backend/native-link-info-core.js +62 -0
- package/dist/backend/native-link-info-core.js.map +1 -0
- package/dist/backend/native-link-info.d.ts +3 -88
- package/dist/backend/native-link-info.js +12 -243
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-link-info.test.js +41 -146
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +10 -25
- package/dist/backend/native-toolchain.js +89 -219
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +15 -5
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/native-tools.d.ts +24 -0
- package/dist/backend/native-tools.js +33 -0
- package/dist/backend/native-tools.js.map +1 -0
- package/dist/backend/object-localize.js +19 -8
- package/dist/backend/object-localize.js.map +1 -1
- package/dist/backend/object-localize.test.js +22 -0
- package/dist/backend/object-localize.test.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +101 -0
- package/dist/backend/runtime-pack-core.js +172 -0
- package/dist/backend/runtime-pack-core.js.map +1 -0
- package/dist/backend/runtime-pack-native.d.ts +21 -0
- package/dist/backend/runtime-pack-native.js +70 -0
- package/dist/backend/runtime-pack-native.js.map +1 -0
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack.d.ts +3 -83
- package/dist/backend/runtime-pack.js +8 -151
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +24 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/source-locations.d.ts +12 -0
- package/dist/backend/source-locations.js +32 -0
- package/dist/backend/source-locations.js.map +1 -0
- package/dist/backend/source-locations.test.d.ts +1 -0
- package/dist/backend/source-locations.test.js +16 -0
- package/dist/backend/source-locations.test.js.map +1 -0
- package/dist/backend/target-diagnostics.d.ts +22 -0
- package/dist/backend/target-diagnostics.js +108 -0
- package/dist/backend/target-diagnostics.js.map +1 -0
- package/dist/backend/target-platform.d.ts +15 -0
- package/dist/backend/target-platform.js +72 -0
- package/dist/backend/target-platform.js.map +1 -0
- package/dist/backend/targets.d.ts +13 -4
- package/dist/backend/targets.js +95 -30
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +65 -4
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/backend/toolchain-environment.d.ts +6 -0
- package/dist/backend/toolchain-environment.js +99 -0
- package/dist/backend/toolchain-environment.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +1 -9
- package/dist/backend/vendor-archives.js +2 -9
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +9 -0
- package/dist/backend/vendor-inputs.js +10 -0
- package/dist/backend/vendor-inputs.js.map +1 -0
- package/dist/backend/warm-cache.d.ts +3 -0
- package/dist/backend/warm-cache.js +41 -0
- package/dist/backend/warm-cache.js.map +1 -0
- package/dist/cli/command.d.ts +3 -0
- package/dist/cli/command.js +328 -0
- package/dist/cli/command.js.map +1 -0
- package/dist/cli/host.d.ts +24 -0
- package/dist/cli/host.js +2 -0
- package/dist/cli/host.js.map +1 -0
- package/dist/cli/output-options.d.ts +26 -0
- package/dist/cli/output-options.js +60 -0
- package/dist/cli/output-options.js.map +1 -0
- package/dist/cli/paths.d.ts +12 -0
- package/dist/cli/paths.js +42 -0
- package/dist/cli/paths.js.map +1 -0
- package/dist/cli/usage.d.ts +74 -0
- package/dist/cli/usage.js +86 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/cli/wasi-paths.d.ts +8 -0
- package/dist/cli/wasi-paths.js +41 -0
- package/dist/cli/wasi-paths.js.map +1 -0
- package/dist/cli/wasi-runner.d.ts +2 -0
- package/dist/cli/wasi-runner.js +28 -0
- package/dist/cli/wasi-runner.js.map +1 -0
- package/dist/compat/fetch-profile.js +3 -3
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +162 -0
- package/dist/compile-types.js +2 -0
- package/dist/compile-types.js.map +1 -0
- package/dist/coverage/report.js +11 -5
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +5 -2
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +4 -0
- package/dist/diagnostics/diagnostic.js +15 -3
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -4
- package/dist/executable/executable-cache.js +33 -10
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +38 -16
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +14 -0
- package/dist/executable/prepare.js +66 -0
- package/dist/executable/prepare.js.map +1 -0
- package/dist/ffi/ffi-manifest.d.ts +11 -4
- package/dist/ffi/ffi-manifest.js +170 -58
- package/dist/ffi/ffi-manifest.js.map +1 -1
- package/dist/ffi/ffi-manifest.test.d.ts +1 -0
- package/dist/ffi/ffi-manifest.test.js +111 -0
- package/dist/ffi/ffi-manifest.test.js.map +1 -0
- package/dist/format-integer.d.ts +3 -0
- package/dist/format-integer.js +14 -0
- package/dist/format-integer.js.map +1 -0
- package/dist/frontend/analysis.d.ts +5 -0
- package/dist/frontend/analysis.js +88 -0
- package/dist/frontend/analysis.js.map +1 -0
- package/dist/frontend/arguments-usage.d.ts +4 -0
- package/dist/frontend/arguments-usage.js +40 -0
- package/dist/frontend/arguments-usage.js.map +1 -0
- package/dist/frontend/binding-source.d.ts +4 -0
- package/dist/frontend/binding-source.js +18 -0
- package/dist/frontend/binding-source.js.map +1 -0
- package/dist/frontend/builtin-modules.d.ts +1 -1
- package/dist/frontend/builtin-modules.js +1 -1
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/cjs-lexer.d.ts +4 -25
- package/dist/frontend/cjs-lexer.js +6 -806
- package/dist/frontend/cjs-lexer.js.map +1 -1
- package/dist/frontend/cjs-resolve.d.ts +5 -0
- package/dist/frontend/cjs-resolve.js +429 -0
- package/dist/frontend/cjs-resolve.js.map +1 -0
- package/dist/frontend/cjs-syntax.d.ts +26 -0
- package/dist/frontend/cjs-syntax.js +806 -0
- package/dist/frontend/cjs-syntax.js.map +1 -0
- package/dist/frontend/comptime-node.d.ts +4 -0
- package/dist/frontend/comptime-node.js +16 -0
- package/dist/frontend/comptime-node.js.map +1 -0
- package/dist/frontend/comptime-node.test.d.ts +1 -0
- package/dist/frontend/comptime-node.test.js +37 -0
- package/dist/frontend/comptime-node.test.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +3 -4
- package/dist/frontend/dts-paths.js +15 -8
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/fork-target.js +2 -2
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/helper-tokens.d.ts +1 -0
- package/dist/frontend/helper-tokens.js +147 -0
- package/dist/frontend/helper-tokens.js.map +1 -0
- package/dist/frontend/helper-tokens.test.d.ts +1 -0
- package/dist/frontend/helper-tokens.test.js +35 -0
- package/dist/frontend/helper-tokens.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.d.ts +5 -0
- package/dist/frontend/inferred-js-diagnostics.js +69 -0
- package/dist/frontend/inferred-js-diagnostics.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.d.ts +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +58 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -0
- package/dist/frontend/input-tracker.d.ts +5 -2
- package/dist/frontend/input-tracker.js +24 -3
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +23 -0
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lib-contract.js +32 -24
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/literal-values.d.ts +4 -0
- package/dist/frontend/literal-values.js +21 -0
- package/dist/frontend/literal-values.js.map +1 -0
- package/dist/frontend/literal-values.test.d.ts +1 -0
- package/dist/frontend/literal-values.test.js +91 -0
- package/dist/frontend/literal-values.test.js.map +1 -0
- package/dist/frontend/lowering/abstract-equality.d.ts +1 -1
- package/dist/frontend/lowering/abstract-equality.js +3 -0
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.js +11 -6
- package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
- package/dist/frontend/lowering/array-values.d.ts +4 -1
- package/dist/frontend/lowering/array-values.js +43 -1
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/callback-arg.js +1 -0
- package/dist/frontend/lowering/callback-arg.js.map +1 -1
- package/dist/frontend/lowering/class-callbacks.d.ts +12 -0
- package/dist/frontend/lowering/class-callbacks.js +63 -0
- package/dist/frontend/lowering/class-callbacks.js.map +1 -0
- package/dist/frontend/lowering/class-descriptors.d.ts +9 -0
- package/dist/frontend/lowering/class-descriptors.js +73 -0
- package/dist/frontend/lowering/class-descriptors.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +41 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +803 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.d.ts +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +92 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -0
- package/dist/frontend/lowering/class-instance-constructor.d.ts +7 -0
- package/dist/frontend/lowering/class-instance-constructor.js +64 -0
- package/dist/frontend/lowering/class-instance-constructor.js.map +1 -0
- package/dist/frontend/lowering/class-method-values.d.ts +10 -0
- package/dist/frontend/lowering/class-method-values.js +170 -0
- package/dist/frontend/lowering/class-method-values.js.map +1 -0
- package/dist/frontend/lowering/class-prototypes.d.ts +16 -0
- package/dist/frontend/lowering/class-prototypes.js +134 -0
- package/dist/frontend/lowering/class-prototypes.js.map +1 -0
- package/dist/frontend/lowering/class-static-data.d.ts +6 -0
- package/dist/frontend/lowering/class-static-data.js +56 -0
- package/dist/frontend/lowering/class-static-data.js.map +1 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.d.ts +4 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.js +26 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.js.map +1 -0
- package/dist/frontend/lowering/containers/bytes.d.ts +11 -7
- package/dist/frontend/lowering/containers/bytes.js +164 -155
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +2 -2
- package/dist/frontend/lowering/containers/string-and-regexp.js +39 -16
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.d.ts +7 -0
- package/dist/frontend/lowering/containers/string-replacement.js +217 -0
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -0
- package/dist/frontend/lowering/error-methods.d.ts +11 -0
- package/dist/frontend/lowering/error-methods.js +78 -0
- package/dist/frontend/lowering/error-methods.js.map +1 -0
- package/dist/frontend/lowering/expressions/global-symbols.d.ts +6 -0
- package/dist/frontend/lowering/expressions/global-symbols.js +11 -0
- package/dist/frontend/lowering/expressions/global-symbols.js.map +1 -0
- package/dist/frontend/lowering/expressions/native-proxy.d.ts +7 -0
- package/dist/frontend/lowering/expressions/native-proxy.js +49 -0
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.d.ts +6 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js +124 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -0
- package/dist/frontend/lowering/expressions/object-literals.d.ts +8 -8
- package/dist/frontend/lowering/expressions/object-literals.js +485 -185
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +5 -6
- package/dist/frontend/lowering/expressions/optional-chains.js +27 -14
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/try-lower-expression.js +1 -0
- package/dist/frontend/lowering/expressions/try-lower-expression.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-field-write.d.ts +8 -0
- package/dist/frontend/lowering/expressions/union-field-write.js +71 -0
- package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -0
- package/dist/frontend/lowering/function-context.d.ts +93 -0
- package/dist/frontend/lowering/function-context.js +103 -0
- package/dist/frontend/lowering/function-context.js.map +1 -0
- package/dist/frontend/lowering/generator-delegation.d.ts +7 -0
- package/dist/frontend/lowering/generator-delegation.js +85 -0
- package/dist/frontend/lowering/generator-delegation.js.map +1 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +10 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +105 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.d.ts +2 -1
- package/dist/frontend/lowering/lib-boundary.js +59 -20
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.test.d.ts +1 -0
- package/dist/frontend/lowering/lib-boundary.test.js +45 -0
- package/dist/frontend/lowering/lib-boundary.test.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +1 -1
- package/dist/frontend/lowering/lower-assert.d.ts +1 -1
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +12 -0
- package/dist/frontend/lowering/lower-builtin-values.js +139 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -0
- package/dist/frontend/lowering/lower-builtins.d.ts +27 -41
- package/dist/frontend/lowering/lower-builtins.js +553 -346
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +22 -26
- package/dist/frontend/lowering/lower-calls.js +1373 -380
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +83 -45
- package/dist/frontend/lowering/lower-classes.js +952 -339
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
- package/dist/frontend/lowering/lower-comptime.js +23 -32
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +27 -32
- package/dist/frontend/lowering/lower-containers.js +796 -151
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.d.ts +1 -1
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.d.ts +1 -1
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +30 -1
- package/dist/frontend/lowering/lower-event-emitter.js +58 -26
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.d.ts +7 -1
- package/dist/frontend/lowering/lower-expando.js +14 -6
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +35 -11
- package/dist/frontend/lowering/lower-exprs.js +1785 -790
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +2 -5
- package/dist/frontend/lowering/lower-generators.js +77 -46
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +7 -0
- package/dist/frontend/lowering/lower-global-value.js +17 -0
- package/dist/frontend/lowering/lower-global-value.js.map +1 -0
- package/dist/frontend/lowering/lower-inspect.d.ts +1 -1
- package/dist/frontend/lowering/lower-inspect.js +17 -8
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +5 -8
- package/dist/frontend/lowering/lower-island.js +34 -23
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.d.ts +2 -2
- package/dist/frontend/lowering/lower-mixins.js +5 -3
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +1 -1
- package/dist/frontend/lowering/lower-modules.js +252 -38
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +1 -1
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-module.d.ts +1 -1
- package/dist/frontend/lowering/lower-node-module.js +13 -10
- package/dist/frontend/lowering/lower-node-module.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +1 -1
- package/dist/frontend/lowering/lower-server.js +6 -10
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +10 -14
- package/dist/frontend/lowering/lower-stmts.js +731 -532
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +1 -1
- package/dist/frontend/lowering/lower-stream.js +19 -10
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.d.ts +1 -1
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lower-url.d.ts +6 -0
- package/dist/frontend/lowering/lower-url.js +77 -0
- package/dist/frontend/lowering/lower-url.js.map +1 -0
- package/dist/frontend/lowering/lowerer.d.ts +113 -189
- package/dist/frontend/lowering/lowerer.js +1033 -663
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.d.ts +1 -0
- package/dist/frontend/lowering/lowerer.test.js +26 -0
- package/dist/frontend/lowering/lowerer.test.js.map +1 -0
- package/dist/frontend/lowering/native-ffi.d.ts +5 -0
- package/dist/frontend/lowering/native-ffi.js +40 -0
- package/dist/frontend/lowering/native-ffi.js.map +1 -0
- package/dist/frontend/lowering/object-enumeration-receiver.d.ts +7 -0
- package/dist/frontend/lowering/object-enumeration-receiver.js +33 -0
- package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -0
- package/dist/frontend/lowering/object-factory-new.d.ts +8 -0
- package/dist/frontend/lowering/object-factory-new.js +68 -0
- package/dist/frontend/lowering/object-factory-new.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.js +6 -1
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/pairs-snapshot.js +2 -1
- package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-locals.d.ts +14 -0
- package/dist/frontend/lowering/runtime-optional-locals.js +41 -0
- package/dist/frontend/lowering/runtime-optional-locals.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.d.ts +1 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.js +85 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.js.map +1 -0
- package/dist/frontend/lowering/sanitize-class-types.d.ts +8 -0
- package/dist/frontend/lowering/sanitize-class-types.js +79 -0
- package/dist/frontend/lowering/sanitize-class-types.js.map +1 -0
- package/dist/frontend/lowering/sanitize-class-types.test.d.ts +1 -0
- package/dist/frontend/lowering/sanitize-class-types.test.js +60 -0
- package/dist/frontend/lowering/sanitize-class-types.test.js.map +1 -0
- package/dist/frontend/lowering/static-this.d.ts +5 -1
- package/dist/frontend/lowering/static-this.js +28 -2
- package/dist/frontend/lowering/static-this.js.map +1 -1
- package/dist/frontend/lowering/string-index.d.ts +7 -0
- package/dist/frontend/lowering/string-index.js +39 -0
- package/dist/frontend/lowering/string-index.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +9 -4
- package/dist/frontend/lowering/surfaces.js +98 -35
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/symbol-fields.d.ts +22 -0
- package/dist/frontend/lowering/symbol-fields.js +183 -0
- package/dist/frontend/lowering/symbol-fields.js.map +1 -0
- package/dist/frontend/lowering/symbol-methods.d.ts +7 -0
- package/dist/frontend/lowering/symbol-methods.js +30 -0
- package/dist/frontend/lowering/symbol-methods.js.map +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.d.ts +10 -0
- package/dist/frontend/lowering/text-decoder-encoding.js +77 -0
- package/dist/frontend/lowering/text-decoder-encoding.js.map +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.d.ts +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.js +38 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.js.map +1 -0
- package/dist/frontend/lowering/union-narrow.d.ts +9 -0
- package/dist/frontend/lowering/union-narrow.js +59 -0
- package/dist/frontend/lowering/union-narrow.js.map +1 -0
- package/dist/frontend/lowering/union-narrow.test.d.ts +1 -0
- package/dist/frontend/lowering/union-narrow.test.js +72 -0
- package/dist/frontend/lowering/union-narrow.test.js.map +1 -0
- package/dist/frontend/lowering/union-retag.d.ts +43 -0
- package/dist/frontend/lowering/union-retag.js +259 -0
- package/dist/frontend/lowering/union-retag.js.map +1 -0
- package/dist/frontend/lowering/union-retag.test.d.ts +1 -0
- package/dist/frontend/lowering/union-retag.test.js +405 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -0
- package/dist/frontend/lowering/unregistered-class-types.d.ts +14 -0
- package/dist/frontend/lowering/unregistered-class-types.js +94 -0
- package/dist/frontend/lowering/unregistered-class-types.js.map +1 -0
- package/dist/frontend/lowering/unregistered-class-types.test.d.ts +1 -0
- package/dist/frontend/lowering/unregistered-class-types.test.js +65 -0
- package/dist/frontend/lowering/unregistered-class-types.test.js.map +1 -0
- package/dist/frontend/lowering/width-lift.d.ts +40 -0
- package/dist/frontend/lowering/width-lift.js +2 -0
- package/dist/frontend/lowering/width-lift.js.map +1 -0
- package/dist/frontend/module-syntax.d.ts +58 -0
- package/dist/frontend/module-syntax.js +123 -0
- package/dist/frontend/module-syntax.js.map +1 -0
- package/dist/frontend/module-syntax.test.d.ts +1 -0
- package/dist/frontend/module-syntax.test.js +78 -0
- package/dist/frontend/module-syntax.test.js.map +1 -0
- package/dist/frontend/npm-fetch-analysis.d.ts +17 -0
- package/dist/frontend/npm-fetch-analysis.js +100 -0
- package/dist/frontend/npm-fetch-analysis.js.map +1 -0
- package/dist/frontend/npm-fetch-analysis.test.d.ts +1 -0
- package/dist/frontend/npm-fetch-analysis.test.js +107 -0
- package/dist/frontend/npm-fetch-analysis.test.js.map +1 -0
- package/dist/frontend/npm-fetch-node.d.ts +2 -0
- package/dist/frontend/npm-fetch-node.js +12 -0
- package/dist/frontend/npm-fetch-node.js.map +1 -0
- package/dist/frontend/npm-fetch-syntax.d.ts +6 -0
- package/dist/frontend/npm-fetch-syntax.js +207 -0
- package/dist/frontend/npm-fetch-syntax.js.map +1 -0
- package/dist/frontend/npm-node.d.ts +10 -0
- package/dist/frontend/npm-node.js +14 -0
- package/dist/frontend/npm-node.js.map +1 -0
- package/dist/frontend/npm-static-bundled-cjs.d.ts +8 -0
- package/dist/frontend/npm-static-bundled-cjs.js +236 -0
- package/dist/frontend/npm-static-bundled-cjs.js.map +1 -0
- package/dist/frontend/npm-static-bundled-cjs.test.d.ts +1 -0
- package/dist/frontend/npm-static-bundled-cjs.test.js +69 -0
- package/dist/frontend/npm-static-bundled-cjs.test.js.map +1 -0
- package/dist/frontend/npm-static-declaration-syntax.d.ts +57 -0
- package/dist/frontend/npm-static-declaration-syntax.js +944 -0
- package/dist/frontend/npm-static-declaration-syntax.js.map +1 -0
- package/dist/frontend/npm-static-declarations.d.ts +11 -39
- package/dist/frontend/npm-static-declarations.js +22 -561
- package/dist/frontend/npm-static-declarations.js.map +1 -1
- package/dist/frontend/npm-static-declarations.test.js +245 -6
- package/dist/frontend/npm-static-declarations.test.js.map +1 -1
- package/dist/frontend/npm-static-prune.d.ts +1 -1
- package/dist/frontend/npm-static-prune.js +5 -4
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-prune.test.js +1 -1
- package/dist/frontend/npm-static-prune.test.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-host.d.ts +4 -0
- package/dist/frontend/npm-static-rewrite-host.js +179 -0
- package/dist/frontend/npm-static-rewrite-host.js.map +1 -0
- package/dist/frontend/npm-static-rewrite-syntax.d.ts +16 -0
- package/dist/frontend/npm-static-rewrite-syntax.js +905 -0
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -0
- package/dist/frontend/npm-static-rewrite.d.ts +0 -5
- package/dist/frontend/npm-static-rewrite.js +2 -1079
- package/dist/frontend/npm-static-rewrite.js.map +1 -1
- package/dist/frontend/npm-static-subtyping.d.ts +5 -0
- package/dist/frontend/npm-static-subtyping.js +55 -0
- package/dist/frontend/npm-static-subtyping.js.map +1 -0
- package/dist/frontend/npm-static-subtyping.test.d.ts +1 -0
- package/dist/frontend/npm-static-subtyping.test.js +58 -0
- package/dist/frontend/npm-static-subtyping.test.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +7 -15
- package/dist/frontend/npm-static.js +19 -28
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +8 -69
- package/dist/frontend/npm.js +21 -361
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +2 -2
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.d.ts +6 -0
- package/dist/frontend/pipeline-native.js +32 -0
- package/dist/frontend/pipeline-native.js.map +1 -0
- package/dist/frontend/pipeline.d.ts +54 -0
- package/dist/frontend/pipeline.js +382 -0
- package/dist/frontend/pipeline.js.map +1 -0
- package/dist/frontend/pipeline.test.d.ts +1 -0
- package/dist/frontend/pipeline.test.js +77 -0
- package/dist/frontend/pipeline.test.js.map +1 -0
- package/dist/frontend/program-analysis.d.ts +10 -0
- package/dist/frontend/program-analysis.js +14 -0
- package/dist/frontend/program-analysis.js.map +1 -0
- package/dist/frontend/program-node.d.ts +9 -0
- package/dist/frontend/program-node.js +48 -0
- package/dist/frontend/program-node.js.map +1 -0
- package/dist/frontend/program.d.ts +43 -19
- package/dist/frontend/program.js +556 -197
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.d.ts +1 -0
- package/dist/frontend/program.test.js +202 -0
- package/dist/frontend/program.test.js.map +1 -0
- package/dist/frontend/provenance-core.d.ts +9 -0
- package/dist/frontend/provenance-core.js +435 -0
- package/dist/frontend/provenance-core.js.map +1 -0
- package/dist/frontend/provenance.d.ts +0 -4
- package/dist/frontend/provenance.js +4 -459
- package/dist/frontend/provenance.js.map +1 -1
- package/dist/frontend/resolve.d.ts +3 -1
- package/dist/frontend/resolve.js +6 -3
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.d.ts +4 -3
- package/dist/frontend/runtime-resolve.js +22 -18
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.test.js +53 -0
- package/dist/frontend/runtime-resolve.test.js.map +1 -1
- package/dist/frontend/services-node.d.ts +5 -0
- package/dist/frontend/services-node.js +19 -0
- package/dist/frontend/services-node.js.map +1 -0
- package/dist/frontend/services-node.test.d.ts +1 -0
- package/dist/frontend/services-node.test.js +70 -0
- package/dist/frontend/services-node.test.js.map +1 -0
- package/dist/frontend/services.d.ts +44 -0
- package/dist/frontend/services.js +90 -0
- package/dist/frontend/services.js.map +1 -0
- package/dist/frontend/services.test.d.ts +1 -0
- package/dist/frontend/services.test.js +174 -0
- package/dist/frontend/services.test.js.map +1 -0
- package/dist/frontend/ts7/adapter.d.ts +3 -3
- package/dist/frontend/ts7/adapter.js +14 -31
- package/dist/frontend/ts7/adapter.js.map +1 -1
- package/dist/frontend/ts7/api.d.ts +16 -0
- package/dist/frontend/ts7/api.js +24 -0
- package/dist/frontend/ts7/api.js.map +1 -0
- package/dist/frontend/ts7/ast-bytes.d.ts +31 -0
- package/dist/frontend/ts7/ast-bytes.js +137 -0
- package/dist/frontend/ts7/ast-bytes.js.map +1 -0
- package/dist/frontend/ts7/ast-bytes.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-bytes.test.js +73 -0
- package/dist/frontend/ts7/ast-bytes.test.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.generated.d.ts +353 -0
- package/dist/frontend/ts7/ast-guards.generated.js +1951 -0
- package/dist/frontend/ts7/ast-guards.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-guards.test.js +43 -0
- package/dist/frontend/ts7/ast-guards.test.js.map +1 -0
- package/dist/frontend/ts7/ast-node.d.ts +194 -0
- package/dist/frontend/ts7/ast-node.js +448 -0
- package/dist/frontend/ts7/ast-node.js.map +1 -0
- package/dist/frontend/ts7/ast-node.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-node.test.js +266 -0
- package/dist/frontend/ts7/ast-node.test.js.map +1 -0
- package/dist/frontend/ts7/ast-schema.generated.d.ts +503 -0
- package/dist/frontend/ts7/ast-schema.generated.js +1446 -0
- package/dist/frontend/ts7/ast-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-text.d.ts +6 -0
- package/dist/frontend/ts7/ast-text.js +124 -0
- package/dist/frontend/ts7/ast-text.js.map +1 -0
- package/dist/frontend/ts7/ast-text.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-text.test.js +38 -0
- package/dist/frontend/ts7/ast-text.test.js.map +1 -0
- package/dist/frontend/ts7/ast-tokens.generated.d.ts +2 -0
- package/dist/frontend/ts7/ast-tokens.generated.js +155 -0
- package/dist/frontend/ts7/ast-tokens.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-types.d.ts +42 -0
- package/dist/frontend/ts7/ast-types.generated.d.ts +1615 -0
- package/dist/frontend/ts7/ast-types.generated.js +5 -0
- package/dist/frontend/ts7/ast-types.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-types.js +3 -0
- package/dist/frontend/ts7/ast-types.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.d.ts +58 -0
- package/dist/frontend/ts7/ast-wire.js +267 -0
- package/dist/frontend/ts7/ast-wire.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-wire.test.js +151 -0
- package/dist/frontend/ts7/ast-wire.test.js.map +1 -0
- package/dist/frontend/ts7/ast.d.ts +14 -14
- package/dist/frontend/ts7/ast.js +21 -15
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/census-check.js +1 -0
- package/dist/frontend/ts7/census-check.js.map +1 -1
- package/dist/frontend/ts7/checker-cache.d.ts +48 -0
- package/dist/frontend/ts7/checker-cache.js +92 -0
- package/dist/frontend/ts7/checker-cache.js.map +1 -0
- package/dist/frontend/ts7/checker.d.ts +19 -46
- package/dist/frontend/ts7/checker.js +231 -161
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.d.ts +1 -0
- package/dist/frontend/ts7/checker.test.js +335 -0
- package/dist/frontend/ts7/checker.test.js.map +1 -0
- package/dist/frontend/ts7/enums.d.ts +4 -27
- package/dist/frontend/ts7/enums.generated.d.ts +878 -0
- package/dist/frontend/ts7/enums.generated.js +1313 -0
- package/dist/frontend/ts7/enums.generated.js.map +1 -0
- package/dist/frontend/ts7/enums.js +4 -45
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/enums.test.d.ts +1 -0
- package/dist/frontend/ts7/enums.test.js +48 -0
- package/dist/frontend/ts7/enums.test.js.map +1 -0
- package/dist/frontend/ts7/native-api.d.ts +10 -0
- package/dist/frontend/ts7/native-api.js +10 -0
- package/dist/frontend/ts7/native-api.js.map +1 -0
- package/dist/frontend/ts7/native-host.d.ts +2 -0
- package/dist/frontend/ts7/native-host.js +11 -0
- package/dist/frontend/ts7/native-host.js.map +1 -0
- package/dist/frontend/ts7/native-process.d.ts +14 -0
- package/dist/frontend/ts7/native-process.js +62 -0
- package/dist/frontend/ts7/native-process.js.map +1 -0
- package/dist/frontend/ts7/program-adapter.d.ts +10 -98
- package/dist/frontend/ts7/program-adapter.js +16 -310
- package/dist/frontend/ts7/program-adapter.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +115 -0
- package/dist/frontend/ts7/program-host.js +347 -0
- package/dist/frontend/ts7/program-host.js.map +1 -0
- package/dist/frontend/ts7/program-host.test.d.ts +1 -0
- package/dist/frontend/ts7/program-host.test.js +207 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-api.d.ts +12 -0
- package/dist/frontend/ts7/rpc-api.js +23 -0
- package/dist/frontend/ts7/rpc-api.js.map +1 -0
- package/dist/frontend/ts7/rpc-client.d.ts +27 -0
- package/dist/frontend/ts7/rpc-client.js +102 -0
- package/dist/frontend/ts7/rpc-client.js.map +1 -0
- package/dist/frontend/ts7/rpc-client.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-client.test.js +133 -0
- package/dist/frontend/ts7/rpc-client.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-filesystem.d.ts +16 -0
- package/dist/frontend/ts7/rpc-filesystem.js +42 -0
- package/dist/frontend/ts7/rpc-filesystem.js.map +1 -0
- package/dist/frontend/ts7/rpc-filesystem.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-filesystem.test.js +89 -0
- package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-process.d.ts +2 -0
- package/dist/frontend/ts7/rpc-process.js +148 -0
- package/dist/frontend/ts7/rpc-process.js.map +1 -0
- package/dist/frontend/ts7/rpc-process.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-process.test.js +29 -0
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-wire.d.ts +46 -0
- package/dist/frontend/ts7/rpc-wire.js +195 -0
- package/dist/frontend/ts7/rpc-wire.js.map +1 -0
- package/dist/frontend/ts7/rpc-wire.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-wire.test.js +168 -0
- package/dist/frontend/ts7/rpc-wire.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-checker.d.ts +137 -0
- package/dist/frontend/ts7/semantic-checker.js +221 -0
- package/dist/frontend/ts7/semantic-checker.js.map +1 -0
- package/dist/frontend/ts7/semantic-checker.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-checker.test.js +119 -0
- package/dist/frontend/ts7/semantic-checker.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-json.d.ts +5 -0
- package/dist/frontend/ts7/semantic-json.js +52 -0
- package/dist/frontend/ts7/semantic-json.js.map +1 -0
- package/dist/frontend/ts7/semantic-json.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-json.test.js +42 -0
- package/dist/frontend/ts7/semantic-json.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-model.d.ts +222 -0
- package/dist/frontend/ts7/semantic-model.js +423 -0
- package/dist/frontend/ts7/semantic-model.js.map +1 -0
- package/dist/frontend/ts7/semantic-model.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-model.test.js +322 -0
- package/dist/frontend/ts7/semantic-model.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-schema.generated.d.ts +283 -0
- package/dist/frontend/ts7/semantic-schema.generated.js +222 -0
- package/dist/frontend/ts7/semantic-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/semantic-types.d.ts +5 -0
- package/dist/frontend/ts7/semantic-types.js +2 -0
- package/dist/frontend/ts7/semantic-types.js.map +1 -0
- package/dist/frontend/ts7/session-cache.d.ts +17 -0
- package/dist/frontend/ts7/session-cache.js +97 -0
- package/dist/frontend/ts7/session-cache.js.map +1 -0
- package/dist/frontend/ts7/session-cache.test.d.ts +1 -0
- package/dist/frontend/ts7/session-cache.test.js +87 -0
- package/dist/frontend/ts7/session-cache.test.js.map +1 -0
- package/dist/frontend/ts7/session-path.d.ts +18 -0
- package/dist/frontend/ts7/session-path.js +203 -0
- package/dist/frontend/ts7/session-path.js.map +1 -0
- package/dist/frontend/ts7/session-path.test.d.ts +1 -0
- package/dist/frontend/ts7/session-path.test.js +34 -0
- package/dist/frontend/ts7/session-path.test.js.map +1 -0
- package/dist/frontend/ts7/session-schema.generated.d.ts +167 -0
- package/dist/frontend/ts7/session-schema.generated.js +5 -0
- package/dist/frontend/ts7/session-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/session-timing.d.ts +50 -0
- package/dist/frontend/ts7/session-timing.js +61 -0
- package/dist/frontend/ts7/session-timing.js.map +1 -0
- package/dist/frontend/ts7/session-timing.test.d.ts +1 -0
- package/dist/frontend/ts7/session-timing.test.js +52 -0
- package/dist/frontend/ts7/session-timing.test.js.map +1 -0
- package/dist/frontend/ts7/session.d.ts +105 -0
- package/dist/frontend/ts7/session.js +233 -0
- package/dist/frontend/ts7/session.js.map +1 -0
- package/dist/frontend/ts7/session.test.d.ts +1 -0
- package/dist/frontend/ts7/session.test.js +215 -0
- package/dist/frontend/ts7/session.test.js.map +1 -0
- package/dist/frontend/ts7/source-parser-node.d.ts +6 -0
- package/dist/frontend/ts7/source-parser-node.js +15 -0
- package/dist/frontend/ts7/source-parser-node.js.map +1 -0
- package/dist/frontend/ts7/source-parser.d.ts +25 -0
- package/dist/frontend/ts7/source-parser.js +96 -0
- package/dist/frontend/ts7/source-parser.js.map +1 -0
- package/dist/frontend/ts7/source-parser.test.d.ts +1 -0
- package/dist/frontend/ts7/source-parser.test.js +151 -0
- package/dist/frontend/ts7/source-parser.test.js.map +1 -0
- package/dist/frontend/ts7/syntax.d.ts +3 -0
- package/dist/frontend/ts7/syntax.js +4 -0
- package/dist/frontend/ts7/syntax.js.map +1 -0
- package/dist/frontend/tsc-codes.js +3 -0
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +29 -19
- package/dist/frontend/type-mapper.js +713 -306
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.d.ts +1 -0
- package/dist/frontend/type-mapper.test.js +207 -0
- package/dist/frontend/type-mapper.test.js.map +1 -0
- package/dist/frontend/union-discriminants.d.ts +16 -0
- package/dist/frontend/union-discriminants.js +98 -0
- package/dist/frontend/union-discriminants.js.map +1 -0
- package/dist/frontend/union-discriminants.test.d.ts +1 -0
- package/dist/frontend/union-discriminants.test.js +182 -0
- package/dist/frontend/union-discriminants.test.js.map +1 -0
- package/dist/index.d.ts +7 -197
- package/dist/index.js +369 -1567
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +16 -4
- package/dist/ir/analysis.js +25 -6
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +15 -2
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/constant-tables.js +67 -49
- package/dist/ir/constant-tables.js.map +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/control-flow.d.ts +6 -0
- package/dist/ir/control-flow.js +142 -0
- package/dist/ir/control-flow.js.map +1 -0
- package/dist/ir/control-flow.test.d.ts +1 -0
- package/dist/ir/control-flow.test.js +113 -0
- package/dist/ir/control-flow.test.js.map +1 -0
- package/dist/ir/integer-loops.js +7 -18
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-ranges.js +53 -27
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +309 -164
- package/dist/ir/ir.js +588 -879
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +127 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/scalar-records.js +165 -134
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +4 -2
- package/dist/ir/serialize.js +19 -12
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.d.ts +1 -0
- package/dist/ir/serialize.test.js +53 -0
- package/dist/ir/serialize.test.js.map +1 -0
- package/dist/ir/traverse.d.ts +41 -0
- package/dist/ir/traverse.js +660 -0
- package/dist/ir/traverse.js.map +1 -0
- package/dist/ir/traverse.test.d.ts +1 -0
- package/dist/ir/traverse.test.js +242 -0
- package/dist/ir/traverse.test.js.map +1 -0
- package/dist/ir/validate.js +1956 -1496
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +476 -2
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/cache-primitives.d.ts +2 -3
- package/dist/library/cache-primitives.js +4 -6
- package/dist/library/cache-primitives.js.map +1 -1
- package/dist/library/compiler-self-identity.d.ts +1 -1
- package/dist/library/compiler-self-identity.js +31 -15
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.d.ts +1 -0
- package/dist/library/compiler-self-identity.test.js +93 -0
- package/dist/library/compiler-self-identity.test.js.map +1 -0
- package/dist/library/fence-eval.js +2 -2
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.js +7 -6
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/library-cache.d.ts +3 -2
- package/dist/library/library-cache.js +5 -17
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +54 -41
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/library-profile.d.ts +3 -1
- package/dist/library/library-profile.js +15 -6
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/prepare.d.ts +15 -0
- package/dist/library/prepare.js +584 -0
- package/dist/library/prepare.js.map +1 -0
- package/dist/library/semantic-source.d.ts +1 -1
- package/dist/library/semantic-source.js +8 -6
- package/dist/library/semantic-source.js.map +1 -1
- package/dist/library/sidecar-validate.js +4 -4
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.d.ts +2 -0
- package/dist/library/sidecar.js +10 -3
- package/dist/library/sidecar.js.map +1 -1
- package/dist/native/cache.d.ts +11 -0
- package/dist/native/cache.js +113 -0
- package/dist/native/cache.js.map +1 -0
- package/dist/native/cache.test.d.ts +1 -0
- package/dist/native/cache.test.js +66 -0
- package/dist/native/cache.test.js.map +1 -0
- package/dist/native/cli.d.ts +1 -0
- package/dist/native/cli.js +112 -0
- package/dist/native/cli.js.map +1 -0
- package/dist/native/compiler.d.ts +15 -0
- package/dist/native/compiler.js +336 -0
- package/dist/native/compiler.js.map +1 -0
- package/dist/native/compiler.test.d.ts +1 -0
- package/dist/native/compiler.test.js +174 -0
- package/dist/native/compiler.test.js.map +1 -0
- package/dist/native/comptime.d.ts +5 -0
- package/dist/native/comptime.js +73 -0
- package/dist/native/comptime.js.map +1 -0
- package/dist/native/comptime.test.d.ts +1 -0
- package/dist/native/comptime.test.js +65 -0
- package/dist/native/comptime.test.js.map +1 -0
- package/dist/native/executable-cache.d.ts +26 -0
- package/dist/native/executable-cache.js +228 -0
- package/dist/native/executable-cache.js.map +1 -0
- package/dist/native/executable-cache.test.d.ts +1 -0
- package/dist/native/executable-cache.test.js +151 -0
- package/dist/native/executable-cache.test.js.map +1 -0
- package/dist/native/file-identity.d.ts +4 -0
- package/dist/native/file-identity.js +14 -0
- package/dist/native/file-identity.js.map +1 -0
- package/dist/native/file-identity.test.d.ts +1 -0
- package/dist/native/file-identity.test.js +43 -0
- package/dist/native/file-identity.test.js.map +1 -0
- package/dist/native/library.d.ts +22 -0
- package/dist/native/library.js +83 -0
- package/dist/native/library.js.map +1 -0
- package/dist/native/prepare.d.ts +21 -0
- package/dist/native/prepare.js +174 -0
- package/dist/native/prepare.js.map +1 -0
- package/dist/native/prepare.test.d.ts +1 -0
- package/dist/native/prepare.test.js +70 -0
- package/dist/native/prepare.test.js.map +1 -0
- package/dist/native/sanitizer.d.ts +11 -0
- package/dist/native/sanitizer.js +135 -0
- package/dist/native/sanitizer.js.map +1 -0
- package/dist/native/sanitizer.test.d.ts +1 -0
- package/dist/native/sanitizer.test.js +58 -0
- package/dist/native/sanitizer.test.js.map +1 -0
- package/dist/native/task.d.ts +4 -0
- package/dist/native/task.js +16 -0
- package/dist/native/task.js.map +1 -0
- package/dist/native/task.test.d.ts +1 -0
- package/dist/native/task.test.js +17 -0
- package/dist/native/task.test.js.map +1 -0
- package/dist/native/toolchain.d.ts +45 -0
- package/dist/native/toolchain.js +74 -0
- package/dist/native/toolchain.js.map +1 -0
- package/dist/native/toolchain.test.d.ts +1 -0
- package/dist/native/toolchain.test.js +33 -0
- package/dist/native/toolchain.test.js.map +1 -0
- package/dist/startup-cache.d.ts +1 -1
- package/dist/startup-cache.js +2 -5
- package/dist/startup-cache.js.map +1 -1
- package/dist/timing.d.ts +4 -0
- package/dist/timing.js +19 -0
- package/dist/timing.js.map +1 -0
- package/dist/wasi-paths.js +10 -7
- package/dist/wasi-paths.js.map +1 -1
- package/package.json +28 -19
- package/surface-manifest.json +171 -18
- package/dist/backend/c/async.d.ts +0 -171
- package/dist/backend/c/async.js +0 -1317
- package/dist/backend/c/async.js.map +0 -1
- package/dist/backend/c/c-emitter.d.ts +0 -531
- package/dist/backend/c/c-emitter.js +0 -1917
- package/dist/backend/c/c-emitter.js.map +0 -1
- package/dist/backend/c/exprs.d.ts +0 -15
- package/dist/backend/c/exprs.js +0 -8803
- package/dist/backend/c/exprs.js.map +0 -1
- package/dist/backend/c/island.d.ts +0 -45
- package/dist/backend/c/island.js +0 -281
- package/dist/backend/c/island.js.map +0 -1
- package/dist/backend/c/may-throw.js.map +0 -1
- package/dist/backend/c/shapes.d.ts +0 -142
- package/dist/backend/c/shapes.js +0 -603
- package/dist/backend/c/shapes.js.map +0 -1
- package/dist/backend/c/stmts.d.ts +0 -76
- package/dist/backend/c/stmts.js +0 -1084
- package/dist/backend/c/stmts.js.map +0 -1
- package/dist/backend/c/types.d.ts +0 -71
- package/dist/backend/c/types.js +0 -459
- package/dist/backend/c/types.js.map +0 -1
- package/dist/backend/c/types.test.js +0 -32
- package/dist/backend/c/types.test.js.map +0 -1
- package/dist/backend/c/walkers.d.ts +0 -134
- package/dist/backend/c/walkers.js +0 -1773
- package/dist/backend/c/walkers.js.map +0 -1
- /package/dist/backend/{c/types.test.d.ts → cycle-analysis.test.d.ts} +0 -0
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { InternalCompilerError } from "../errors.js";
|
|
2
2
|
import * as ts from "./ts7/adapter.js";
|
|
3
|
-
import {
|
|
3
|
+
import { bodyReadsArguments } from "./arguments-usage.js";
|
|
4
|
+
import { BYTES_ELEMENT_NAME, 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, unionContainerArmsOk, UNDEFINED_T, VOID } from "../ir/ir.js";
|
|
4
5
|
import { BIGINT_T } from "../ir/ir.js";
|
|
6
|
+
import { literalValues } from "./literal-values.js";
|
|
7
|
+
import { remapUnionDiscriminant } from "./union-discriminants.js";
|
|
5
8
|
import { isJsSourceFile, isNodeTypesPath } from "./program.js";
|
|
6
|
-
import { accessorSlotProp } from "../ir/ir.js";
|
|
9
|
+
import { accessorSlotProp, recordTextCodecClass } from "../ir/ir.js";
|
|
7
10
|
// typeKey moved to ir/ir.ts (the backend needs it too, for per-type
|
|
8
11
|
// helper interning); re-exported here so frontend call sites keep their
|
|
9
12
|
// import path.
|
|
10
13
|
export { typeKey };
|
|
14
|
+
/** Empty JS object inference describes no fixed layout. Keep these values
|
|
15
|
+
* in checked storage across fields, parameters and function signatures. */
|
|
16
|
+
export function jsOpenObjectType(decl, type, shapes, unions) {
|
|
17
|
+
if (!decl || !isJsSourceFile(decl.getSourceFile()))
|
|
18
|
+
return type;
|
|
19
|
+
const arms = type.kind === "union" ? unions.get(type.unionId)?.arms : [type];
|
|
20
|
+
const present = arms?.filter((arm) => arm.kind !== "undefinedT");
|
|
21
|
+
if (present?.length !== 1 || present[0].kind !== "record")
|
|
22
|
+
return type;
|
|
23
|
+
const shape = shapes.get(present[0].shapeId);
|
|
24
|
+
return shape && shape.fields.length === 0 && !shape.indexValue && !shape.tuple ? DYN : type;
|
|
25
|
+
}
|
|
11
26
|
/** The ambient TYPE names of the fetch slice. Under --dynamic their
|
|
12
27
|
* values live in the embedded engine and map to island handles (jsval).
|
|
13
28
|
* Static fetch gives Response, RequestInit, AbortController/AbortSignal, response
|
|
@@ -32,6 +47,14 @@ export const ISLAND_AMBIENT_TYPES = [
|
|
|
32
47
|
"ReadableStreamReadValueResult",
|
|
33
48
|
"ReadableStreamReadDoneResult",
|
|
34
49
|
];
|
|
50
|
+
function isAmbientAbortHandleType(type, ctx) {
|
|
51
|
+
if (type.isUnionType())
|
|
52
|
+
return ts.constituentTypes(type).some((part) => isAmbientAbortHandleType(part, ctx));
|
|
53
|
+
const symbol = type.getSymbol();
|
|
54
|
+
return !!symbol &&
|
|
55
|
+
(symbol.name === "AbortSignal" || symbol.name === "AbortController") &&
|
|
56
|
+
ctx.checker.declarationsOf(symbol).some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) && ctx.isStdlibFile(d.getSourceFile()));
|
|
57
|
+
}
|
|
35
58
|
/** node:util.parseArgs's public and @types/node helper type names. Values
|
|
36
59
|
* behind this surface use the checked-dynamic tree; see mapTypeInner. */
|
|
37
60
|
const PARSE_ARGS_DYN_TYPES = new Set([
|
|
@@ -58,7 +81,7 @@ export function isParseArgsDynTypeName(name) {
|
|
|
58
81
|
return PARSE_ARGS_DYN_TYPES.has(name);
|
|
59
82
|
}
|
|
60
83
|
function priorityRank(priority) {
|
|
61
|
-
return
|
|
84
|
+
return Array.isArray(priority) ? priority : priority.rank;
|
|
62
85
|
}
|
|
63
86
|
function comparePriority(left, right) {
|
|
64
87
|
const a = priorityRank(left);
|
|
@@ -285,10 +308,9 @@ export class ShapeRegistry {
|
|
|
285
308
|
}
|
|
286
309
|
}
|
|
287
310
|
/** The frontend's union interner — mirrors ShapeRegistry. A union's
|
|
288
|
-
* canonical identity
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
* the Lowerer; threaded through mapType exactly like ShapeRegistry. */
|
|
311
|
+
* canonical identity includes its typeKey-sorted arms and literal
|
|
312
|
+
* discriminator contract. An arm's index in that list IS its runtime tag.
|
|
313
|
+
* Owned by the Lowerer; threaded through mapType like ShapeRegistry. */
|
|
292
314
|
export class UnionRegistry {
|
|
293
315
|
byKey = new Map();
|
|
294
316
|
byId = new Map();
|
|
@@ -334,199 +356,286 @@ export class UnionRegistry {
|
|
|
334
356
|
}
|
|
335
357
|
/** Completes a recursive placeholder with its canonical arm list and
|
|
336
358
|
* registers the structural key (first writer wins, like shapes). */
|
|
337
|
-
finalizeRecursive(t, arms) {
|
|
359
|
+
finalizeRecursive(t, arms, discriminant) {
|
|
338
360
|
const id = this.recIds.get(t);
|
|
339
361
|
if (id === undefined)
|
|
340
362
|
throw new InternalCompilerError("union registry bug: finalizeRecursive without a placeholder");
|
|
341
363
|
if (this.pendingRec.has(id)) {
|
|
342
364
|
const def = this.byId.get(id);
|
|
343
365
|
def.arms.push(...arms);
|
|
366
|
+
if (discriminant)
|
|
367
|
+
def.discriminant = discriminant;
|
|
344
368
|
this.pendingRec.delete(id);
|
|
345
|
-
const key = JSON.stringify(arms.map(typeKey));
|
|
369
|
+
const key = JSON.stringify([arms.map(typeKey), discriminant]);
|
|
346
370
|
if (!this.byKey.has(key))
|
|
347
371
|
this.byKey.set(key, id);
|
|
348
372
|
}
|
|
349
373
|
return id;
|
|
350
374
|
}
|
|
351
|
-
/** Interns
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const key = JSON.stringify(arms.map(typeKey));
|
|
375
|
+
/** Interns canonical arms and discriminator cases, returning their unionId. */
|
|
376
|
+
intern(arms, discriminant) {
|
|
377
|
+
const key = JSON.stringify([arms.map(typeKey), discriminant]);
|
|
355
378
|
let id = this.byKey.get(key);
|
|
356
379
|
if (id === undefined) {
|
|
357
380
|
id = `u${this.unions.length}`;
|
|
358
|
-
const def = { id, arms };
|
|
381
|
+
const def = { id, arms, ...(discriminant ? { discriminant } : {}) };
|
|
359
382
|
this.byKey.set(key, id);
|
|
360
383
|
this.byId.set(id, def);
|
|
361
384
|
this.unions.push(def);
|
|
362
385
|
}
|
|
363
386
|
return id;
|
|
364
387
|
}
|
|
388
|
+
/** An exact arm transformation keeps the source's semantic variants. */
|
|
389
|
+
transform(source, arms) {
|
|
390
|
+
return this.intern(arms, remapUnionDiscriminant(source, arms));
|
|
391
|
+
}
|
|
365
392
|
get(unionId) {
|
|
366
393
|
return this.byId.get(unionId);
|
|
367
394
|
}
|
|
368
395
|
}
|
|
369
396
|
/** Human-readable rendering of an IrType for diagnostics (records expand to
|
|
370
397
|
* their canonical field list, unions to their arms; `checker.typeToString`
|
|
371
|
-
* can't — it never sees IR types).
|
|
372
|
-
*
|
|
398
|
+
* can't — it never sees IR types). Bound the traversal as well as its output:
|
|
399
|
+
* cycle detection alone still expands a shared acyclic graph exponentially.
|
|
400
|
+
* The same budget covers every sibling, and deep wrapper chains truncate
|
|
401
|
+
* before exhausting the JS stack. Small types retain their full spelling. */
|
|
373
402
|
export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
return
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
return
|
|
420
|
-
|
|
421
|
-
return "
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
403
|
+
const maxLength = 4096;
|
|
404
|
+
const maxDepth = 32;
|
|
405
|
+
let output = "";
|
|
406
|
+
let truncated = false;
|
|
407
|
+
const append = (text) => {
|
|
408
|
+
if (truncated)
|
|
409
|
+
return;
|
|
410
|
+
// Reserve the marker so a full buffer can always report truncation.
|
|
411
|
+
const remaining = maxLength - 3 - output.length;
|
|
412
|
+
if (text.length > remaining) {
|
|
413
|
+
output += text.slice(0, remaining) + "...";
|
|
414
|
+
truncated = true;
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
output += text;
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
const list = (types, separator, depth) => {
|
|
421
|
+
for (let i = 0; i < types.length && !truncated; i++) {
|
|
422
|
+
if (i > 0)
|
|
423
|
+
append(separator);
|
|
424
|
+
visit(types[i], depth);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
const visit = (t, depth) => {
|
|
428
|
+
if (truncated)
|
|
429
|
+
return;
|
|
430
|
+
if (depth >= maxDepth)
|
|
431
|
+
return append("...");
|
|
432
|
+
const child = (type) => visit(type, depth + 1);
|
|
433
|
+
switch (t.kind) {
|
|
434
|
+
case "f64":
|
|
435
|
+
return append("number");
|
|
436
|
+
case "string":
|
|
437
|
+
return append("string");
|
|
438
|
+
case "bool":
|
|
439
|
+
return append("boolean");
|
|
440
|
+
case "dyn":
|
|
441
|
+
return append("unknown");
|
|
442
|
+
case "caught":
|
|
443
|
+
// What tsc calls the binding; the fence messages carry the real story.
|
|
444
|
+
return append("unknown");
|
|
445
|
+
case "void":
|
|
446
|
+
return append("void");
|
|
447
|
+
case "undefinedT":
|
|
448
|
+
return append("undefined");
|
|
449
|
+
case "nullT":
|
|
450
|
+
return append("null");
|
|
451
|
+
case "array": {
|
|
452
|
+
// Union/func elements need the parens TS syntax would ("(number |
|
|
453
|
+
// string)[]" — without them the [] reads as binding to the last arm).
|
|
454
|
+
const parens = t.elem.kind === "union" || t.elem.kind === "func";
|
|
455
|
+
if (parens)
|
|
456
|
+
append("(");
|
|
457
|
+
child(t.elem);
|
|
458
|
+
return append(parens ? ")[]" : "[]");
|
|
459
|
+
}
|
|
460
|
+
case "bytes":
|
|
461
|
+
// The u8 kind reads as Uint8Array (Buffer maps here too — one
|
|
462
|
+
// runtime representation; the message stays honest either way).
|
|
463
|
+
return append(BYTES_ELEMENT_NAME[t.elem]);
|
|
464
|
+
case "map":
|
|
465
|
+
append("Map<");
|
|
466
|
+
child(t.key);
|
|
467
|
+
append(", ");
|
|
468
|
+
child(t.value);
|
|
469
|
+
return append(">");
|
|
470
|
+
case "set":
|
|
471
|
+
append("Set<");
|
|
472
|
+
child(t.elem);
|
|
473
|
+
return append(">");
|
|
474
|
+
case "func":
|
|
475
|
+
append("(");
|
|
476
|
+
list(t.params, ", ", depth + 1);
|
|
477
|
+
append(") => ");
|
|
478
|
+
return child(t.ret);
|
|
479
|
+
case "object":
|
|
480
|
+
// Runtime-provided error classes carry '%'-prefixed IR names
|
|
481
|
+
// ("%Error") so user classes can never collide; diagnostics show the
|
|
482
|
+
// source-level name.
|
|
483
|
+
return append(t.className.startsWith("%") ? t.className.slice(1) : t.className);
|
|
484
|
+
case "classval":
|
|
485
|
+
// The static side, in TS's own spelling.
|
|
486
|
+
append("typeof ");
|
|
487
|
+
return append(t.className.startsWith("%") ? t.className.slice(1) : t.className);
|
|
488
|
+
case "record": {
|
|
489
|
+
const shape = shapes.get(t.shapeId);
|
|
490
|
+
if (!shape)
|
|
491
|
+
return append(`{ /* unknown shape ${t.shapeId} */ }`);
|
|
492
|
+
const codec = recordTextCodecClass(shape);
|
|
493
|
+
if (codec !== null)
|
|
494
|
+
return append(codec);
|
|
495
|
+
if (seen.has(t.shapeId))
|
|
496
|
+
return append("..."); // the recursive knot
|
|
497
|
+
seen.add(t.shapeId);
|
|
498
|
+
try {
|
|
499
|
+
if (shape.tuple) {
|
|
500
|
+
const byIndex = [...shape.fields].sort((a, b) => Number(a.name) - Number(b.name));
|
|
501
|
+
append("[");
|
|
502
|
+
for (let i = 0; i < byIndex.length && !truncated; i++) {
|
|
503
|
+
if (i > 0)
|
|
504
|
+
append(", ");
|
|
505
|
+
child(byIndex[i].type);
|
|
506
|
+
}
|
|
507
|
+
return append("]");
|
|
508
|
+
}
|
|
509
|
+
if (shape.fields.length === 0 && !shape.indexValue)
|
|
510
|
+
return append("{}");
|
|
511
|
+
append("{ ");
|
|
512
|
+
for (let i = 0; i < shape.fields.length && !truncated; i++) {
|
|
513
|
+
if (i > 0)
|
|
514
|
+
append("; ");
|
|
515
|
+
const f = shape.fields[i];
|
|
516
|
+
// Accessor slots print in TS's accessor spelling, not the
|
|
517
|
+
// reserved '%'-field encoding.
|
|
518
|
+
const slot = accessorSlotProp(f.name);
|
|
519
|
+
if (slot && f.type.kind === "func") {
|
|
520
|
+
append(slot.kind === "get" ? "get " : "set ");
|
|
521
|
+
append(slot.prop);
|
|
522
|
+
if (slot.kind === "get") {
|
|
523
|
+
append("(): ");
|
|
524
|
+
child(f.type.ret);
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
append("(");
|
|
528
|
+
child(f.type.params[0] ?? VOID);
|
|
529
|
+
append(")");
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
append(f.name);
|
|
534
|
+
append(": ");
|
|
535
|
+
child(f.type);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
if (shape.indexValue) {
|
|
539
|
+
if (shape.fields.length > 0)
|
|
540
|
+
append("; ");
|
|
541
|
+
append("[key: string]: ");
|
|
542
|
+
child(shape.indexValue);
|
|
436
543
|
}
|
|
437
|
-
return
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
544
|
+
return append(" }");
|
|
545
|
+
}
|
|
546
|
+
finally {
|
|
547
|
+
seen.delete(t.shapeId); // sibling occurrences still expand
|
|
441
548
|
}
|
|
442
|
-
if (members.length === 0)
|
|
443
|
-
return "{}";
|
|
444
|
-
return `{ ${members.join("; ")} }`;
|
|
445
|
-
}
|
|
446
|
-
finally {
|
|
447
|
-
seen.delete(t.shapeId); // sibling occurrences still expand
|
|
448
549
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
550
|
+
case "union": {
|
|
551
|
+
const def = unions.get(t.unionId);
|
|
552
|
+
if (!def)
|
|
553
|
+
return append(`/* union ${t.unionId} */`);
|
|
554
|
+
if (seen.has(t.unionId))
|
|
555
|
+
return append("..."); // the recursive knot
|
|
556
|
+
seen.add(t.unionId);
|
|
557
|
+
try {
|
|
558
|
+
return list(def.arms, " | ", depth + 1);
|
|
559
|
+
}
|
|
560
|
+
finally {
|
|
561
|
+
seen.delete(t.unionId);
|
|
562
|
+
}
|
|
459
563
|
}
|
|
460
|
-
|
|
461
|
-
|
|
564
|
+
case "jsval":
|
|
565
|
+
return append("any");
|
|
566
|
+
case "regex":
|
|
567
|
+
return append("RegExp");
|
|
568
|
+
case "date":
|
|
569
|
+
return append("Date");
|
|
570
|
+
case "url":
|
|
571
|
+
return append("URL");
|
|
572
|
+
case "searchParams":
|
|
573
|
+
return append("URLSearchParams");
|
|
574
|
+
case "symbol":
|
|
575
|
+
return append("symbol");
|
|
576
|
+
case "bigint":
|
|
577
|
+
return append("bigint");
|
|
578
|
+
case "stats":
|
|
579
|
+
return append("Stats");
|
|
580
|
+
case "fileHandle":
|
|
581
|
+
return append("FileHandle");
|
|
582
|
+
case "spawnRes":
|
|
583
|
+
return append("SpawnSyncReturns");
|
|
584
|
+
case "child":
|
|
585
|
+
return append("ChildProcess");
|
|
586
|
+
case "netServer":
|
|
587
|
+
return append("Server");
|
|
588
|
+
case "netSocket":
|
|
589
|
+
return append("Socket");
|
|
590
|
+
case "http2Session":
|
|
591
|
+
return append("Http2Session");
|
|
592
|
+
case "http2Stream":
|
|
593
|
+
return append("Http2Stream");
|
|
594
|
+
case "dgramSocket":
|
|
595
|
+
return append("dgram.Socket");
|
|
596
|
+
case "testCtx":
|
|
597
|
+
return append("TestContext");
|
|
598
|
+
case "httpReq":
|
|
599
|
+
return append("IncomingMessage");
|
|
600
|
+
case "httpRes":
|
|
601
|
+
return append("ServerResponse");
|
|
602
|
+
case "httpClientReq":
|
|
603
|
+
return append("ClientRequest");
|
|
604
|
+
case "secureCtx":
|
|
605
|
+
return append("SecureContext");
|
|
606
|
+
case "cryptoHash":
|
|
607
|
+
return append("Hash");
|
|
608
|
+
case "cryptoHmac":
|
|
609
|
+
return append("Hmac");
|
|
610
|
+
case "fsWatcher":
|
|
611
|
+
return append("FSWatcher");
|
|
612
|
+
case "childStream":
|
|
613
|
+
return append("Readable");
|
|
614
|
+
case "childWriter":
|
|
615
|
+
return append("Writable");
|
|
616
|
+
case "procStream":
|
|
617
|
+
return append("WriteStream");
|
|
618
|
+
case "moduleNs":
|
|
619
|
+
append("module namespace '");
|
|
620
|
+
append(t.moduleId);
|
|
621
|
+
return append("'");
|
|
622
|
+
case "promise":
|
|
623
|
+
append("Promise<");
|
|
624
|
+
child(t.inner);
|
|
625
|
+
return append(">");
|
|
626
|
+
case "generator":
|
|
627
|
+
append(t.async ? "AsyncGenerator<" : "Generator<");
|
|
628
|
+
list([t.yieldT, t.retT, t.nextT], ", ", depth + 1);
|
|
629
|
+
return append(">");
|
|
630
|
+
default: {
|
|
631
|
+
const _exhaustive = t;
|
|
632
|
+
void _exhaustive;
|
|
633
|
+
throw new InternalCompilerError("unreachable");
|
|
462
634
|
}
|
|
463
635
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
return "RegExp";
|
|
468
|
-
case "date":
|
|
469
|
-
return "Date";
|
|
470
|
-
case "url":
|
|
471
|
-
return "URL";
|
|
472
|
-
case "searchParams":
|
|
473
|
-
return "URLSearchParams";
|
|
474
|
-
case "symbol":
|
|
475
|
-
return "symbol";
|
|
476
|
-
case "bigint":
|
|
477
|
-
return "bigint";
|
|
478
|
-
case "stats":
|
|
479
|
-
return "Stats";
|
|
480
|
-
case "fileHandle":
|
|
481
|
-
return "FileHandle";
|
|
482
|
-
case "spawnRes":
|
|
483
|
-
return "SpawnSyncReturns";
|
|
484
|
-
case "child":
|
|
485
|
-
return "ChildProcess";
|
|
486
|
-
case "netServer":
|
|
487
|
-
return "Server";
|
|
488
|
-
case "netSocket":
|
|
489
|
-
return "Socket";
|
|
490
|
-
case "http2Session":
|
|
491
|
-
return "Http2Session";
|
|
492
|
-
case "http2Stream":
|
|
493
|
-
return "Http2Stream";
|
|
494
|
-
case "dgramSocket":
|
|
495
|
-
return "dgram.Socket";
|
|
496
|
-
case "testCtx":
|
|
497
|
-
return "TestContext";
|
|
498
|
-
case "httpReq":
|
|
499
|
-
return "IncomingMessage";
|
|
500
|
-
case "httpRes":
|
|
501
|
-
return "ServerResponse";
|
|
502
|
-
case "httpClientReq":
|
|
503
|
-
return "ClientRequest";
|
|
504
|
-
case "secureCtx":
|
|
505
|
-
return "SecureContext";
|
|
506
|
-
case "cryptoHash":
|
|
507
|
-
return "Hash";
|
|
508
|
-
case "cryptoHmac":
|
|
509
|
-
return "Hmac";
|
|
510
|
-
case "fsWatcher":
|
|
511
|
-
return "FSWatcher";
|
|
512
|
-
case "childStream":
|
|
513
|
-
return "Readable";
|
|
514
|
-
case "childWriter":
|
|
515
|
-
return "Writable";
|
|
516
|
-
case "procStream":
|
|
517
|
-
return "WriteStream";
|
|
518
|
-
case "moduleNs":
|
|
519
|
-
return `module namespace '${t.moduleId}'`;
|
|
520
|
-
case "promise":
|
|
521
|
-
return `Promise<${formatIrType(t.inner, shapes, unions, seen)}>`;
|
|
522
|
-
case "generator":
|
|
523
|
-
return `${t.async ? "AsyncGenerator" : "Generator"}<${formatIrType(t.yieldT, shapes, unions, seen)}, ${formatIrType(t.retT, shapes, unions, seen)}, ${formatIrType(t.nextT, shapes, unions, seen)}>`;
|
|
524
|
-
default: {
|
|
525
|
-
const _exhaustive = t;
|
|
526
|
-
void _exhaustive;
|
|
527
|
-
throw new InternalCompilerError("unreachable");
|
|
528
|
-
}
|
|
529
|
-
}
|
|
636
|
+
};
|
|
637
|
+
visit(t, 0);
|
|
638
|
+
return output;
|
|
530
639
|
}
|
|
531
640
|
/** True when the declaration sits inside `declare module "<name>"` (or
|
|
532
641
|
* its node:-prefixed twin) — the disambiguator for builtin-module type
|
|
@@ -602,28 +711,6 @@ export function containsUnion(t) {
|
|
|
602
711
|
return false;
|
|
603
712
|
}
|
|
604
713
|
}
|
|
605
|
-
/** lower-calls.ts's bodyReadsArguments, duplicated here (type-mapper.ts must not
|
|
606
|
-
* import from lowering/ — that edge is a module cycle): does the function's
|
|
607
|
-
* OWN body read `arguments`? Nested plain functions/methods own theirs
|
|
608
|
-
* (skipped); arrows see the enclosing one (descended). */
|
|
609
|
-
function bodyReadsArgumentsLocal(fn) {
|
|
610
|
-
let found = false;
|
|
611
|
-
if (fn.body === undefined)
|
|
612
|
-
return false;
|
|
613
|
-
// Iterative walk (walkPreorder): function bodies can hold pathologically
|
|
614
|
-
// deep expression chains that a recursive visit would die on.
|
|
615
|
-
ts.walkPreorder(fn.body, (n) => {
|
|
616
|
-
if (ts.isIdentifier(n) && n.text === "arguments" && !(ts.isPropertyAccessExpression(n.parent) && n.parent.name === n)) {
|
|
617
|
-
found = true;
|
|
618
|
-
return "stop";
|
|
619
|
-
}
|
|
620
|
-
if ((ts.isFunctionExpression(n) || ts.isFunctionDeclaration(n) || ts.isMethodDeclaration(n)) && n !== fn) {
|
|
621
|
-
return "skip"; // own `arguments` scope
|
|
622
|
-
}
|
|
623
|
-
return undefined;
|
|
624
|
-
});
|
|
625
|
-
return found;
|
|
626
|
-
}
|
|
627
714
|
/** A generator type's normalized value channels (Generator<T, TReturn,
|
|
628
715
|
* TNext> and the IteratorResult alias share this):
|
|
629
716
|
* - yield: `never` (a generator that never yields) rides the VOID
|
|
@@ -638,8 +725,8 @@ function bodyReadsArgumentsLocal(fn) {
|
|
|
638
725
|
* - next: void/undefined/never mean valueless resumes (the undefined
|
|
639
726
|
* unit); any/unknown ride dyn; else the mapped type (`.next(v)` then
|
|
640
727
|
* requires its argument — fenced at the call site).
|
|
641
|
-
* Mixed dyn/concrete value channels
|
|
642
|
-
* record's value slot
|
|
728
|
+
* Mixed dyn/concrete value channels both use checked values because the
|
|
729
|
+
* shared result record's value slot has one representation. */
|
|
643
730
|
function genChannels(yieldTs, retTs, nextTs, ctx) {
|
|
644
731
|
if (!yieldTs)
|
|
645
732
|
return null;
|
|
@@ -670,7 +757,7 @@ function genChannels(yieldTs, retTs, nextTs, ctx) {
|
|
|
670
757
|
const dynMix = (yieldT.kind === "dyn" && retT.kind !== "dyn" && retT.kind !== "void") ||
|
|
671
758
|
(retT.kind === "dyn" && yieldT.kind !== "dyn" && yieldT.kind !== "void");
|
|
672
759
|
if (dynMix)
|
|
673
|
-
return
|
|
760
|
+
return { yieldT: DYN, retT: DYN, nextT };
|
|
674
761
|
return { yieldT, retT, nextT };
|
|
675
762
|
}
|
|
676
763
|
/** SELF-REFERENTIAL types recurse through mapType with no structural floor:
|
|
@@ -722,16 +809,10 @@ export function mapType(type, ctx) {
|
|
|
722
809
|
mapTypeDepth--;
|
|
723
810
|
}
|
|
724
811
|
}
|
|
725
|
-
/**
|
|
726
|
-
*
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
* naming a struct that will never be emitted is the invalid-C escape
|
|
730
|
-
* family (every SITE using the value already carries its own fence). */
|
|
731
|
-
function classExprNeverRegisters(decl) {
|
|
732
|
-
if (!ts.isClassExpression(decl))
|
|
733
|
-
return false;
|
|
734
|
-
for (let p = decl.parent; !ts.isSourceFile(p); p = p.parent) {
|
|
812
|
+
/** Local class types need the enclosing specialization's registered layout.
|
|
813
|
+
* Static-block classes are sent through the same hook for an explicit fence. */
|
|
814
|
+
function classExprNeedsContext(decl) {
|
|
815
|
+
for (let p = decl.parent; p !== undefined && !ts.isSourceFile(p); p = p.parent) {
|
|
735
816
|
if (ts.isFunctionLike(p) || ts.isClassStaticBlockDeclaration(p))
|
|
736
817
|
return true;
|
|
737
818
|
}
|
|
@@ -739,6 +820,11 @@ function classExprNeverRegisters(decl) {
|
|
|
739
820
|
}
|
|
740
821
|
function mapTypeInner(type, ctx) {
|
|
741
822
|
const { checker, unions, classNamer, resolveTypeParam } = ctx;
|
|
823
|
+
// TypeScript's intrinsic globalThis symbol has no declaration. A stored
|
|
824
|
+
// reference needs native object identity, including var's undefined state.
|
|
825
|
+
const intrinsic = type.getSymbol();
|
|
826
|
+
if (!ctx.dynamic && intrinsic?.name === "globalThis" && checker.declarationsOf(intrinsic).length === 0)
|
|
827
|
+
return DYN;
|
|
742
828
|
if (!ctx.dynamic) {
|
|
743
829
|
const moduleId = ctx.moduleNamespaceId?.(type) ?? null;
|
|
744
830
|
if (moduleId !== null)
|
|
@@ -800,6 +886,15 @@ function mapTypeInner(type, ctx) {
|
|
|
800
886
|
return STRING;
|
|
801
887
|
if (flags & ts.TypeFlags.Boolean || flags & ts.TypeFlags.BooleanLiteral)
|
|
802
888
|
return BOOL;
|
|
889
|
+
// ErrorOptions carries a presence-sensitive unknown value. A fixed
|
|
890
|
+
// optional field cannot distinguish {} from { cause: undefined }; the
|
|
891
|
+
// checked-dynamic object retains that distinction through forwarding
|
|
892
|
+
// constructors. Only the standard library's interface gets this ABI.
|
|
893
|
+
const errorOptionsSymbol = widened.getSymbol();
|
|
894
|
+
if (errorOptionsSymbol?.name === "ErrorOptions" &&
|
|
895
|
+
checker.declarationsOf(errorOptionsSymbol).some((d) => ctx.isStdlibFile(d.getSourceFile()))) {
|
|
896
|
+
return DYN;
|
|
897
|
+
}
|
|
803
898
|
// node:util.parseArgs config/results are declaration-heavy conditional
|
|
804
899
|
// and discriminated-union types over a value that is naturally a checked-
|
|
805
900
|
// dynamic tree. Keep the named public surface (plus @types/node's private
|
|
@@ -810,12 +905,29 @@ function mapTypeInner(type, ctx) {
|
|
|
810
905
|
// user aliases with the same names on the normal structural path.
|
|
811
906
|
{
|
|
812
907
|
const parseArgsSym = widened.getAliasSymbol() ?? widened.getSymbol();
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
908
|
+
const belongs = (declaration) => {
|
|
909
|
+
if (!ctx.isStdlibFile(declaration.getSourceFile()))
|
|
910
|
+
return false;
|
|
911
|
+
let family = false;
|
|
912
|
+
for (let node = declaration; node; node = node.parent) {
|
|
913
|
+
if ((ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node)) &&
|
|
914
|
+
PARSE_ARGS_DYN_TYPES.has(node.name.text))
|
|
915
|
+
family = true;
|
|
916
|
+
if (ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name)) {
|
|
917
|
+
return family && (node.name.text === "util" || node.name.text === "node:util");
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return false;
|
|
921
|
+
};
|
|
922
|
+
if (parseArgsSym && PARSE_ARGS_DYN_TYPES.has(parseArgsSym.name) &&
|
|
923
|
+
checker.declarationsOf(parseArgsSym).some(belongs))
|
|
924
|
+
return DYN;
|
|
925
|
+
// ReturnType and instantiated conditional types can erase the alias.
|
|
926
|
+
// Require every member to retain the util declaration provenance so
|
|
927
|
+
// unrelated records with similar property names keep their own layout.
|
|
928
|
+
const members = checker.getPropertiesOfType(widened);
|
|
929
|
+
if (members.length > 0 && members.every((member) => checker.declarationsOf(member).some(belongs)))
|
|
817
930
|
return DYN;
|
|
818
|
-
}
|
|
819
931
|
}
|
|
820
932
|
// The lib's BOXED wrapper interfaces used as TYPES (`const n: Number =
|
|
821
933
|
// 5`): every value such a slot can hold IS the primitive — `new
|
|
@@ -867,6 +979,21 @@ function mapTypeInner(type, ctx) {
|
|
|
867
979
|
// position knows it wants a value; this mapping cannot.
|
|
868
980
|
if (flags & (ts.TypeFlags.Void | ts.TypeFlags.Undefined))
|
|
869
981
|
return VOID;
|
|
982
|
+
// Generic visitors can instantiate `T | undefined` as `void | undefined`.
|
|
983
|
+
// It has the same return convention as standalone void; value positions
|
|
984
|
+
// still substitute the unit-only slot through isUnitOnlyTsType below.
|
|
985
|
+
if (widened.isUnionType() && ts.constituentTypes(widened).every((part) => {
|
|
986
|
+
if ((part.flags & (ts.TypeFlags.Void | ts.TypeFlags.Undefined)) !== 0)
|
|
987
|
+
return true;
|
|
988
|
+
// A forwarding generic call keeps its caller's symbolic T in the
|
|
989
|
+
// resolved signature. Its current instantiation can still be void.
|
|
990
|
+
if ((part.flags & ts.TypeFlags.TypeParameter) !== 0 && resolveTypeParam?.(part)?.kind === "void") {
|
|
991
|
+
contextResolutions++;
|
|
992
|
+
return true;
|
|
993
|
+
}
|
|
994
|
+
return false;
|
|
995
|
+
}))
|
|
996
|
+
return VOID;
|
|
870
997
|
// Standalone `null` (a `const x = null` binding, a `{ value: null }`
|
|
871
998
|
// field, a `(): null` return): the unit-only union — the value is always
|
|
872
999
|
// THE interned null instance, comparisons are tag tests, JSON serializes
|
|
@@ -981,7 +1108,8 @@ function mapTypeInner(type, ctx) {
|
|
|
981
1108
|
// function VALUE is one ScrClosure for its whole life — top-level
|
|
982
1109
|
// declarations intern one immortal closure, and inner closures are
|
|
983
1110
|
// allocated once at their definition's evaluation and flow by
|
|
984
|
-
// reference, exactly JS's function identity.
|
|
1111
|
+
// reference, exactly JS's function identity. Maps and Sets use their
|
|
1112
|
+
// typed RC/trace adapters; RegExp values use immutable REF storage. URL and
|
|
985
1113
|
// Date (scalar-backed but identity-bearing in JS) and the other opaque
|
|
986
1114
|
// handles stay unsupported as array elements; ordinary Date locals,
|
|
987
1115
|
// params, fixed record/tuple fields, and promise payloads are supported.
|
|
@@ -993,7 +1121,7 @@ function mapTypeInner(type, ctx) {
|
|
|
993
1121
|
// `undefined[]` (sparse literals — `[,]` — and explicit annotations):
|
|
994
1122
|
// the element rides the unit-only union like a record field would; the
|
|
995
1123
|
// VOID mapping is a return-position artifact, not a value.
|
|
996
|
-
if (elem?.kind === "void" && isUnitOnlyTsType(elemTs))
|
|
1124
|
+
if (elem?.kind === "void" && isUnitOnlyTsType(elemTs, ctx.resolveTypeParam))
|
|
997
1125
|
elem = unitOnlyUnion(unions);
|
|
998
1126
|
// A jsval element ABSORBS the array — with one carve-out. An array
|
|
999
1127
|
// type entangled with package-declared ('npm-jsval') elements
|
|
@@ -1011,15 +1139,15 @@ function mapTypeInner(type, ctx) {
|
|
|
1011
1139
|
// A dyn ELEMENT makes the WHOLE array the checked-dynamic value:
|
|
1012
1140
|
// `unknown[]`, `object[]`, and the collapsed `(string | object)[]`
|
|
1013
1141
|
// (the plugins-slot shape) — the checked-dynamic tree has real arrays, so length/
|
|
1014
|
-
// index/push/iteration ride the keyed-dyn paths
|
|
1015
|
-
//
|
|
1016
|
-
//
|
|
1142
|
+
// index/push/iteration ride the keyed-dyn paths. Native dyn-element
|
|
1143
|
+
// vectors are reserved for collection seeds and drains, rather than
|
|
1144
|
+
// changing this public representation. This is dynFallbackType's JS stance promoted into
|
|
1017
1145
|
// the mapping itself; construction sites build dynArrLit (the checked-dynamic tree
|
|
1018
1146
|
// array literal) and typed sources convert per element at the slot.
|
|
1019
1147
|
if (elem.kind === "dyn")
|
|
1020
1148
|
return DYN;
|
|
1021
1149
|
// The shared predicate is the runtime/backend storage contract. In
|
|
1022
|
-
// particular, valid standalone values such as
|
|
1150
|
+
// particular, valid standalone values such as Date and opaque
|
|
1023
1151
|
// handles do not automatically have an array element representation.
|
|
1024
1152
|
if (!isSupportedArrayElem(elem))
|
|
1025
1153
|
return null;
|
|
@@ -1076,7 +1204,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1076
1204
|
let et = mapType(args[i], ctx);
|
|
1077
1205
|
// A unit-only element (`[number, undefined]`) rides the unit-only
|
|
1078
1206
|
// union, the record-field rule.
|
|
1079
|
-
if (et?.kind === "void" && isUnitOnlyTsType(args[i]))
|
|
1207
|
+
if (et?.kind === "void" && isUnitOnlyTsType(args[i], ctx.resolveTypeParam))
|
|
1080
1208
|
et = unitOnlyUnion(unions);
|
|
1081
1209
|
// dyn ELEMENTS map now — `[string, unknown]`, the Object.entries
|
|
1082
1210
|
// tuple over an `unknown`-valued index signature (the pricing-table
|
|
@@ -1084,8 +1212,8 @@ function mapTypeInner(type, ctx) {
|
|
|
1084
1212
|
// plumbing, values arrive dyn or convert via dynFrom.
|
|
1085
1213
|
if (!et || et.kind === "void")
|
|
1086
1214
|
return null;
|
|
1087
|
-
// A jsval
|
|
1088
|
-
//
|
|
1215
|
+
// A jsval member keeps this tuple in the island as a real JS array.
|
|
1216
|
+
// Object records may instead keep ambient abort handles in slots.
|
|
1089
1217
|
if (et.kind === "jsval")
|
|
1090
1218
|
return JSVAL;
|
|
1091
1219
|
fields.push({ name: String(i), type: et });
|
|
@@ -1104,8 +1232,6 @@ function mapTypeInner(type, ctx) {
|
|
|
1104
1232
|
if (brandedPrimitive)
|
|
1105
1233
|
return brandedPrimitive;
|
|
1106
1234
|
}
|
|
1107
|
-
// Class instances: the type's symbol is a class declared in the user's
|
|
1108
|
-
// file. The class NAME as a value has the *constructor* type — same
|
|
1109
1235
|
// REFINED handle intersections — @types/node's idioms: `ServerResponse<
|
|
1110
1236
|
// IncomingMessage> & { req: IncomingMessage }` (RequestListener's
|
|
1111
1237
|
// inferred res param — every unannotated http.createServer handler) and
|
|
@@ -1157,8 +1283,11 @@ function mapTypeInner(type, ctx) {
|
|
|
1157
1283
|
}
|
|
1158
1284
|
}
|
|
1159
1285
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1286
|
+
const classView = mapClassView(widened, ctx);
|
|
1287
|
+
if (classView !== undefined)
|
|
1288
|
+
return classView;
|
|
1289
|
+
// Class instances name a program class. The same symbol with construct
|
|
1290
|
+
// signatures names its static side, mapped to classval below.
|
|
1162
1291
|
const widenedSym = widened.getSymbol();
|
|
1163
1292
|
const classDecl = widenedSym ? checker.valueDeclarationOf(widenedSym) : undefined;
|
|
1164
1293
|
if (classDecl &&
|
|
@@ -1185,17 +1314,17 @@ function mapTypeInner(type, ctx) {
|
|
|
1185
1314
|
return viaMixin;
|
|
1186
1315
|
}
|
|
1187
1316
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1317
|
+
if (classExprNeedsContext(classDecl)) {
|
|
1318
|
+
const local = ctx.localClassInstance?.(classDecl);
|
|
1319
|
+
if (local)
|
|
1320
|
+
contextResolutions++;
|
|
1321
|
+
return local ?? null;
|
|
1322
|
+
}
|
|
1192
1323
|
// A GENERIC class's instance type (`Box<number>`) maps to the concrete
|
|
1193
1324
|
// INSTANTIATION's class (`Box%0`), registered on demand — the Lowerer
|
|
1194
1325
|
// hook owns the instance table (monomorphization by flow).
|
|
1195
1326
|
if (classDecl.typeParameters) {
|
|
1196
|
-
const instance = ctx.genericClassInstance
|
|
1197
|
-
? ctx.genericClassInstance(classDecl, widened)
|
|
1198
|
-
: null;
|
|
1327
|
+
const instance = ctx.genericClassInstance?.(classDecl, widened, (argument) => mapType(argument, ctx)) ?? null;
|
|
1199
1328
|
// Before the generic declaration's collection turn, the hook can only
|
|
1200
1329
|
// return its family shell; after collection the same checker type names
|
|
1201
1330
|
// a concrete registered instance. Never memoize either phase's answer.
|
|
@@ -1223,8 +1352,14 @@ function mapTypeInner(type, ctx) {
|
|
|
1223
1352
|
return { kind: "classval", className: viaMixin.className };
|
|
1224
1353
|
}
|
|
1225
1354
|
}
|
|
1226
|
-
if (
|
|
1355
|
+
if (classExprNeedsContext(classDecl)) {
|
|
1356
|
+
const local = ctx.localClassInstance?.(classDecl);
|
|
1357
|
+
if (local?.kind === "object") {
|
|
1358
|
+
contextResolutions++;
|
|
1359
|
+
return { kind: "classval", className: local.className };
|
|
1360
|
+
}
|
|
1227
1361
|
return null;
|
|
1362
|
+
}
|
|
1228
1363
|
// A GENERIC class's static side: only an INSTANTIATED one maps — an
|
|
1229
1364
|
// instantiation expression's type (`Box<number>` as a value) carries a
|
|
1230
1365
|
// construct signature returning the concrete instance, which maps to
|
|
@@ -1269,8 +1404,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1269
1404
|
const psym = widened.getSymbol();
|
|
1270
1405
|
const isStdlibInterface = (name) => psym?.name === name &&
|
|
1271
1406
|
checker.declarationsOf(psym).some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(d.getSourceFile()));
|
|
1272
|
-
// The builtin Error classes: references to the
|
|
1273
|
-
// RangeError/SyntaxError interfaces map to the runtime-provided class
|
|
1407
|
+
// The builtin Error classes: references to the lib's Error interfaces map to the runtime-provided class
|
|
1274
1408
|
// hierarchy (provenance, not the name — a user's own `class Error`
|
|
1275
1409
|
// resolved through the class-instance branch above, and a user
|
|
1276
1410
|
// `interface Error` maps as a record). The '%'-prefixed IR names are the
|
|
@@ -1355,6 +1489,15 @@ function mapTypeInner(type, ctx) {
|
|
|
1355
1489
|
isDeclaredInAmbientModule(d, "diagnostics_channel"))) {
|
|
1356
1490
|
return F64;
|
|
1357
1491
|
}
|
|
1492
|
+
// WHATWG codec instances have ordinary reference identity and ownership.
|
|
1493
|
+
// Their private encoding slot is omitted from enumeration and JSON.
|
|
1494
|
+
if ((psym?.name === "TextEncoder" || psym?.name === "TextDecoder") &&
|
|
1495
|
+
checker.declarationsOf(psym).some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) && ctx.isStdlibFile(d.getSourceFile()))) {
|
|
1496
|
+
return {
|
|
1497
|
+
kind: "record",
|
|
1498
|
+
shapeId: ctx.shapes.intern([{ name: `%${psym.name}`, type: F64 }], false, undefined, []),
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1358
1501
|
// string_decoder.StringDecoder: the decoder value is a two-field record
|
|
1359
1502
|
// — the CANONICAL encoding name (construction normalizes aliases; the
|
|
1360
1503
|
// `.encoding` property reads it) and the f64 packing the pending
|
|
@@ -1383,9 +1526,10 @@ function mapTypeInner(type, ctx) {
|
|
|
1383
1526
|
// record-holding binding forms compile. User-declared literals with
|
|
1384
1527
|
// these member names keep the ordinary record path (their declarations
|
|
1385
1528
|
// are not in declaration files).
|
|
1529
|
+
const promiseDeclarations = psym ? checker.declarationsOf(psym) : [];
|
|
1386
1530
|
if (flags & ts.TypeFlags.Object &&
|
|
1387
|
-
|
|
1388
|
-
|
|
1531
|
+
promiseDeclarations.length > 0 &&
|
|
1532
|
+
promiseDeclarations.every((d) => d.getSourceFile().isDeclarationFile)) {
|
|
1389
1533
|
const props = checker.getPropertiesOfType(widened);
|
|
1390
1534
|
if (props.length === 3 &&
|
|
1391
1535
|
["promise", "resolve", "reject"].every((n) => props.some((p) => p.name === n))) {
|
|
@@ -1478,26 +1622,33 @@ function mapTypeInner(type, ctx) {
|
|
|
1478
1622
|
const args = checker.getTypeArguments(widened);
|
|
1479
1623
|
if (args.length !== 2)
|
|
1480
1624
|
return null;
|
|
1481
|
-
const key = mapType(args[0], ctx);
|
|
1482
|
-
if (!key || !isSupportedMapKey(key))
|
|
1625
|
+
const key = !ctx.dynamic && (args[0].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[0], ctx);
|
|
1626
|
+
if (!key || !isSupportedMapKey(key, key.kind === "union" ? ctx.unions.get(key.unionId)?.arms : undefined))
|
|
1483
1627
|
return null;
|
|
1484
|
-
const value = mapType(args[1], ctx);
|
|
1628
|
+
const value = !ctx.dynamic && (args[1].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[1], ctx);
|
|
1485
1629
|
if (!value || !isSupportedMapValue(value))
|
|
1486
1630
|
return null;
|
|
1487
1631
|
return mapOf(key, value);
|
|
1488
1632
|
}
|
|
1489
|
-
//
|
|
1490
|
-
//
|
|
1633
|
+
// Native WeakMap keeps reference identities in checked-dynamic storage.
|
|
1634
|
+
// The runtime rejects reference kinds without a weak lifetime contract.
|
|
1635
|
+
if (isStdlibInterface("WeakMap") || isStdlibInterface("WeakSet"))
|
|
1636
|
+
return ctx.dynamic ? JSVAL : DYN;
|
|
1637
|
+
// Set<T>: Map's sibling — same provenance rule and key domain.
|
|
1638
|
+
// Anything else stays unmapped;
|
|
1491
1639
|
// the `new Set` lowering names the offending element type specifically.
|
|
1492
1640
|
if (isStdlibInterface("Set") || isStdlibInterface("ReadonlySet")) {
|
|
1493
1641
|
const args = checker.getTypeArguments(widened);
|
|
1494
1642
|
if (args.length !== 1)
|
|
1495
1643
|
return null;
|
|
1496
|
-
const elem = mapType(args[0], ctx);
|
|
1497
|
-
if (!elem || !isSupportedSetElem(elem))
|
|
1644
|
+
const elem = !ctx.dynamic && (args[0].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[0], ctx);
|
|
1645
|
+
if (!elem || !isSupportedSetElem(elem, elem.kind === "union" ? ctx.unions.get(elem.unionId)?.arms : undefined))
|
|
1498
1646
|
return null;
|
|
1499
1647
|
return setOf(elem);
|
|
1500
1648
|
}
|
|
1649
|
+
const collectionView = mapCollectionView(widened, ctx);
|
|
1650
|
+
if (collectionView)
|
|
1651
|
+
return collectionView;
|
|
1501
1652
|
// Date: a TimeClip'd epoch-millisecond scalar in the static runtime.
|
|
1502
1653
|
// This supports stored/passed values and the read-only getter slice;
|
|
1503
1654
|
// identity and mutation stay fenced because the scalar deliberately
|
|
@@ -1511,6 +1662,8 @@ function mapTypeInner(type, ctx) {
|
|
|
1511
1662
|
if (isStdlibInterface("RegExp")) {
|
|
1512
1663
|
return { kind: "regex" };
|
|
1513
1664
|
}
|
|
1665
|
+
if (isStdlibInterface("Segmenter") || isStdlibInterface("Segments") || isStdlibInterface("SegmentData"))
|
|
1666
|
+
return DYN;
|
|
1514
1667
|
// Typed arrays: references to the lib's Uint8Array/Uint32Array/
|
|
1515
1668
|
// Float32Array/Float64Array interfaces (provenance, not names). The es2022+ lib
|
|
1516
1669
|
// declares them generic over the backing buffer (`Uint8Array<ArrayBuffer>`
|
|
@@ -1550,10 +1703,20 @@ function mapTypeInner(type, ctx) {
|
|
|
1550
1703
|
// space, so clearTimeout of an Immediate no-ops like Node.
|
|
1551
1704
|
if (isStdlibInterface("Immediate"))
|
|
1552
1705
|
return F64;
|
|
1706
|
+
if (isStdlibInterface("ArrayBuffer") || isStdlibInterface("PropertyDescriptor") || isStdlibInterface("ProcessVersions"))
|
|
1707
|
+
return DYN;
|
|
1553
1708
|
if (isStdlibInterface("Uint8Array"))
|
|
1554
1709
|
return bytesOf("u8");
|
|
1555
1710
|
if (isStdlibInterface("Uint32Array"))
|
|
1556
1711
|
return bytesOf("u32");
|
|
1712
|
+
if (isStdlibInterface("Uint8ClampedArray"))
|
|
1713
|
+
return bytesOf("u8c");
|
|
1714
|
+
if (isStdlibInterface("Int8Array"))
|
|
1715
|
+
return bytesOf("i8");
|
|
1716
|
+
if (isStdlibInterface("Uint16Array"))
|
|
1717
|
+
return bytesOf("u16");
|
|
1718
|
+
if (isStdlibInterface("Int16Array"))
|
|
1719
|
+
return bytesOf("i16");
|
|
1557
1720
|
// Int32Array: the signed 32-bit kind (element reads sign-extend, writes
|
|
1558
1721
|
// ToInt32-wrap) — the Atomics.wait sleep idiom constructs one over a
|
|
1559
1722
|
// SharedArrayBuffer, and the i32 semantics hold for every other use.
|
|
@@ -1906,8 +2069,8 @@ function mapTypeInner(type, ctx) {
|
|
|
1906
2069
|
// boxes; the yield expression reads checked-dynamic);
|
|
1907
2070
|
// else the mapped type (`.next(v)` requires its
|
|
1908
2071
|
// argument — fenced at the call).
|
|
1909
|
-
// Mixed dyn/concrete channels
|
|
1910
|
-
//
|
|
2072
|
+
// Mixed dyn/concrete value channels share checked storage, so either
|
|
2073
|
+
// branch of the result record has the same representation.
|
|
1911
2074
|
if (isStdlibInterface("Generator") || isStdlibInterface("AsyncGenerator") || isStdlibInterface("IterableIterator")) {
|
|
1912
2075
|
const args = checker.getTypeArguments(widened);
|
|
1913
2076
|
const channels = genChannels(args[0], args[1], args[2], ctx);
|
|
@@ -2228,7 +2391,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2228
2391
|
// tsgo never SYNTHESIZES that rest param into the inferred signature
|
|
2229
2392
|
// (5.9.3 did — the count mismatch above was the whole detector
|
|
2230
2393
|
// there), so the declaration's own body answers directly.
|
|
2231
|
-
if (sigDecl !== undefined && ts.isFunctionLike(sigDecl) &&
|
|
2394
|
+
if (sigDecl !== undefined && ts.isFunctionLike(sigDecl) && bodyReadsArguments(sigDecl)) {
|
|
2232
2395
|
return null;
|
|
2233
2396
|
}
|
|
2234
2397
|
}
|
|
@@ -2247,10 +2410,12 @@ function mapTypeInner(type, ctx) {
|
|
|
2247
2410
|
ts.isParameter(decl) &&
|
|
2248
2411
|
(decl.questionToken !== undefined || decl.initializer !== undefined);
|
|
2249
2412
|
let pt = mapType(checker.getTypeOfSymbol(p), ctx);
|
|
2413
|
+
if (pt)
|
|
2414
|
+
pt = jsOpenObjectType(decl, pt, ctx.shapes, ctx.unions);
|
|
2250
2415
|
// Belt and braces for non-strict type worlds: an optional param's
|
|
2251
2416
|
// ABI slot is always the undefined-armed union (strictNullChecks
|
|
2252
2417
|
// already spells it that way; arm it here if the world didn't).
|
|
2253
|
-
if (optional && pt && pt.kind !== "void" && pt.kind !== "jsval") {
|
|
2418
|
+
if (optional && pt && pt.kind !== "void" && pt.kind !== "jsval" && pt.kind !== "dyn") {
|
|
2254
2419
|
const armed = withUndefinedArm(pt, ctx.unions);
|
|
2255
2420
|
if (!armed)
|
|
2256
2421
|
return null;
|
|
@@ -2272,8 +2437,13 @@ function mapTypeInner(type, ctx) {
|
|
|
2272
2437
|
const retT = checker.getReturnTypeOfSignature(sig);
|
|
2273
2438
|
// `() => never` (a throw-only lambda's inferred type) is assignable to
|
|
2274
2439
|
// `() => void` and its calls never produce a value — map the return
|
|
2275
|
-
// like declaredReturnType does for declarations.
|
|
2276
|
-
|
|
2440
|
+
// like declaredReturnType does for declarations. JS null/undefined
|
|
2441
|
+
// returns can read mutable fields, so callable values use the same
|
|
2442
|
+
// checked-native return ABI as their implementations.
|
|
2443
|
+
const sigDecl = checker.signatureDeclaration(sig);
|
|
2444
|
+
const jsUnitReturn = sigDecl !== undefined && isJsSourceFile(sigDecl.getSourceFile()) &&
|
|
2445
|
+
(retT.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) !== 0;
|
|
2446
|
+
const ret = jsUnitReturn ? DYN : retT.flags & ts.TypeFlags.Never ? VOID : mapType(retT, ctx);
|
|
2277
2447
|
if (!ret)
|
|
2278
2448
|
return null;
|
|
2279
2449
|
return typedRest
|
|
@@ -2364,7 +2534,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2364
2534
|
// literal unions like `"a" | "b"` — parts that map to the SAME IR type
|
|
2365
2535
|
// collapse (deduplicated by typeKey), so a single surviving arm is just
|
|
2366
2536
|
// that type. Two or more distinct arms become a TAGGED union: the
|
|
2367
|
-
// typeKey-sorted arm list
|
|
2537
|
+
// typeKey-sorted arm list and discriminator are interned, and an arm's index
|
|
2368
2538
|
// in that list is its runtime tag. `undefined` and `null` PARTS become
|
|
2369
2539
|
// the unit arms undefinedT/nullT — strictNullChecks spells optionality
|
|
2370
2540
|
// as exactly these unions (`string | undefined`, `number | null`), and
|
|
@@ -2388,7 +2558,12 @@ function mapTypeInner(type, ctx) {
|
|
|
2388
2558
|
const sensitivityAtEntry = contextResolutions;
|
|
2389
2559
|
try {
|
|
2390
2560
|
const byKey = new Map();
|
|
2561
|
+
const recordParts = [];
|
|
2391
2562
|
for (const part of ts.constituentTypes(widened)) {
|
|
2563
|
+
// TypeScript's client can retain impossible intersections in a
|
|
2564
|
+
// distributed union. They have no inhabitants and no runtime tag.
|
|
2565
|
+
if (checker.isNeverType(part))
|
|
2566
|
+
continue;
|
|
2392
2567
|
// A `void` PART is inhabited only by undefined (`Promise<void> |
|
|
2393
2568
|
// void` return types, `string | void`): it becomes the undefinedT
|
|
2394
2569
|
// unit arm, exactly like an undefined part — the value either
|
|
@@ -2423,9 +2598,17 @@ function mapTypeInner(type, ctx) {
|
|
|
2423
2598
|
}
|
|
2424
2599
|
return null;
|
|
2425
2600
|
}
|
|
2601
|
+
if (mapped.kind === "void") {
|
|
2602
|
+
byKey.set(typeKey(UNDEFINED_T), UNDEFINED_T);
|
|
2603
|
+
continue;
|
|
2604
|
+
}
|
|
2426
2605
|
byKey.set(typeKey(mapped), mapped);
|
|
2606
|
+
if (mapped.kind === "record")
|
|
2607
|
+
recordParts.push({ source: part, mapped });
|
|
2427
2608
|
}
|
|
2428
2609
|
const arms = [...byKey.values()];
|
|
2610
|
+
if (arms.length === 0)
|
|
2611
|
+
return F64; // same unreachable placeholder as standalone never
|
|
2429
2612
|
// A single surviving UNIT arm cannot stand alone (degenerate — the
|
|
2430
2613
|
// checker collapsed everything else away); anything else single is
|
|
2431
2614
|
// just that type. A single arm UNDER A MINTED PLACEHOLDER cannot
|
|
@@ -2465,29 +2648,12 @@ function mapTypeInner(type, ctx) {
|
|
|
2465
2648
|
return DYN;
|
|
2466
2649
|
}
|
|
2467
2650
|
if (arms.some((a) => a.kind === "void" || a.kind === "union" ||
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
// arms map: `x instanceof RegExp` is their narrowing test
|
|
2471
|
-
// (the skip-utility `string | RegExp` shape), and the arm
|
|
2472
|
-
// rides the ref machinery like array regex elements.
|
|
2473
|
-
a.kind === "map" || a.kind === "set" || a.kind === "date" || a.kind === "dyn" ||
|
|
2474
|
-
// Generator arms follow the map/set rule: no narrowing test.
|
|
2475
|
-
a.kind === "generator" ||
|
|
2476
|
-
// Func arms map beside ANY sibling: `typeof x === "function"`
|
|
2477
|
-
// is the narrowing against data arms (typeofAnswer knows every
|
|
2478
|
-
// arm kind), unit TAG tests cover the nullable-callback shape
|
|
2479
|
-
// (cb !== null, cb ?? f, cb?.()), and against FUNC siblings
|
|
2480
|
-
// (`StringConstructor | NumberConstructor` — the option-table
|
|
2481
|
-
// field) closures compare by pointer identity per tag
|
|
2482
|
-
// (unionEq), so `x === String` narrows. No restriction left.
|
|
2483
|
-
// Promise arms follow the func rule (typeof gives no test
|
|
2484
|
-
// against sibling data arms): only the promise-or-absent shape
|
|
2485
|
-
// maps — `Promise<T> | undefined`, and `Promise<T> | void`
|
|
2486
|
-
// return types whose void part became the undefined arm above.
|
|
2487
|
-
(a.kind === "promise" && !arms.every((b) => b === a || isUnitType(b))))) {
|
|
2651
|
+
a.kind === "date" || a.kind === "dyn" ||
|
|
2652
|
+
a.kind === "generator") || !unionContainerArmsOk(arms)) {
|
|
2488
2653
|
return null;
|
|
2489
2654
|
}
|
|
2490
2655
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2656
|
+
const discriminant = unionDiscriminant(recordParts, arms, ctx);
|
|
2491
2657
|
if (unions.recursivePending(widened)) {
|
|
2492
2658
|
// The knot closed through this union. A frame that resolved
|
|
2493
2659
|
// through context-sensitive hooks (generic type parameters, mixin
|
|
@@ -2496,9 +2662,9 @@ function mapTypeInner(type, ctx) {
|
|
|
2496
2662
|
// recursive generic-open unions stay fenced.
|
|
2497
2663
|
if (contextResolutions !== sensitivityAtEntry)
|
|
2498
2664
|
return null;
|
|
2499
|
-
return { kind: "union", unionId: unions.finalizeRecursive(widened, arms) };
|
|
2665
|
+
return { kind: "union", unionId: unions.finalizeRecursive(widened, arms, discriminant) };
|
|
2500
2666
|
}
|
|
2501
|
-
return { kind: "union", unionId: unions.intern(arms) };
|
|
2667
|
+
return { kind: "union", unionId: unions.intern(arms, discriminant) };
|
|
2502
2668
|
}
|
|
2503
2669
|
finally {
|
|
2504
2670
|
unions.inProgress.delete(widened);
|
|
@@ -2506,6 +2672,231 @@ function mapTypeInner(type, ctx) {
|
|
|
2506
2672
|
}
|
|
2507
2673
|
return null;
|
|
2508
2674
|
}
|
|
2675
|
+
/** Retain a literal discriminator before widening erases its values. A
|
|
2676
|
+
* structural match alone is insufficient: `{ kind: "loop", body: ... }`
|
|
2677
|
+
* also fits a smaller `{ kind: "empty" }` record. Choosing that layout
|
|
2678
|
+
* makes a later switch on kind read fields outside the allocated object.
|
|
2679
|
+
*
|
|
2680
|
+
* Require one common, required data property with finite literal values.
|
|
2681
|
+
* Values may repeat within a single storage arm (several variants share a
|
|
2682
|
+
* shape), but never select different arms. Non-record arms keep their
|
|
2683
|
+
* ordinary kind checks. Types without an unambiguous discriminator retain
|
|
2684
|
+
* their structural boundary behavior. */
|
|
2685
|
+
function unionDiscriminant(parts, arms, ctx) {
|
|
2686
|
+
if (arms.filter((arm) => arm.kind === "record").length < 2 || parts.length < 2)
|
|
2687
|
+
return undefined;
|
|
2688
|
+
const { checker } = ctx;
|
|
2689
|
+
for (const candidate of checker.getPropertiesOfType(parts[0].source)) {
|
|
2690
|
+
if (candidate.name.startsWith("__@"))
|
|
2691
|
+
continue;
|
|
2692
|
+
const byTag = new Map();
|
|
2693
|
+
const owner = new Map();
|
|
2694
|
+
let complete = true;
|
|
2695
|
+
for (const part of parts) {
|
|
2696
|
+
const prop = checker.getPropertyOfType(part.source, candidate.name);
|
|
2697
|
+
if (!prop || prop.flags & (ts.SymbolFlags.Optional | ts.SymbolFlags.GetAccessor | ts.SymbolFlags.SetAccessor)) {
|
|
2698
|
+
complete = false;
|
|
2699
|
+
break;
|
|
2700
|
+
}
|
|
2701
|
+
const values = literalValues(checker.getTypeOfSymbol(prop));
|
|
2702
|
+
if (!values) {
|
|
2703
|
+
complete = false;
|
|
2704
|
+
break;
|
|
2705
|
+
}
|
|
2706
|
+
const tag = arms.findIndex((arm) => typeEquals(arm, part.mapped));
|
|
2707
|
+
const grouped = byTag.get(tag) ?? [];
|
|
2708
|
+
for (const value of values) {
|
|
2709
|
+
const key = JSON.stringify(value);
|
|
2710
|
+
const previous = owner.get(key);
|
|
2711
|
+
if (previous !== undefined && previous !== tag) {
|
|
2712
|
+
complete = false;
|
|
2713
|
+
break;
|
|
2714
|
+
}
|
|
2715
|
+
owner.set(key, tag);
|
|
2716
|
+
if (!grouped.includes(value))
|
|
2717
|
+
grouped.push(value);
|
|
2718
|
+
}
|
|
2719
|
+
if (!complete)
|
|
2720
|
+
break;
|
|
2721
|
+
byTag.set(tag, grouped);
|
|
2722
|
+
}
|
|
2723
|
+
if (complete) {
|
|
2724
|
+
return {
|
|
2725
|
+
field: candidate.name,
|
|
2726
|
+
cases: [...byTag].sort(([a], [b]) => a - b).map(([tag, values]) => ({
|
|
2727
|
+
tag, values: values.sort((a, b) => JSON.stringify(a) < JSON.stringify(b) ? -1 : JSON.stringify(a) > JSON.stringify(b) ? 1 : 0),
|
|
2728
|
+
})),
|
|
2729
|
+
};
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
return undefined;
|
|
2733
|
+
}
|
|
2734
|
+
/** A class-derived interface or intersection can refine existing members
|
|
2735
|
+
* without changing the object's layout. Keep the unique program class as
|
|
2736
|
+
* its representation; structural lookalikes without a class base do not
|
|
2737
|
+
* qualify. Construction and coercion must still supply that actual class.
|
|
2738
|
+
* Undefined means no class view, while null is a recognized but unsupported
|
|
2739
|
+
* view: do not fall through and copy an identity-bearing object to a record. */
|
|
2740
|
+
function mapClassView(type, ctx, seen = new Set()) {
|
|
2741
|
+
const { checker } = ctx;
|
|
2742
|
+
if (seen.has(type) || seen.size >= MAP_TYPE_MAX_DEPTH)
|
|
2743
|
+
return null;
|
|
2744
|
+
let bases;
|
|
2745
|
+
let viewCtx = ctx;
|
|
2746
|
+
if (type.isIntersectionType()) {
|
|
2747
|
+
bases = ts.constituentTypes(type);
|
|
2748
|
+
}
|
|
2749
|
+
else {
|
|
2750
|
+
const symbol = type.getSymbol();
|
|
2751
|
+
const declarations = symbol ? checker.declarationsOf(symbol) : [];
|
|
2752
|
+
if (declarations.length === 0 || !declarations.every((decl) => ts.isInterfaceDeclaration(decl) && !ctx.isStdlibFile(decl.getSourceFile())))
|
|
2753
|
+
return undefined;
|
|
2754
|
+
const target = type.isTypeReference() ? type.getTarget() : type;
|
|
2755
|
+
if (target === undefined || !target.isClassOrInterface())
|
|
2756
|
+
return undefined;
|
|
2757
|
+
bases = checker.getBaseTypes(target);
|
|
2758
|
+
if (type.isTypeReference() && target.isTypeReference()) {
|
|
2759
|
+
const params = checker.getTypeArguments(target);
|
|
2760
|
+
const args = checker.getTypeArguments(type);
|
|
2761
|
+
viewCtx = {
|
|
2762
|
+
...ctx,
|
|
2763
|
+
canMemoizeType: () => false,
|
|
2764
|
+
resolveTypeParam: (param) => {
|
|
2765
|
+
const index = params.indexOf(param);
|
|
2766
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2767
|
+
return arg && arg !== param ? mapType(arg, ctx) : ctx.resolveTypeParam?.(param) ?? null;
|
|
2768
|
+
},
|
|
2769
|
+
resolveTypeParamTs: (param) => {
|
|
2770
|
+
const index = params.indexOf(param);
|
|
2771
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2772
|
+
return arg && arg !== param ? ctx.resolveTypeParamTs?.(arg) ?? arg : ctx.resolveTypeParamTs?.(param) ?? null;
|
|
2773
|
+
},
|
|
2774
|
+
};
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
seen.add(type);
|
|
2778
|
+
try {
|
|
2779
|
+
let baseType;
|
|
2780
|
+
let representation;
|
|
2781
|
+
for (const base of bases) {
|
|
2782
|
+
const symbol = base.getSymbol();
|
|
2783
|
+
const declaration = symbol ? checker.valueDeclarationOf(symbol) : undefined;
|
|
2784
|
+
const classBase = declaration && (ts.isClassDeclaration(declaration) || ts.isClassExpression(declaration)) &&
|
|
2785
|
+
!declaration.getSourceFile().isDeclarationFile;
|
|
2786
|
+
const mapped = classBase ? mapType(base, viewCtx) : mapClassView(base, viewCtx, seen);
|
|
2787
|
+
if (mapped === null)
|
|
2788
|
+
return null;
|
|
2789
|
+
if (mapped === undefined)
|
|
2790
|
+
continue;
|
|
2791
|
+
if (mapped.kind !== "object" || (representation && !typeEquals(representation, mapped)))
|
|
2792
|
+
return null;
|
|
2793
|
+
baseType = base;
|
|
2794
|
+
representation = mapped;
|
|
2795
|
+
}
|
|
2796
|
+
if (!representation || !baseType)
|
|
2797
|
+
return undefined;
|
|
2798
|
+
if (checker.getCallSignatures(type).length || checker.getConstructSignatures(type).length ||
|
|
2799
|
+
checker.getIndexInfosOfType(type).length)
|
|
2800
|
+
return null;
|
|
2801
|
+
for (const property of checker.getPropertiesOfType(type)) {
|
|
2802
|
+
const original = checker.getPropertyOfType(baseType, property.name);
|
|
2803
|
+
if (!original)
|
|
2804
|
+
return null;
|
|
2805
|
+
if (original === property)
|
|
2806
|
+
continue;
|
|
2807
|
+
const originalDeclarations = checker.declarationsOf(original);
|
|
2808
|
+
const declarations = checker.declarationsOf(property);
|
|
2809
|
+
// Instantiating an inherited member can create a new symbol without
|
|
2810
|
+
// changing its declaration or ABI. Only refinements need validation.
|
|
2811
|
+
if (declarations.length > 0 && declarations.length === originalDeclarations.length &&
|
|
2812
|
+
declarations.every((declaration, index) => declaration === originalDeclarations[index]))
|
|
2813
|
+
continue;
|
|
2814
|
+
const before = checker.getTypeOfSymbol(original);
|
|
2815
|
+
const after = checker.getTypeOfSymbol(property);
|
|
2816
|
+
if (checker.getCallSignatures(before).length || checker.getCallSignatures(after).length) {
|
|
2817
|
+
const from = mapType(before, viewCtx);
|
|
2818
|
+
const to = mapType(after, viewCtx);
|
|
2819
|
+
if (!from || !to || !typeEquals(from, to))
|
|
2820
|
+
return null;
|
|
2821
|
+
}
|
|
2822
|
+
else if (!checker.isTypeAssignableTo(after, before)) {
|
|
2823
|
+
return null;
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
return representation;
|
|
2827
|
+
}
|
|
2828
|
+
finally {
|
|
2829
|
+
seen.delete(type);
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
/** Interface views of native collections may inherit their runtime surface
|
|
2833
|
+
* and refine `has` into a type predicate. Keep declaration provenance and
|
|
2834
|
+
* require the same call ABI; extra fields or replacement methods need a
|
|
2835
|
+
* different representation. Value construction/coercion still has to prove
|
|
2836
|
+
* a native Map/Set, so structural mocks cannot acquire a native handle. */
|
|
2837
|
+
function mapCollectionView(type, ctx, seen = new Set()) {
|
|
2838
|
+
if (!type.isTypeReference())
|
|
2839
|
+
return null;
|
|
2840
|
+
const { checker } = ctx;
|
|
2841
|
+
const symbol = type.getSymbol();
|
|
2842
|
+
const declarations = symbol ? checker.declarationsOf(symbol) : [];
|
|
2843
|
+
if (declarations.length === 0 || !declarations.every((decl) => ts.isInterfaceDeclaration(decl) && !ctx.isStdlibFile(decl.getSourceFile())))
|
|
2844
|
+
return null;
|
|
2845
|
+
const target = type.getTarget();
|
|
2846
|
+
if (target === undefined || !target.isClassOrInterface() || seen.has(target) || seen.size >= MAP_TYPE_MAX_DEPTH)
|
|
2847
|
+
return null;
|
|
2848
|
+
const bases = checker.getBaseTypes(target);
|
|
2849
|
+
if (bases.length !== 1)
|
|
2850
|
+
return null;
|
|
2851
|
+
if (checker.getCallSignatures(type).length || checker.getConstructSignatures(type).length ||
|
|
2852
|
+
checker.getIndexInfosOfType(type).length)
|
|
2853
|
+
return null;
|
|
2854
|
+
// Base declarations contain the interface's parameters, even when this
|
|
2855
|
+
// reference is instantiated. Resolve those through this reference before
|
|
2856
|
+
// mapping the base; never cache a template under one instantiation's ABI.
|
|
2857
|
+
const params = checker.getTypeArguments(target);
|
|
2858
|
+
const args = checker.getTypeArguments(type);
|
|
2859
|
+
const baseCtx = {
|
|
2860
|
+
...ctx,
|
|
2861
|
+
canMemoizeType: () => false,
|
|
2862
|
+
resolveTypeParam: (param) => {
|
|
2863
|
+
const index = params.indexOf(param);
|
|
2864
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2865
|
+
return arg && arg !== param ? mapType(arg, ctx) : ctx.resolveTypeParam?.(param) ?? null;
|
|
2866
|
+
},
|
|
2867
|
+
resolveTypeParamTs: (param) => {
|
|
2868
|
+
const index = params.indexOf(param);
|
|
2869
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2870
|
+
return arg && arg !== param ? ctx.resolveTypeParamTs?.(arg) ?? arg : ctx.resolveTypeParamTs?.(param) ?? null;
|
|
2871
|
+
},
|
|
2872
|
+
};
|
|
2873
|
+
seen.add(target);
|
|
2874
|
+
try {
|
|
2875
|
+
const base = bases[0];
|
|
2876
|
+
const baseSymbol = base.getSymbol();
|
|
2877
|
+
const native = baseSymbol && ["Map", "ReadonlyMap", "Set", "ReadonlySet"].includes(baseSymbol.name) &&
|
|
2878
|
+
checker.declarationsOf(baseSymbol).some((decl) => ts.isInterfaceDeclaration(decl) && ctx.isStdlibFile(decl.getSourceFile()));
|
|
2879
|
+
const mapped = native ? mapType(base, baseCtx) : mapCollectionView(base, baseCtx, seen);
|
|
2880
|
+
if (mapped?.kind !== "map" && mapped?.kind !== "set")
|
|
2881
|
+
return null;
|
|
2882
|
+
const hasType = funcOf([mapped.kind === "map" ? mapped.key : mapped.elem], BOOL);
|
|
2883
|
+
for (const property of checker.getPropertiesOfType(type)) {
|
|
2884
|
+
const own = checker.declarationsOf(property).filter((decl) => !ctx.isStdlibFile(decl.getSourceFile()));
|
|
2885
|
+
if (own.length === 0)
|
|
2886
|
+
continue;
|
|
2887
|
+
if (property.name !== "has" || (property.flags & ts.SymbolFlags.Optional) ||
|
|
2888
|
+
!own.every((decl) => decl.kind === ts.SyntaxKind.MethodSignature))
|
|
2889
|
+
return null;
|
|
2890
|
+
const method = mapType(checker.getTypeOfSymbol(property), ctx);
|
|
2891
|
+
if (!method || !typeEquals(method, hasType))
|
|
2892
|
+
return null;
|
|
2893
|
+
}
|
|
2894
|
+
return mapped;
|
|
2895
|
+
}
|
|
2896
|
+
finally {
|
|
2897
|
+
seen.delete(target);
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2509
2900
|
/** The narrowed-type-parameter recognizer behind mapType's early return:
|
|
2510
2901
|
* a union/intersection over exactly ONE type parameter whose companions
|
|
2511
2902
|
* are all `{}`-empty shapes or the null/undefined units. Returns the
|
|
@@ -2585,7 +2976,7 @@ function mapBoundIndexedAccess(type, ctx) {
|
|
|
2585
2976
|
const { checker, resolveTypeParamTs } = ctx;
|
|
2586
2977
|
if (!resolveTypeParamTs || !type.isIndexedAccessType())
|
|
2587
2978
|
return null;
|
|
2588
|
-
const resolveSide = (t) => t.flags & ts.TypeFlags.TypeParameter ? resolveTypeParamTs(t) : t;
|
|
2979
|
+
const resolveSide = (t) => t === undefined ? null : t.flags & ts.TypeFlags.TypeParameter ? resolveTypeParamTs(t) : t;
|
|
2589
2980
|
const objT = resolveSide(type.getObjectType());
|
|
2590
2981
|
const idxT = resolveSide(type.getIndexType());
|
|
2591
2982
|
if (!objT || !idxT)
|
|
@@ -2702,7 +3093,7 @@ function mapGenericIndexedAccess(type, ctx) {
|
|
|
2702
3093
|
if (!resolveTypeParam || !type.isIndexedAccessType())
|
|
2703
3094
|
return null;
|
|
2704
3095
|
const obj = type.getObjectType();
|
|
2705
|
-
if (!(obj.flags & ts.TypeFlags.TypeParameter))
|
|
3096
|
+
if (obj === undefined || !(obj.flags & ts.TypeFlags.TypeParameter))
|
|
2706
3097
|
return null;
|
|
2707
3098
|
const bound = resolveTypeParam(obj);
|
|
2708
3099
|
if (!bound || bound.kind !== "record")
|
|
@@ -2711,13 +3102,15 @@ function mapGenericIndexedAccess(type, ctx) {
|
|
|
2711
3102
|
if (!shape || shape.tuple)
|
|
2712
3103
|
return null;
|
|
2713
3104
|
const idx = type.getIndexType();
|
|
3105
|
+
if (idx === undefined)
|
|
3106
|
+
return null;
|
|
2714
3107
|
let covered = null;
|
|
2715
3108
|
if (idx.isStringLiteralType()) {
|
|
2716
3109
|
const f = shape.fields.find((x) => x.name === idx.value);
|
|
2717
3110
|
covered = f ? [f.type] : shape.indexValue ? [shape.indexValue] : null;
|
|
2718
3111
|
}
|
|
2719
3112
|
else {
|
|
2720
|
-
const allKeys = (idx.flags & ts.TypeFlags.TypeParameter && resolveTypeParam(idx)?.kind === "string") ||
|
|
3113
|
+
const allKeys = ((idx.flags & ts.TypeFlags.TypeParameter) !== 0 && resolveTypeParam(idx)?.kind === "string") ||
|
|
2721
3114
|
(idx.isIndexType() && idx.getTarget() === obj);
|
|
2722
3115
|
if (allKeys) {
|
|
2723
3116
|
covered = shape.fields.map((f) => f.type);
|
|
@@ -2798,8 +3191,8 @@ export function unitOnlyUnion(unions) {
|
|
|
2798
3191
|
* answers undefined). ONE shape per channel pair — `g.next()`'s lowering,
|
|
2799
3192
|
* `.return()`, `.throw()`, the for-of desugar, and mapType's
|
|
2800
3193
|
* IteratorResult alias mapping all intern through here, so reads agree.
|
|
2801
|
-
* Null when the combined union would be illegal (a
|
|
2802
|
-
* data arms, a
|
|
3194
|
+
* Null when the combined union would be illegal (a container arm beside
|
|
3195
|
+
* data arms, a regex/Date arm — kinds with no narrowing test here): such
|
|
2803
3196
|
* generators stay unmapped. */
|
|
2804
3197
|
export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
2805
3198
|
let valueT;
|
|
@@ -2816,7 +3209,7 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2816
3209
|
byKey.set(typeKey(a), a);
|
|
2817
3210
|
return true;
|
|
2818
3211
|
}
|
|
2819
|
-
if (t.kind === "
|
|
3212
|
+
if (t.kind === "regex" || t.kind === "date" ||
|
|
2820
3213
|
t.kind === "jsval" || t.kind === "generator") {
|
|
2821
3214
|
return false; // no legal union arm exists for these kinds
|
|
2822
3215
|
}
|
|
@@ -2827,9 +3220,9 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2827
3220
|
return null;
|
|
2828
3221
|
byKey.set(typeKey(UNDEFINED_T), UNDEFINED_T);
|
|
2829
3222
|
const arms = [...byKey.values()];
|
|
2830
|
-
//
|
|
2831
|
-
//
|
|
2832
|
-
if (arms.some((a) =>
|
|
3223
|
+
// Containers keep the shared nullable-only rule. Generator function
|
|
3224
|
+
// payloads retain their existing unit-only boundary too.
|
|
3225
|
+
if (!unionContainerArmsOk(arms) || arms.some((a) => a.kind === "func" && !arms.every((b) => b === a || isUnitType(b)))) {
|
|
2833
3226
|
return null;
|
|
2834
3227
|
}
|
|
2835
3228
|
if (arms.every(isUnitType) && arms.length < 2) {
|
|
@@ -2856,37 +3249,45 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2856
3249
|
* fields, tuple/array elements, variable slots) substitute unitOnlyUnion
|
|
2857
3250
|
* for these; RETURN positions keep the VOID mapping (a void return is not
|
|
2858
3251
|
* a value). */
|
|
2859
|
-
export function isUnitOnlyTsType(t) {
|
|
3252
|
+
export function isUnitOnlyTsType(t, resolveTypeParam) {
|
|
2860
3253
|
const UNIT = ts.TypeFlags.Undefined | ts.TypeFlags.Void | ts.TypeFlags.Null;
|
|
2861
3254
|
const parts = t.isUnionType() ? ts.constituentTypes(t) : [t];
|
|
2862
|
-
return parts.every((p) => (p.flags & UNIT) !== 0
|
|
3255
|
+
return parts.every((p) => (p.flags & UNIT) !== 0 ||
|
|
3256
|
+
((p.flags & ts.TypeFlags.TypeParameter) !== 0 && resolveTypeParam?.(p)?.kind === "void"));
|
|
2863
3257
|
}
|
|
2864
3258
|
/** IR-level `t | undefined`, canonicalized and fenced exactly like the
|
|
2865
|
-
* ts-union branch of mapType (typeKey-sorted arms, deduplicated;
|
|
2866
|
-
*
|
|
3259
|
+
* ts-union branch of mapType (typeKey-sorted arms, deduplicated;
|
|
3260
|
+
* Date/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
2867
3261
|
* result is exactly the nullable-callback shape mapType's union branch
|
|
2868
3262
|
* admits, `(() => void) | undefined`) so the interned union is IDENTICAL
|
|
2869
3263
|
* to what mapping the checker's own `T | undefined` produces. */
|
|
2870
3264
|
export function withUndefinedArm(t, unions) {
|
|
3265
|
+
return withUnitArm(t, "undefinedT", unions);
|
|
3266
|
+
}
|
|
3267
|
+
/** Preserve a nullish runtime value that JavaScript inference omitted. */
|
|
3268
|
+
export function withUnitArm(t, kind, unions) {
|
|
3269
|
+
const unit = { kind };
|
|
3270
|
+
if (t.kind === "jsval")
|
|
3271
|
+
return t;
|
|
2871
3272
|
if (t.kind === "union") {
|
|
2872
3273
|
const def = unions.get(t.unionId);
|
|
2873
3274
|
if (!def)
|
|
2874
3275
|
return null;
|
|
2875
3276
|
if (def.arms.some((a) => a.kind === "date"))
|
|
2876
3277
|
return null;
|
|
2877
|
-
if (def.arms.some((a) => a.kind ===
|
|
3278
|
+
if (def.arms.some((a) => a.kind === kind))
|
|
2878
3279
|
return t;
|
|
2879
|
-
const arms = [...def.arms,
|
|
3280
|
+
const arms = [...def.arms, unit];
|
|
2880
3281
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2881
|
-
return { kind: "union", unionId: unions.
|
|
3282
|
+
return { kind: "union", unionId: unions.transform(def, arms) };
|
|
2882
3283
|
}
|
|
2883
|
-
if (t.kind === "void" || t.kind === "
|
|
3284
|
+
if (t.kind === "void" || t.kind === "date" || t.kind === "dyn" ||
|
|
2884
3285
|
// A bare unit field type cannot occur (units live only inside unions),
|
|
2885
3286
|
// but guard against constructing a single-arm union from one.
|
|
2886
3287
|
isUnitType(t)) {
|
|
2887
3288
|
return null;
|
|
2888
3289
|
}
|
|
2889
|
-
const arms = [t,
|
|
3290
|
+
const arms = [t, unit];
|
|
2890
3291
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2891
3292
|
return { kind: "union", unionId: unions.intern(arms) };
|
|
2892
3293
|
}
|
|
@@ -3134,6 +3535,15 @@ function mapRecordType(widened, ctx) {
|
|
|
3134
3535
|
shapeId: shapes.finalizeRecursive(widened, inner.fields, inner.indexValue, inner.declaredOrder),
|
|
3135
3536
|
};
|
|
3136
3537
|
}
|
|
3538
|
+
// A record with no typed payload contract is a view of an existing
|
|
3539
|
+
// object, including across parameters and returns. Building a native
|
|
3540
|
+
// struct for it would copy a checked-dynamic object at each boundary
|
|
3541
|
+
// and sever mutation/identity. Keep the same representation as unknown;
|
|
3542
|
+
// constrained records and tuples retain their native layouts.
|
|
3543
|
+
if ((inner.fields.length > 0 || inner.indexValue !== undefined) &&
|
|
3544
|
+
inner.fields.every((field) => field.type.kind === "dyn") &&
|
|
3545
|
+
(inner.indexValue === undefined || inner.indexValue.kind === "dyn"))
|
|
3546
|
+
return DYN;
|
|
3137
3547
|
return { kind: "record", shapeId: shapes.intern(inner.fields, false, inner.indexValue, inner.declaredOrder) };
|
|
3138
3548
|
}
|
|
3139
3549
|
finally {
|
|
@@ -3401,7 +3811,7 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
3401
3811
|
// absent-field idiom — and `{ p: undefined }` spellings): the
|
|
3402
3812
|
// unit-only union. The runtime value is the interned unit, JSON
|
|
3403
3813
|
// omits the undefined arm exactly like an omitted optional.
|
|
3404
|
-
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs))
|
|
3814
|
+
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs, ctx.resolveTypeParam))
|
|
3405
3815
|
pt = unitOnlyUnion(ctx.unions);
|
|
3406
3816
|
// dyn FIELDS map now (`{ v: unknown }`, `[string, unknown]` tuples):
|
|
3407
3817
|
// the slot carries a dyn value exactly like an `unknown`-valued
|
|
@@ -3415,14 +3825,11 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
3415
3825
|
// accessor dispatch, so the shape stays unmapped.
|
|
3416
3826
|
if (accessorSlotProp(p.name) !== null)
|
|
3417
3827
|
return null;
|
|
3418
|
-
//
|
|
3419
|
-
//
|
|
3420
|
-
//
|
|
3421
|
-
//
|
|
3422
|
-
|
|
3423
|
-
// BEARING composite fields (`content: any[]`) keep their static
|
|
3424
|
-
// shape — the lift covers them.
|
|
3425
|
-
if (pt.kind === "jsval")
|
|
3828
|
+
// Keep ambient abort handles in a native record slot under --dynamic:
|
|
3829
|
+
// an options record with `signal?: AbortSignal` must not turn its
|
|
3830
|
+
// unrelated static fields into island properties. Other bare jsval
|
|
3831
|
+
// fields still absorb the record into one island object.
|
|
3832
|
+
if (pt.kind === "jsval" && !(ctx.dynamic && isAmbientAbortHandleType(fieldTs, ctx)))
|
|
3426
3833
|
return JSVAL;
|
|
3427
3834
|
fields.push({ name: p.name, type: pt });
|
|
3428
3835
|
}
|
|
@@ -3493,15 +3900,15 @@ function armHasUnionHome(arm, siblingCount) {
|
|
|
3493
3900
|
switch (arm.kind) {
|
|
3494
3901
|
case "void":
|
|
3495
3902
|
case "union":
|
|
3496
|
-
case "map":
|
|
3497
|
-
case "set":
|
|
3498
3903
|
case "regex":
|
|
3499
3904
|
case "date":
|
|
3500
3905
|
case "generator":
|
|
3501
3906
|
case "dyn":
|
|
3502
3907
|
return false;
|
|
3503
|
-
//
|
|
3504
|
-
//
|
|
3908
|
+
// Containers map only beside unit siblings; data siblings have no
|
|
3909
|
+
// supported runtime narrowing test against them.
|
|
3910
|
+
case "map":
|
|
3911
|
+
case "set":
|
|
3505
3912
|
case "promise":
|
|
3506
3913
|
return siblingCount === 0;
|
|
3507
3914
|
default:
|
|
@@ -3535,14 +3942,14 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
3535
3942
|
if (!mapped) {
|
|
3536
3943
|
return `the ${container} shape is supported, but its ${role} type '${text(arg)}' does not compile`;
|
|
3537
3944
|
}
|
|
3538
|
-
if ((container === "Map" || container === "ReadonlyMap") && i === 0 && !isSupportedMapKey(mapped)) {
|
|
3539
|
-
return `the ${container} shape is supported, but
|
|
3945
|
+
if ((container === "Map" || container === "ReadonlyMap") && i === 0 && !isSupportedMapKey(mapped, mapped.kind === "union" ? ctx.unions.get(mapped.unionId)?.arms : undefined)) {
|
|
3946
|
+
return `the ${container} shape is supported, but '${text(arg)}' is outside its supported key domain (numbers, strings, identity references, or unions of identity references)`;
|
|
3540
3947
|
}
|
|
3541
3948
|
if ((container === "Map" || container === "ReadonlyMap") && i === 1 && !isSupportedMapValue(mapped)) {
|
|
3542
|
-
return `the ${container} shape is supported, but '${text(arg)}' values have no Map slot yet
|
|
3949
|
+
return `the ${container} shape is supported, but '${text(arg)}' values have no Map slot yet`;
|
|
3543
3950
|
}
|
|
3544
|
-
if ((container === "Set" || container === "ReadonlySet") && !isSupportedSetElem(mapped)) {
|
|
3545
|
-
return `the ${container} shape is supported, but
|
|
3951
|
+
if ((container === "Set" || container === "ReadonlySet") && !isSupportedSetElem(mapped, mapped.kind === "union" ? ctx.unions.get(mapped.unionId)?.arms : undefined)) {
|
|
3952
|
+
return `the ${container} shape is supported, but '${text(arg)}' is outside its supported element domain (numbers, strings, identity references, or unions of identity references)`;
|
|
3546
3953
|
}
|
|
3547
3954
|
}
|
|
3548
3955
|
// Every argument passed the per-slot checks and the type still failed:
|
|
@@ -3568,7 +3975,7 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
3568
3975
|
if (checker.isTupleType(widened)) {
|
|
3569
3976
|
for (const arg of checker.getTypeArguments(widened)) {
|
|
3570
3977
|
const et = mapType(arg, ctx);
|
|
3571
|
-
if (et?.kind === "void" && isUnitOnlyTsType(arg))
|
|
3978
|
+
if (et?.kind === "void" && isUnitOnlyTsType(arg, ctx.resolveTypeParam))
|
|
3572
3979
|
continue;
|
|
3573
3980
|
if (!et || et.kind === "void") {
|
|
3574
3981
|
return `the tuple shape is supported, but its element type '${text(arg)}' does not compile`;
|
|
@@ -3623,7 +4030,7 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
3623
4030
|
if (sigDecl !== undefined &&
|
|
3624
4031
|
ts.isFunctionLike(sigDecl) &&
|
|
3625
4032
|
(sigDecl.parameters.length !== sig.getParameters().length ||
|
|
3626
|
-
|
|
4033
|
+
bodyReadsArguments(sigDecl))) {
|
|
3627
4034
|
return `the function shape is supported, but its signature is variadic ('arguments'-reading), and a compiled signature is fixed-arity`;
|
|
3628
4035
|
}
|
|
3629
4036
|
for (const p of sig.getParameters()) {
|
|
@@ -3682,7 +4089,7 @@ export function describeRecordMemberBlocker(widened, ctx) {
|
|
|
3682
4089
|
if (isGenericCallableMemberType(fieldTs, checker))
|
|
3683
4090
|
continue;
|
|
3684
4091
|
let pt = mapType(fieldTs, ctx);
|
|
3685
|
-
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs))
|
|
4092
|
+
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs, ctx.resolveTypeParam))
|
|
3686
4093
|
pt = unitOnlyUnion(ctx.unions);
|
|
3687
4094
|
if (!pt || pt.kind === "void") {
|
|
3688
4095
|
return `the record shape is supported, but its member '${p.name}' has type '${checker.typeToString(fieldTs)}', which does not compile`;
|