@scriptc/compiler 0.1.7 → 0.2.1
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 +98 -39
- package/ambient/scriptc-overrides.d.ts +10 -6
- package/ambient/scriptc.d.ts +15 -0
- 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 +108 -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/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 +1 -1
- package/dist/backend/link-plan.js +16 -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 +1 -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 +2 -0
- package/dist/backend/llvm/blocks.js +9 -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 +88 -30
- 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.js +2 -7
- package/dist/backend/llvm/debug-info.js.map +1 -1
- 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 +21 -2
- package/dist/backend/llvm/dyn.js +647 -251
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +596 -1
- package/dist/backend/llvm/emitter.js +769 -425
- 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 +2 -2
- package/dist/backend/llvm/expr-bytes.js +60 -31
- 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 +10 -6
- 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 +78 -81
- 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 +62 -31
- 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 +54 -7
- 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 +220 -131
- 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 +30 -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 +44 -19
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +162 -3
- 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 +42 -131
- package/dist/backend/llvm/shapes.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 +12 -30
- package/dist/backend/native-toolchain.js +83 -233
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +77 -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 +73 -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/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 +103 -34
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +72 -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 +37 -7
- 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.js +5 -10
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -4
- package/dist/executable/executable-cache.js +5 -6
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +16 -17
- 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 +1 -3
- package/dist/frontend/arguments-usage.js.map +1 -1
- 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 +74 -0
- package/dist/frontend/lowering/class-callbacks.js.map +1 -0
- package/dist/frontend/lowering/class-construction.d.ts +12 -0
- package/dist/frontend/lowering/class-construction.js +156 -0
- package/dist/frontend/lowering/class-construction.js.map +1 -0
- package/dist/frontend/lowering/class-descriptors.d.ts +10 -0
- package/dist/frontend/lowering/class-descriptors.js +114 -0
- package/dist/frontend/lowering/class-descriptors.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +51 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1158 -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 +93 -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 +67 -0
- package/dist/frontend/lowering/class-instance-constructor.js.map +1 -0
- package/dist/frontend/lowering/class-method-values.d.ts +13 -0
- package/dist/frontend/lowering/class-method-values.js +235 -0
- package/dist/frontend/lowering/class-method-values.js.map +1 -0
- package/dist/frontend/lowering/class-prototypes.d.ts +19 -0
- package/dist/frontend/lowering/class-prototypes.js +242 -0
- package/dist/frontend/lowering/class-prototypes.js.map +1 -0
- package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
- package/dist/frontend/lowering/class-runtime-statics.js +66 -0
- package/dist/frontend/lowering/class-runtime-statics.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 +208 -163
- 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 +58 -63
- 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 +14 -0
- package/dist/frontend/lowering/error-methods.js +177 -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 +51 -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 +132 -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 +509 -183
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +3 -4
- package/dist/frontend/lowering/expressions/optional-chains.js +88 -24
- 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 +101 -0
- package/dist/frontend/lowering/function-context.js +109 -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 +11 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +143 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.d.ts +4 -1
- package/dist/frontend/lowering/lib-boundary.js +112 -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 +18 -0
- package/dist/frontend/lowering/lower-builtin-values.js +249 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -0
- package/dist/frontend/lowering/lower-builtins.d.ts +33 -46
- package/dist/frontend/lowering/lower-builtins.js +676 -365
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +28 -22
- package/dist/frontend/lowering/lower-calls.js +1660 -412
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +95 -57
- package/dist/frontend/lowering/lower-classes.js +1491 -404
- 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 +36 -32
- package/dist/frontend/lowering/lower-containers.js +925 -181
- 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 +3 -2
- 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 +37 -13
- package/dist/frontend/lowering/lower-exprs.js +2163 -863
- 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 +88 -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 +7 -8
- package/dist/frontend/lowering/lower-island.js +66 -33
- 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 +445 -39
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.d.ts +1 -0
- package/dist/frontend/lowering/lower-modules.test.js +39 -0
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -0
- 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 +17 -17
- package/dist/frontend/lowering/lower-stmts.js +855 -514
- 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 +20 -11
- 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 +140 -190
- package/dist/frontend/lowering/lowerer.js +1193 -712
- 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 +172 -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 +10 -3
- package/dist/frontend/lowering/surfaces.js +86 -37
- 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 +12 -0
- package/dist/frontend/lowering/text-decoder-encoding.js +82 -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 +121 -38
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-prune.test.js +9 -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 +39 -20
- package/dist/frontend/program.js +393 -189
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +105 -2
- package/dist/frontend/program.test.js.map +1 -1
- 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 +25 -18
- 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 +47 -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 +34 -18
- package/dist/frontend/type-mapper.js +552 -131
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.js +146 -2
- package/dist/frontend/type-mapper.test.js.map +1 -1
- 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 -198
- package/dist/index.js +369 -1572
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +16 -4
- package/dist/ir/analysis.js +23 -4
- 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 +334 -176
- package/dist/ir/ir.js +710 -903
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +162 -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 +33 -14
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.d.ts +1 -0
- package/dist/ir/serialize.test.js +57 -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 +2018 -1498
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +536 -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/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 +137 -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 +94 -0
- package/dist/native/toolchain.js.map +1 -0
- package/dist/native/toolchain.test.d.ts +1 -0
- package/dist/native/toolchain.test.js +85 -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 +107 -98
- 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 -536
- package/dist/backend/c/c-emitter.js +0 -1932
- 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 -8847
- 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 -1108
- 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 -1772
- 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,14 +1,44 @@
|
|
|
1
1
|
import { InternalCompilerError } from "../errors.js";
|
|
2
2
|
import * as ts from "./ts7/adapter.js";
|
|
3
3
|
import { bodyReadsArguments } from "./arguments-usage.js";
|
|
4
|
-
import { arrayOf, BOOL, bytesOf, canConvertToDyn, CHILD_T, CRYPTOHASH_T, CRYPTOHMAC_T, DATE_T, DYN, F64, funcOf, isSupportedArrayElem, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, JSVAL, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, setOf, STRING, SYMBOL_T, typeEquals, typeKey, UNDEFINED_T, VOID } from "../ir/ir.js";
|
|
4
|
+
import { 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";
|
|
5
5
|
import { BIGINT_T } from "../ir/ir.js";
|
|
6
|
+
import { literalValues } from "./literal-values.js";
|
|
7
|
+
import { remapUnionDiscriminant } from "./union-discriminants.js";
|
|
6
8
|
import { isJsSourceFile, isNodeTypesPath } from "./program.js";
|
|
7
|
-
import { accessorSlotProp } from "../ir/ir.js";
|
|
9
|
+
import { accessorSlotProp, recordTextCodecClass } from "../ir/ir.js";
|
|
8
10
|
// typeKey moved to ir/ir.ts (the backend needs it too, for per-type
|
|
9
11
|
// helper interning); re-exported here so frontend call sites keep their
|
|
10
12
|
// import path.
|
|
11
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
|
+
const parameter = ts.isParameter(decl) ? decl : decl.parent && ts.isParameter(decl.parent) ? decl.parent : null;
|
|
22
|
+
// Numeric array parameters in JavaScript also accept typed arrays. Keep
|
|
23
|
+
// their runtime storage at the boundary, including default [] parameters.
|
|
24
|
+
if (parameter && !parameter.dotDotDotToken && present?.length === 1 &&
|
|
25
|
+
present[0].kind === "array" && present[0].elem.kind === "f64")
|
|
26
|
+
return DYN;
|
|
27
|
+
// An unannotated JavaScript parameter's object default is a fallback,
|
|
28
|
+
// not a closed class contract. Published code routinely passes another
|
|
29
|
+
// implementation of the same protocol through a boxed callable.
|
|
30
|
+
if (parameter?.initializer && !parameter.type &&
|
|
31
|
+
present?.some((arm) => arm.kind === "object") &&
|
|
32
|
+
arms?.every((arm) => canConvertToDyn(arm, (id) => shapes.get(id), (id) => unions.get(id))))
|
|
33
|
+
return DYN;
|
|
34
|
+
if (present?.length !== 1 || present[0].kind !== "record")
|
|
35
|
+
return type;
|
|
36
|
+
const shape = shapes.get(present[0].shapeId);
|
|
37
|
+
const unitOnly = (field) => isUnitType(field) || field.kind === "void" ||
|
|
38
|
+
field.kind === "union" && unions.get(field.unionId)?.arms.every(isUnitType) === true;
|
|
39
|
+
return shape && !shape.tuple && !shape.indexValue &&
|
|
40
|
+
(shape.fields.length === 0 || shape.fields.some((field) => unitOnly(field.type))) ? DYN : type;
|
|
41
|
+
}
|
|
12
42
|
/** The ambient TYPE names of the fetch slice. Under --dynamic their
|
|
13
43
|
* values live in the embedded engine and map to island handles (jsval).
|
|
14
44
|
* Static fetch gives Response, RequestInit, AbortController/AbortSignal, response
|
|
@@ -19,6 +49,7 @@ export { typeKey };
|
|
|
19
49
|
* same names keep their ordinary structural representation. */
|
|
20
50
|
export const ISLAND_AMBIENT_TYPES = [
|
|
21
51
|
"Response",
|
|
52
|
+
"Request",
|
|
22
53
|
"ResponseInit",
|
|
23
54
|
"RequestInit",
|
|
24
55
|
"Event",
|
|
@@ -67,7 +98,7 @@ export function isParseArgsDynTypeName(name) {
|
|
|
67
98
|
return PARSE_ARGS_DYN_TYPES.has(name);
|
|
68
99
|
}
|
|
69
100
|
function priorityRank(priority) {
|
|
70
|
-
return
|
|
101
|
+
return Array.isArray(priority) ? priority : priority.rank;
|
|
71
102
|
}
|
|
72
103
|
function comparePriority(left, right) {
|
|
73
104
|
const a = priorityRank(left);
|
|
@@ -86,6 +117,8 @@ function comparePriority(left, right) {
|
|
|
86
117
|
* struct). Owned by the Lowerer; `mapType` needs it to intern the object
|
|
87
118
|
* types it encounters, which is why it is threaded through as a parameter. */
|
|
88
119
|
export class ShapeRegistry {
|
|
120
|
+
/** Existing layouts change only when a recursive placeholder closes. */
|
|
121
|
+
revision = 0;
|
|
89
122
|
byKey = new Map();
|
|
90
123
|
byId = new Map();
|
|
91
124
|
/** Historical emit-order rank of the declaration-order metadata each
|
|
@@ -245,6 +278,7 @@ export class ShapeRegistry {
|
|
|
245
278
|
shape.indexValue = indexValue;
|
|
246
279
|
this.adoptDeclaredOrder(shape, declaredOrder);
|
|
247
280
|
this.pendingRec.delete(id);
|
|
281
|
+
this.revision++;
|
|
248
282
|
const key = this.keyOf(fields, false, indexValue);
|
|
249
283
|
if (!this.byKey.has(key))
|
|
250
284
|
this.byKey.set(key, id);
|
|
@@ -294,13 +328,15 @@ export class ShapeRegistry {
|
|
|
294
328
|
}
|
|
295
329
|
}
|
|
296
330
|
/** The frontend's union interner — mirrors ShapeRegistry. A union's
|
|
297
|
-
* canonical identity
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
* the Lowerer; threaded through mapType exactly like ShapeRegistry. */
|
|
331
|
+
* canonical identity includes its typeKey-sorted arms and literal
|
|
332
|
+
* discriminator contract. An arm's index in that list IS its runtime tag.
|
|
333
|
+
* Owned by the Lowerer; threaded through mapType like ShapeRegistry. */
|
|
301
334
|
export class UnionRegistry {
|
|
335
|
+
/** Existing arm/discriminator contracts change when a placeholder closes. */
|
|
336
|
+
revision = 0;
|
|
302
337
|
byKey = new Map();
|
|
303
338
|
byId = new Map();
|
|
339
|
+
armTags = new Map();
|
|
304
340
|
/** All interned unions in first-seen (`u0`, `u1`, ...) order. */
|
|
305
341
|
unions = [];
|
|
306
342
|
/** ts.Types currently being mapped — a back-reference to one is the
|
|
@@ -343,37 +379,67 @@ export class UnionRegistry {
|
|
|
343
379
|
}
|
|
344
380
|
/** Completes a recursive placeholder with its canonical arm list and
|
|
345
381
|
* registers the structural key (first writer wins, like shapes). */
|
|
346
|
-
finalizeRecursive(t, arms) {
|
|
382
|
+
finalizeRecursive(t, arms, discriminant) {
|
|
347
383
|
const id = this.recIds.get(t);
|
|
348
384
|
if (id === undefined)
|
|
349
385
|
throw new InternalCompilerError("union registry bug: finalizeRecursive without a placeholder");
|
|
350
386
|
if (this.pendingRec.has(id)) {
|
|
351
387
|
const def = this.byId.get(id);
|
|
352
388
|
def.arms.push(...arms);
|
|
389
|
+
if (discriminant)
|
|
390
|
+
def.discriminant = discriminant;
|
|
353
391
|
this.pendingRec.delete(id);
|
|
354
|
-
|
|
392
|
+
this.armTags.delete(id);
|
|
393
|
+
this.revision++;
|
|
394
|
+
const key = JSON.stringify([arms.map(typeKey), discriminant]);
|
|
355
395
|
if (!this.byKey.has(key))
|
|
356
396
|
this.byKey.set(key, id);
|
|
357
397
|
}
|
|
358
398
|
return id;
|
|
359
399
|
}
|
|
360
|
-
/** Interns
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const key = JSON.stringify(arms.map(typeKey));
|
|
400
|
+
/** Interns canonical arms and discriminator cases, returning their unionId. */
|
|
401
|
+
intern(arms, discriminant) {
|
|
402
|
+
const key = JSON.stringify([arms.map(typeKey), discriminant]);
|
|
364
403
|
let id = this.byKey.get(key);
|
|
365
404
|
if (id === undefined) {
|
|
366
405
|
id = `u${this.unions.length}`;
|
|
367
|
-
const def = { id, arms };
|
|
406
|
+
const def = { id, arms, ...(discriminant ? { discriminant } : {}) };
|
|
368
407
|
this.byKey.set(key, id);
|
|
369
408
|
this.byId.set(id, def);
|
|
370
409
|
this.unions.push(def);
|
|
371
410
|
}
|
|
372
411
|
return id;
|
|
373
412
|
}
|
|
413
|
+
/** An exact arm transformation keeps the source's semantic variants. */
|
|
414
|
+
transform(source, arms) {
|
|
415
|
+
return this.intern(arms, remapUnionDiscriminant(source, arms));
|
|
416
|
+
}
|
|
374
417
|
get(unionId) {
|
|
375
418
|
return this.byId.get(unionId);
|
|
376
419
|
}
|
|
420
|
+
/** Index large arm lists once. Exact equality still resolves type-key
|
|
421
|
+
* collisions, including optional function ABI flags. */
|
|
422
|
+
armTag(unionId, arm) {
|
|
423
|
+
const def = this.byId.get(unionId);
|
|
424
|
+
if (!def)
|
|
425
|
+
return -1;
|
|
426
|
+
if (def.arms.length < 8)
|
|
427
|
+
return def.arms.findIndex((candidate) => typeEquals(candidate, arm));
|
|
428
|
+
let tags = this.armTags.get(unionId);
|
|
429
|
+
if (!tags) {
|
|
430
|
+
tags = new Map();
|
|
431
|
+
def.arms.forEach((candidate, tag) => {
|
|
432
|
+
const key = typeKey(candidate);
|
|
433
|
+
const previous = tags.get(key);
|
|
434
|
+
if (previous)
|
|
435
|
+
previous.push(tag);
|
|
436
|
+
else
|
|
437
|
+
tags.set(key, [tag]);
|
|
438
|
+
});
|
|
439
|
+
this.armTags.set(unionId, tags);
|
|
440
|
+
}
|
|
441
|
+
return tags.get(typeKey(arm))?.find((tag) => typeEquals(def.arms[tag], arm)) ?? -1;
|
|
442
|
+
}
|
|
377
443
|
}
|
|
378
444
|
/** Human-readable rendering of an IrType for diagnostics (records expand to
|
|
379
445
|
* their canonical field list, unions to their arms; `checker.typeToString`
|
|
@@ -442,7 +508,7 @@ export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
|
442
508
|
case "bytes":
|
|
443
509
|
// The u8 kind reads as Uint8Array (Buffer maps here too — one
|
|
444
510
|
// runtime representation; the message stays honest either way).
|
|
445
|
-
return append(t.elem
|
|
511
|
+
return append(BYTES_ELEMENT_NAME[t.elem]);
|
|
446
512
|
case "map":
|
|
447
513
|
append("Map<");
|
|
448
514
|
child(t.key);
|
|
@@ -471,6 +537,9 @@ export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
|
471
537
|
const shape = shapes.get(t.shapeId);
|
|
472
538
|
if (!shape)
|
|
473
539
|
return append(`{ /* unknown shape ${t.shapeId} */ }`);
|
|
540
|
+
const codec = recordTextCodecClass(shape);
|
|
541
|
+
if (codec !== null)
|
|
542
|
+
return append(codec);
|
|
474
543
|
if (seen.has(t.shapeId))
|
|
475
544
|
return append("..."); // the recursive knot
|
|
476
545
|
seen.add(t.shapeId);
|
|
@@ -696,16 +765,13 @@ export function containsUnion(t) {
|
|
|
696
765
|
* sentinel; any/unknown ride dyn; undefined-only yields have no C value
|
|
697
766
|
* form (null); else the mapped type.
|
|
698
767
|
* - return: void/undefined/never carry no value (VOID — the done-value is
|
|
699
|
-
* the undefined arm); any/unknown
|
|
700
|
-
*
|
|
701
|
-
* "no modeled return value" — VOID, not dyn (a dyn return channel would
|
|
702
|
-
* force the yield channel dyn too; bodies that `return v` under a
|
|
703
|
-
* defaulted TReturn keep their fence at the return site).
|
|
768
|
+
* the undefined arm); any/unknown carry checked values. A defaulted or
|
|
769
|
+
* inferred return channel can still return a value and must preserve it.
|
|
704
770
|
* - next: void/undefined/never mean valueless resumes (the undefined
|
|
705
771
|
* unit); any/unknown ride dyn; else the mapped type (`.next(v)` then
|
|
706
772
|
* requires its argument — fenced at the call site).
|
|
707
|
-
* Mixed dyn/concrete value channels
|
|
708
|
-
* record's value slot
|
|
773
|
+
* Mixed dyn/concrete value channels both use checked values because the
|
|
774
|
+
* shared result record's value slot has one representation. */
|
|
709
775
|
function genChannels(yieldTs, retTs, nextTs, ctx) {
|
|
710
776
|
if (!yieldTs)
|
|
711
777
|
return null;
|
|
@@ -723,9 +789,9 @@ function genChannels(yieldTs, retTs, nextTs, ctx) {
|
|
|
723
789
|
}
|
|
724
790
|
if (!yieldT)
|
|
725
791
|
return null;
|
|
726
|
-
const retT = retTs === undefined || retTs.flags &
|
|
792
|
+
const retT = retTs === undefined || retTs.flags & UNITISH
|
|
727
793
|
? VOID
|
|
728
|
-
: mapType(retTs, ctx);
|
|
794
|
+
: retTs.flags & ANYISH ? DYN : mapType(retTs, ctx);
|
|
729
795
|
if (!retT || (retT.kind !== "void" && isUnitType(retT)))
|
|
730
796
|
return null;
|
|
731
797
|
const nextT = nextTs === undefined || nextTs.flags & UNITISH
|
|
@@ -736,7 +802,7 @@ function genChannels(yieldTs, retTs, nextTs, ctx) {
|
|
|
736
802
|
const dynMix = (yieldT.kind === "dyn" && retT.kind !== "dyn" && retT.kind !== "void") ||
|
|
737
803
|
(retT.kind === "dyn" && yieldT.kind !== "dyn" && yieldT.kind !== "void");
|
|
738
804
|
if (dynMix)
|
|
739
|
-
return
|
|
805
|
+
return { yieldT: DYN, retT: DYN, nextT };
|
|
740
806
|
return { yieldT, retT, nextT };
|
|
741
807
|
}
|
|
742
808
|
/** SELF-REFERENTIAL types recurse through mapType with no structural floor:
|
|
@@ -788,16 +854,10 @@ export function mapType(type, ctx) {
|
|
|
788
854
|
mapTypeDepth--;
|
|
789
855
|
}
|
|
790
856
|
}
|
|
791
|
-
/**
|
|
792
|
-
*
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
* naming a struct that will never be emitted is the invalid-C escape
|
|
796
|
-
* family (every SITE using the value already carries its own fence). */
|
|
797
|
-
function classExprNeverRegisters(decl) {
|
|
798
|
-
if (!ts.isClassExpression(decl))
|
|
799
|
-
return false;
|
|
800
|
-
for (let p = decl.parent; !ts.isSourceFile(p); p = p.parent) {
|
|
857
|
+
/** Local class types need the enclosing specialization's registered layout.
|
|
858
|
+
* Static-block classes are sent through the same hook for an explicit fence. */
|
|
859
|
+
function classExprNeedsContext(decl) {
|
|
860
|
+
for (let p = decl.parent; p !== undefined && !ts.isSourceFile(p); p = p.parent) {
|
|
801
861
|
if (ts.isFunctionLike(p) || ts.isClassStaticBlockDeclaration(p))
|
|
802
862
|
return true;
|
|
803
863
|
}
|
|
@@ -805,6 +865,11 @@ function classExprNeverRegisters(decl) {
|
|
|
805
865
|
}
|
|
806
866
|
function mapTypeInner(type, ctx) {
|
|
807
867
|
const { checker, unions, classNamer, resolveTypeParam } = ctx;
|
|
868
|
+
// TypeScript's intrinsic globalThis symbol has no declaration. A stored
|
|
869
|
+
// reference needs native object identity, including var's undefined state.
|
|
870
|
+
const intrinsic = type.getSymbol();
|
|
871
|
+
if (!ctx.dynamic && intrinsic?.name === "globalThis" && checker.declarationsOf(intrinsic).length === 0)
|
|
872
|
+
return DYN;
|
|
808
873
|
if (!ctx.dynamic) {
|
|
809
874
|
const moduleId = ctx.moduleNamespaceId?.(type) ?? null;
|
|
810
875
|
if (moduleId !== null)
|
|
@@ -866,6 +931,15 @@ function mapTypeInner(type, ctx) {
|
|
|
866
931
|
return STRING;
|
|
867
932
|
if (flags & ts.TypeFlags.Boolean || flags & ts.TypeFlags.BooleanLiteral)
|
|
868
933
|
return BOOL;
|
|
934
|
+
// ErrorOptions carries a presence-sensitive unknown value. A fixed
|
|
935
|
+
// optional field cannot distinguish {} from { cause: undefined }; the
|
|
936
|
+
// checked-dynamic object retains that distinction through forwarding
|
|
937
|
+
// constructors. Only the standard library's interface gets this ABI.
|
|
938
|
+
const errorOptionsSymbol = widened.getSymbol();
|
|
939
|
+
if (errorOptionsSymbol?.name === "ErrorOptions" &&
|
|
940
|
+
checker.declarationsOf(errorOptionsSymbol).some((d) => ctx.isStdlibFile(d.getSourceFile()))) {
|
|
941
|
+
return DYN;
|
|
942
|
+
}
|
|
869
943
|
// node:util.parseArgs config/results are declaration-heavy conditional
|
|
870
944
|
// and discriminated-union types over a value that is naturally a checked-
|
|
871
945
|
// dynamic tree. Keep the named public surface (plus @types/node's private
|
|
@@ -876,12 +950,29 @@ function mapTypeInner(type, ctx) {
|
|
|
876
950
|
// user aliases with the same names on the normal structural path.
|
|
877
951
|
{
|
|
878
952
|
const parseArgsSym = widened.getAliasSymbol() ?? widened.getSymbol();
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
953
|
+
const belongs = (declaration) => {
|
|
954
|
+
if (!ctx.isStdlibFile(declaration.getSourceFile()))
|
|
955
|
+
return false;
|
|
956
|
+
let family = false;
|
|
957
|
+
for (let node = declaration; node; node = node.parent) {
|
|
958
|
+
if ((ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node)) &&
|
|
959
|
+
PARSE_ARGS_DYN_TYPES.has(node.name.text))
|
|
960
|
+
family = true;
|
|
961
|
+
if (ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name)) {
|
|
962
|
+
return family && (node.name.text === "util" || node.name.text === "node:util");
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return false;
|
|
966
|
+
};
|
|
967
|
+
if (parseArgsSym && PARSE_ARGS_DYN_TYPES.has(parseArgsSym.name) &&
|
|
968
|
+
checker.declarationsOf(parseArgsSym).some(belongs))
|
|
969
|
+
return DYN;
|
|
970
|
+
// ReturnType and instantiated conditional types can erase the alias.
|
|
971
|
+
// Require every member to retain the util declaration provenance so
|
|
972
|
+
// unrelated records with similar property names keep their own layout.
|
|
973
|
+
const members = checker.getPropertiesOfType(widened);
|
|
974
|
+
if (members.length > 0 && members.every((member) => checker.declarationsOf(member).some(belongs)))
|
|
883
975
|
return DYN;
|
|
884
|
-
}
|
|
885
976
|
}
|
|
886
977
|
// The lib's BOXED wrapper interfaces used as TYPES (`const n: Number =
|
|
887
978
|
// 5`): every value such a slot can hold IS the primitive — `new
|
|
@@ -933,6 +1024,21 @@ function mapTypeInner(type, ctx) {
|
|
|
933
1024
|
// position knows it wants a value; this mapping cannot.
|
|
934
1025
|
if (flags & (ts.TypeFlags.Void | ts.TypeFlags.Undefined))
|
|
935
1026
|
return VOID;
|
|
1027
|
+
// Generic visitors can instantiate `T | undefined` as `void | undefined`.
|
|
1028
|
+
// It has the same return convention as standalone void; value positions
|
|
1029
|
+
// still substitute the unit-only slot through isUnitOnlyTsType below.
|
|
1030
|
+
if (widened.isUnionType() && ts.constituentTypes(widened).every((part) => {
|
|
1031
|
+
if ((part.flags & (ts.TypeFlags.Void | ts.TypeFlags.Undefined)) !== 0)
|
|
1032
|
+
return true;
|
|
1033
|
+
// A forwarding generic call keeps its caller's symbolic T in the
|
|
1034
|
+
// resolved signature. Its current instantiation can still be void.
|
|
1035
|
+
if ((part.flags & ts.TypeFlags.TypeParameter) !== 0 && resolveTypeParam?.(part)?.kind === "void") {
|
|
1036
|
+
contextResolutions++;
|
|
1037
|
+
return true;
|
|
1038
|
+
}
|
|
1039
|
+
return false;
|
|
1040
|
+
}))
|
|
1041
|
+
return VOID;
|
|
936
1042
|
// Standalone `null` (a `const x = null` binding, a `{ value: null }`
|
|
937
1043
|
// field, a `(): null` return): the unit-only union — the value is always
|
|
938
1044
|
// THE interned null instance, comparisons are tag tests, JSON serializes
|
|
@@ -1047,7 +1153,8 @@ function mapTypeInner(type, ctx) {
|
|
|
1047
1153
|
// function VALUE is one ScrClosure for its whole life — top-level
|
|
1048
1154
|
// declarations intern one immortal closure, and inner closures are
|
|
1049
1155
|
// allocated once at their definition's evaluation and flow by
|
|
1050
|
-
// reference, exactly JS's function identity.
|
|
1156
|
+
// reference, exactly JS's function identity. Maps and Sets use their
|
|
1157
|
+
// typed RC/trace adapters; RegExp values use immutable REF storage. URL and
|
|
1051
1158
|
// Date (scalar-backed but identity-bearing in JS) and the other opaque
|
|
1052
1159
|
// handles stay unsupported as array elements; ordinary Date locals,
|
|
1053
1160
|
// params, fixed record/tuple fields, and promise payloads are supported.
|
|
@@ -1059,7 +1166,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1059
1166
|
// `undefined[]` (sparse literals — `[,]` — and explicit annotations):
|
|
1060
1167
|
// the element rides the unit-only union like a record field would; the
|
|
1061
1168
|
// VOID mapping is a return-position artifact, not a value.
|
|
1062
|
-
if (elem?.kind === "void" && isUnitOnlyTsType(elemTs))
|
|
1169
|
+
if (elem?.kind === "void" && isUnitOnlyTsType(elemTs, ctx.resolveTypeParam))
|
|
1063
1170
|
elem = unitOnlyUnion(unions);
|
|
1064
1171
|
// A jsval element ABSORBS the array — with one carve-out. An array
|
|
1065
1172
|
// type entangled with package-declared ('npm-jsval') elements
|
|
@@ -1077,15 +1184,15 @@ function mapTypeInner(type, ctx) {
|
|
|
1077
1184
|
// A dyn ELEMENT makes the WHOLE array the checked-dynamic value:
|
|
1078
1185
|
// `unknown[]`, `object[]`, and the collapsed `(string | object)[]`
|
|
1079
1186
|
// (the plugins-slot shape) — the checked-dynamic tree has real arrays, so length/
|
|
1080
|
-
// index/push/iteration ride the keyed-dyn paths
|
|
1081
|
-
//
|
|
1082
|
-
//
|
|
1187
|
+
// index/push/iteration ride the keyed-dyn paths. Native dyn-element
|
|
1188
|
+
// vectors are reserved for collection seeds and drains, rather than
|
|
1189
|
+
// changing this public representation. This is dynFallbackType's JS stance promoted into
|
|
1083
1190
|
// the mapping itself; construction sites build dynArrLit (the checked-dynamic tree
|
|
1084
1191
|
// array literal) and typed sources convert per element at the slot.
|
|
1085
1192
|
if (elem.kind === "dyn")
|
|
1086
1193
|
return DYN;
|
|
1087
1194
|
// The shared predicate is the runtime/backend storage contract. In
|
|
1088
|
-
// particular, valid standalone values such as
|
|
1195
|
+
// particular, valid standalone values such as Date and opaque
|
|
1089
1196
|
// handles do not automatically have an array element representation.
|
|
1090
1197
|
if (!isSupportedArrayElem(elem))
|
|
1091
1198
|
return null;
|
|
@@ -1139,10 +1246,10 @@ function mapTypeInner(type, ctx) {
|
|
|
1139
1246
|
}
|
|
1140
1247
|
const fields = [];
|
|
1141
1248
|
for (let i = 0; i < args.length; i++) {
|
|
1142
|
-
let et = mapType(args[i], ctx);
|
|
1249
|
+
let et = !ctx.dynamic && (args[i].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[i], ctx);
|
|
1143
1250
|
// A unit-only element (`[number, undefined]`) rides the unit-only
|
|
1144
1251
|
// union, the record-field rule.
|
|
1145
|
-
if (et?.kind === "void" && isUnitOnlyTsType(args[i]))
|
|
1252
|
+
if (et?.kind === "void" && isUnitOnlyTsType(args[i], ctx.resolveTypeParam))
|
|
1146
1253
|
et = unitOnlyUnion(unions);
|
|
1147
1254
|
// dyn ELEMENTS map now — `[string, unknown]`, the Object.entries
|
|
1148
1255
|
// tuple over an `unknown`-valued index signature (the pricing-table
|
|
@@ -1170,8 +1277,6 @@ function mapTypeInner(type, ctx) {
|
|
|
1170
1277
|
if (brandedPrimitive)
|
|
1171
1278
|
return brandedPrimitive;
|
|
1172
1279
|
}
|
|
1173
|
-
// Class instances: the type's symbol is a class declared in the user's
|
|
1174
|
-
// file. The class NAME as a value has the *constructor* type — same
|
|
1175
1280
|
// REFINED handle intersections — @types/node's idioms: `ServerResponse<
|
|
1176
1281
|
// IncomingMessage> & { req: IncomingMessage }` (RequestListener's
|
|
1177
1282
|
// inferred res param — every unannotated http.createServer handler) and
|
|
@@ -1223,8 +1328,11 @@ function mapTypeInner(type, ctx) {
|
|
|
1223
1328
|
}
|
|
1224
1329
|
}
|
|
1225
1330
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1331
|
+
const classView = mapClassView(widened, ctx);
|
|
1332
|
+
if (classView !== undefined)
|
|
1333
|
+
return classView;
|
|
1334
|
+
// Class instances name a program class. The same symbol with construct
|
|
1335
|
+
// signatures names its static side, mapped to classval below.
|
|
1228
1336
|
const widenedSym = widened.getSymbol();
|
|
1229
1337
|
const classDecl = widenedSym ? checker.valueDeclarationOf(widenedSym) : undefined;
|
|
1230
1338
|
if (classDecl &&
|
|
@@ -1251,17 +1359,17 @@ function mapTypeInner(type, ctx) {
|
|
|
1251
1359
|
return viaMixin;
|
|
1252
1360
|
}
|
|
1253
1361
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1362
|
+
if (classExprNeedsContext(classDecl)) {
|
|
1363
|
+
const local = ctx.localClassInstance?.(classDecl);
|
|
1364
|
+
if (local)
|
|
1365
|
+
contextResolutions++;
|
|
1366
|
+
return local ?? null;
|
|
1367
|
+
}
|
|
1258
1368
|
// A GENERIC class's instance type (`Box<number>`) maps to the concrete
|
|
1259
1369
|
// INSTANTIATION's class (`Box%0`), registered on demand — the Lowerer
|
|
1260
1370
|
// hook owns the instance table (monomorphization by flow).
|
|
1261
1371
|
if (classDecl.typeParameters) {
|
|
1262
|
-
const instance = ctx.genericClassInstance
|
|
1263
|
-
? ctx.genericClassInstance(classDecl, widened)
|
|
1264
|
-
: null;
|
|
1372
|
+
const instance = ctx.genericClassInstance?.(classDecl, widened, (argument) => mapType(argument, ctx)) ?? null;
|
|
1265
1373
|
// Before the generic declaration's collection turn, the hook can only
|
|
1266
1374
|
// return its family shell; after collection the same checker type names
|
|
1267
1375
|
// a concrete registered instance. Never memoize either phase's answer.
|
|
@@ -1289,8 +1397,14 @@ function mapTypeInner(type, ctx) {
|
|
|
1289
1397
|
return { kind: "classval", className: viaMixin.className };
|
|
1290
1398
|
}
|
|
1291
1399
|
}
|
|
1292
|
-
if (
|
|
1400
|
+
if (classExprNeedsContext(classDecl)) {
|
|
1401
|
+
const local = ctx.localClassInstance?.(classDecl);
|
|
1402
|
+
if (local?.kind === "object") {
|
|
1403
|
+
contextResolutions++;
|
|
1404
|
+
return { kind: "classval", className: local.className };
|
|
1405
|
+
}
|
|
1293
1406
|
return null;
|
|
1407
|
+
}
|
|
1294
1408
|
// A GENERIC class's static side: only an INSTANTIATED one maps — an
|
|
1295
1409
|
// instantiation expression's type (`Box<number>` as a value) carries a
|
|
1296
1410
|
// construct signature returning the concrete instance, which maps to
|
|
@@ -1335,8 +1449,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1335
1449
|
const psym = widened.getSymbol();
|
|
1336
1450
|
const isStdlibInterface = (name) => psym?.name === name &&
|
|
1337
1451
|
checker.declarationsOf(psym).some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(d.getSourceFile()));
|
|
1338
|
-
// The builtin Error classes: references to the
|
|
1339
|
-
// RangeError/SyntaxError interfaces map to the runtime-provided class
|
|
1452
|
+
// The builtin Error classes: references to the lib's Error interfaces map to the runtime-provided class
|
|
1340
1453
|
// hierarchy (provenance, not the name — a user's own `class Error`
|
|
1341
1454
|
// resolved through the class-instance branch above, and a user
|
|
1342
1455
|
// `interface Error` maps as a record). The '%'-prefixed IR names are the
|
|
@@ -1421,6 +1534,15 @@ function mapTypeInner(type, ctx) {
|
|
|
1421
1534
|
isDeclaredInAmbientModule(d, "diagnostics_channel"))) {
|
|
1422
1535
|
return F64;
|
|
1423
1536
|
}
|
|
1537
|
+
// WHATWG codec instances have ordinary reference identity and ownership.
|
|
1538
|
+
// Their private encoding slot is omitted from enumeration and JSON.
|
|
1539
|
+
if ((psym?.name === "TextEncoder" || psym?.name === "TextDecoder") &&
|
|
1540
|
+
checker.declarationsOf(psym).some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) && ctx.isStdlibFile(d.getSourceFile()))) {
|
|
1541
|
+
return {
|
|
1542
|
+
kind: "record",
|
|
1543
|
+
shapeId: ctx.shapes.intern([{ name: `%${psym.name}`, type: F64 }, ...(psym.name === "TextDecoder" ? [{ name: "%fatal", type: BOOL }, { name: "%ignoreBOM", type: BOOL }, { name: "%state", type: DYN }] : [])], false, undefined, []),
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1424
1546
|
// string_decoder.StringDecoder: the decoder value is a two-field record
|
|
1425
1547
|
// — the CANONICAL encoding name (construction normalizes aliases; the
|
|
1426
1548
|
// `.encoding` property reads it) and the f64 packing the pending
|
|
@@ -1449,9 +1571,10 @@ function mapTypeInner(type, ctx) {
|
|
|
1449
1571
|
// record-holding binding forms compile. User-declared literals with
|
|
1450
1572
|
// these member names keep the ordinary record path (their declarations
|
|
1451
1573
|
// are not in declaration files).
|
|
1574
|
+
const promiseDeclarations = psym ? checker.declarationsOf(psym) : [];
|
|
1452
1575
|
if (flags & ts.TypeFlags.Object &&
|
|
1453
|
-
|
|
1454
|
-
|
|
1576
|
+
promiseDeclarations.length > 0 &&
|
|
1577
|
+
promiseDeclarations.every((d) => d.getSourceFile().isDeclarationFile)) {
|
|
1455
1578
|
const props = checker.getPropertiesOfType(widened);
|
|
1456
1579
|
if (props.length === 3 &&
|
|
1457
1580
|
["promise", "resolve", "reject"].every((n) => props.some((p) => p.name === n))) {
|
|
@@ -1484,6 +1607,10 @@ function mapTypeInner(type, ctx) {
|
|
|
1484
1607
|
// read has its own lowering (errno/syscall/path stay per-member fences).
|
|
1485
1608
|
if (isStdlibInterface("ErrnoException"))
|
|
1486
1609
|
return { kind: "object", className: "%Error" };
|
|
1610
|
+
// spawn consumes a presence-sensitive option bag, including optional
|
|
1611
|
+
// stdio and env values. Keep it checked-dynamic for native normalization.
|
|
1612
|
+
if (isStdlibInterface("SpawnOptions"))
|
|
1613
|
+
return DYN;
|
|
1487
1614
|
// The fetch ambient slice: under --dynamic these are island handles
|
|
1488
1615
|
// exactly like npm-declared types. Static fetch has one deliberately
|
|
1489
1616
|
// narrower native representation: Response is an opaque checked-
|
|
@@ -1544,26 +1671,33 @@ function mapTypeInner(type, ctx) {
|
|
|
1544
1671
|
const args = checker.getTypeArguments(widened);
|
|
1545
1672
|
if (args.length !== 2)
|
|
1546
1673
|
return null;
|
|
1547
|
-
const key = mapType(args[0], ctx);
|
|
1548
|
-
if (!key || !isSupportedMapKey(key))
|
|
1674
|
+
const key = !ctx.dynamic && (args[0].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[0], ctx);
|
|
1675
|
+
if (!key || !isSupportedMapKey(key, key.kind === "union" ? ctx.unions.get(key.unionId)?.arms : undefined))
|
|
1549
1676
|
return null;
|
|
1550
|
-
const value = mapType(args[1], ctx);
|
|
1677
|
+
const value = !ctx.dynamic && (args[1].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[1], ctx);
|
|
1551
1678
|
if (!value || !isSupportedMapValue(value))
|
|
1552
1679
|
return null;
|
|
1553
1680
|
return mapOf(key, value);
|
|
1554
1681
|
}
|
|
1555
|
-
//
|
|
1556
|
-
//
|
|
1682
|
+
// Native WeakMap keeps reference identities in checked-dynamic storage.
|
|
1683
|
+
// The runtime rejects reference kinds without a weak lifetime contract.
|
|
1684
|
+
if (isStdlibInterface("WeakMap") || isStdlibInterface("WeakSet"))
|
|
1685
|
+
return ctx.dynamic ? JSVAL : DYN;
|
|
1686
|
+
// Set<T>: Map's sibling — same provenance rule and key domain.
|
|
1687
|
+
// Anything else stays unmapped;
|
|
1557
1688
|
// the `new Set` lowering names the offending element type specifically.
|
|
1558
1689
|
if (isStdlibInterface("Set") || isStdlibInterface("ReadonlySet")) {
|
|
1559
1690
|
const args = checker.getTypeArguments(widened);
|
|
1560
1691
|
if (args.length !== 1)
|
|
1561
1692
|
return null;
|
|
1562
|
-
const elem = mapType(args[0], ctx);
|
|
1563
|
-
if (!elem || !isSupportedSetElem(elem))
|
|
1693
|
+
const elem = !ctx.dynamic && (args[0].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[0], ctx);
|
|
1694
|
+
if (!elem || !isSupportedSetElem(elem, elem.kind === "union" ? ctx.unions.get(elem.unionId)?.arms : undefined))
|
|
1564
1695
|
return null;
|
|
1565
1696
|
return setOf(elem);
|
|
1566
1697
|
}
|
|
1698
|
+
const collectionView = mapCollectionView(widened, ctx);
|
|
1699
|
+
if (collectionView)
|
|
1700
|
+
return collectionView;
|
|
1567
1701
|
// Date: a TimeClip'd epoch-millisecond scalar in the static runtime.
|
|
1568
1702
|
// This supports stored/passed values and the read-only getter slice;
|
|
1569
1703
|
// identity and mutation stay fenced because the scalar deliberately
|
|
@@ -1577,6 +1711,8 @@ function mapTypeInner(type, ctx) {
|
|
|
1577
1711
|
if (isStdlibInterface("RegExp")) {
|
|
1578
1712
|
return { kind: "regex" };
|
|
1579
1713
|
}
|
|
1714
|
+
if (isStdlibInterface("Segmenter") || isStdlibInterface("Segments") || isStdlibInterface("SegmentData"))
|
|
1715
|
+
return DYN;
|
|
1580
1716
|
// Typed arrays: references to the lib's Uint8Array/Uint32Array/
|
|
1581
1717
|
// Float32Array/Float64Array interfaces (provenance, not names). The es2022+ lib
|
|
1582
1718
|
// declares them generic over the backing buffer (`Uint8Array<ArrayBuffer>`
|
|
@@ -1616,10 +1752,22 @@ function mapTypeInner(type, ctx) {
|
|
|
1616
1752
|
// space, so clearTimeout of an Immediate no-ops like Node.
|
|
1617
1753
|
if (isStdlibInterface("Immediate"))
|
|
1618
1754
|
return F64;
|
|
1755
|
+
if (isStdlibInterface("ArrayBuffer") || isStdlibInterface("PropertyDescriptor") || isStdlibInterface("ProcessVersions"))
|
|
1756
|
+
return DYN;
|
|
1757
|
+
if (Object.values(BYTES_ELEMENT_NAME).some((name) => isStdlibInterface(`${name}Constructor`)))
|
|
1758
|
+
return DYN;
|
|
1619
1759
|
if (isStdlibInterface("Uint8Array"))
|
|
1620
1760
|
return bytesOf("u8");
|
|
1621
1761
|
if (isStdlibInterface("Uint32Array"))
|
|
1622
1762
|
return bytesOf("u32");
|
|
1763
|
+
if (isStdlibInterface("Uint8ClampedArray"))
|
|
1764
|
+
return bytesOf("u8c");
|
|
1765
|
+
if (isStdlibInterface("Int8Array"))
|
|
1766
|
+
return bytesOf("i8");
|
|
1767
|
+
if (isStdlibInterface("Uint16Array"))
|
|
1768
|
+
return bytesOf("u16");
|
|
1769
|
+
if (isStdlibInterface("Int16Array"))
|
|
1770
|
+
return bytesOf("i16");
|
|
1623
1771
|
// Int32Array: the signed 32-bit kind (element reads sign-extend, writes
|
|
1624
1772
|
// ToInt32-wrap) — the Atomics.wait sleep idiom constructs one over a
|
|
1625
1773
|
// SharedArrayBuffer, and the i32 semantics hold for every other use.
|
|
@@ -1956,6 +2104,9 @@ function mapTypeInner(type, ctx) {
|
|
|
1956
2104
|
return null;
|
|
1957
2105
|
return { kind: "promise", inner };
|
|
1958
2106
|
}
|
|
2107
|
+
// Native collection iterators use checked runtime iterator objects.
|
|
2108
|
+
if (isStdlibInterface("MapIterator") || isStdlibInterface("SetIterator"))
|
|
2109
|
+
return DYN;
|
|
1959
2110
|
// Generator<T, TReturn, TNext>, AsyncGenerator<T, TReturn, TNext> (and
|
|
1960
2111
|
// the lib's IterableIterator<T, ...>, the older sync annotation spelling):
|
|
1961
2112
|
// the generator kind. Channel normalization keeps the runtime honest:
|
|
@@ -1972,8 +2123,8 @@ function mapTypeInner(type, ctx) {
|
|
|
1972
2123
|
// boxes; the yield expression reads checked-dynamic);
|
|
1973
2124
|
// else the mapped type (`.next(v)` requires its
|
|
1974
2125
|
// argument — fenced at the call).
|
|
1975
|
-
// Mixed dyn/concrete channels
|
|
1976
|
-
//
|
|
2126
|
+
// Mixed dyn/concrete value channels share checked storage, so either
|
|
2127
|
+
// branch of the result record has the same representation.
|
|
1977
2128
|
if (isStdlibInterface("Generator") || isStdlibInterface("AsyncGenerator") || isStdlibInterface("IterableIterator")) {
|
|
1978
2129
|
const args = checker.getTypeArguments(widened);
|
|
1979
2130
|
const channels = genChannels(args[0], args[1], args[2], ctx);
|
|
@@ -2273,6 +2424,11 @@ function mapTypeInner(type, ctx) {
|
|
|
2273
2424
|
const hybrid = mapHybridCallableIntersection(widened, ctx);
|
|
2274
2425
|
if (hybrid)
|
|
2275
2426
|
return hybrid;
|
|
2427
|
+
// Recursive and Symbol-keyed callable objects need their complete live
|
|
2428
|
+
// property table; dropping those members into a plain closure loses data.
|
|
2429
|
+
if (!ctx.dynamic && checker.getCallSignatures(widened).length > 0 &&
|
|
2430
|
+
checker.getPropertiesOfType(widened).length > 0)
|
|
2431
|
+
return DYN;
|
|
2276
2432
|
}
|
|
2277
2433
|
const callSigs = checker.getCallSignatures(widened);
|
|
2278
2434
|
if (callSigs.length === 1) {
|
|
@@ -2313,10 +2469,18 @@ function mapTypeInner(type, ctx) {
|
|
|
2313
2469
|
ts.isParameter(decl) &&
|
|
2314
2470
|
(decl.questionToken !== undefined || decl.initializer !== undefined);
|
|
2315
2471
|
let pt = mapType(checker.getTypeOfSymbol(p), ctx);
|
|
2472
|
+
// An inferred JavaScript binding pattern consumes an iterable; it
|
|
2473
|
+
// does not require the caller's array to have exactly this length.
|
|
2474
|
+
if (decl && ts.isParameter(decl) && ts.isArrayBindingPattern(decl.name) &&
|
|
2475
|
+
isJsSourceFile(decl.getSourceFile()) && !decl.type &&
|
|
2476
|
+
!/@(?:param|type)\b/.test(decl.getSourceFile().text.slice(decl.parent?.pos ?? decl.pos, decl.getStart())))
|
|
2477
|
+
pt = DYN;
|
|
2478
|
+
if (pt)
|
|
2479
|
+
pt = jsOpenObjectType(decl, pt, ctx.shapes, ctx.unions);
|
|
2316
2480
|
// Belt and braces for non-strict type worlds: an optional param's
|
|
2317
2481
|
// ABI slot is always the undefined-armed union (strictNullChecks
|
|
2318
2482
|
// already spells it that way; arm it here if the world didn't).
|
|
2319
|
-
if (optional && pt && pt.kind !== "void" && pt.kind !== "jsval") {
|
|
2483
|
+
if (optional && pt && pt.kind !== "void" && pt.kind !== "jsval" && pt.kind !== "dyn") {
|
|
2320
2484
|
const armed = withUndefinedArm(pt, ctx.unions);
|
|
2321
2485
|
if (!armed)
|
|
2322
2486
|
return null;
|
|
@@ -2338,8 +2502,16 @@ function mapTypeInner(type, ctx) {
|
|
|
2338
2502
|
const retT = checker.getReturnTypeOfSignature(sig);
|
|
2339
2503
|
// `() => never` (a throw-only lambda's inferred type) is assignable to
|
|
2340
2504
|
// `() => void` and its calls never produce a value — map the return
|
|
2341
|
-
// like declaredReturnType does for declarations.
|
|
2342
|
-
|
|
2505
|
+
// like declaredReturnType does for declarations. JS null/undefined
|
|
2506
|
+
// returns can read mutable fields, so callable values use the same
|
|
2507
|
+
// checked-native return ABI as their implementations.
|
|
2508
|
+
const sigDecl = checker.signatureDeclaration(sig);
|
|
2509
|
+
const jsUnitReturn = sigDecl !== undefined && isJsSourceFile(sigDecl.getSourceFile()) &&
|
|
2510
|
+
(retT.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) !== 0;
|
|
2511
|
+
let ret = jsUnitReturn || (!ctx.dynamic && (retT.flags & ts.TypeFlags.Any) !== 0)
|
|
2512
|
+
? DYN : retT.flags & ts.TypeFlags.Never ? VOID : mapType(retT, ctx);
|
|
2513
|
+
if (sigDecl && isJsSourceFile(sigDecl.getSourceFile()) && ret?.kind === "array" && ret.elem.kind === "f64")
|
|
2514
|
+
ret = DYN;
|
|
2343
2515
|
if (!ret)
|
|
2344
2516
|
return null;
|
|
2345
2517
|
return typedRest
|
|
@@ -2430,7 +2602,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2430
2602
|
// literal unions like `"a" | "b"` — parts that map to the SAME IR type
|
|
2431
2603
|
// collapse (deduplicated by typeKey), so a single surviving arm is just
|
|
2432
2604
|
// that type. Two or more distinct arms become a TAGGED union: the
|
|
2433
|
-
// typeKey-sorted arm list
|
|
2605
|
+
// typeKey-sorted arm list and discriminator are interned, and an arm's index
|
|
2434
2606
|
// in that list is its runtime tag. `undefined` and `null` PARTS become
|
|
2435
2607
|
// the unit arms undefinedT/nullT — strictNullChecks spells optionality
|
|
2436
2608
|
// as exactly these unions (`string | undefined`, `number | null`), and
|
|
@@ -2454,7 +2626,12 @@ function mapTypeInner(type, ctx) {
|
|
|
2454
2626
|
const sensitivityAtEntry = contextResolutions;
|
|
2455
2627
|
try {
|
|
2456
2628
|
const byKey = new Map();
|
|
2629
|
+
const recordParts = [];
|
|
2457
2630
|
for (const part of ts.constituentTypes(widened)) {
|
|
2631
|
+
// TypeScript's client can retain impossible intersections in a
|
|
2632
|
+
// distributed union. They have no inhabitants and no runtime tag.
|
|
2633
|
+
if (checker.isNeverType(part))
|
|
2634
|
+
continue;
|
|
2458
2635
|
// A `void` PART is inhabited only by undefined (`Promise<void> |
|
|
2459
2636
|
// void` return types, `string | void`): it becomes the undefinedT
|
|
2460
2637
|
// unit arm, exactly like an undefined part — the value either
|
|
@@ -2489,9 +2666,17 @@ function mapTypeInner(type, ctx) {
|
|
|
2489
2666
|
}
|
|
2490
2667
|
return null;
|
|
2491
2668
|
}
|
|
2669
|
+
if (mapped.kind === "void") {
|
|
2670
|
+
byKey.set(typeKey(UNDEFINED_T), UNDEFINED_T);
|
|
2671
|
+
continue;
|
|
2672
|
+
}
|
|
2492
2673
|
byKey.set(typeKey(mapped), mapped);
|
|
2674
|
+
if (mapped.kind === "record")
|
|
2675
|
+
recordParts.push({ source: part, mapped });
|
|
2493
2676
|
}
|
|
2494
2677
|
const arms = [...byKey.values()];
|
|
2678
|
+
if (arms.length === 0)
|
|
2679
|
+
return F64; // same unreachable placeholder as standalone never
|
|
2495
2680
|
// A single surviving UNIT arm cannot stand alone (degenerate — the
|
|
2496
2681
|
// checker collapsed everything else away); anything else single is
|
|
2497
2682
|
// just that type. A single arm UNDER A MINTED PLACEHOLDER cannot
|
|
@@ -2531,29 +2716,12 @@ function mapTypeInner(type, ctx) {
|
|
|
2531
2716
|
return DYN;
|
|
2532
2717
|
}
|
|
2533
2718
|
if (arms.some((a) => a.kind === "void" || a.kind === "union" ||
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
// arms map: `x instanceof RegExp` is their narrowing test
|
|
2537
|
-
// (the skip-utility `string | RegExp` shape), and the arm
|
|
2538
|
-
// rides the ref machinery like array regex elements.
|
|
2539
|
-
a.kind === "map" || a.kind === "set" || a.kind === "date" || a.kind === "dyn" ||
|
|
2540
|
-
// Generator arms follow the map/set rule: no narrowing test.
|
|
2541
|
-
a.kind === "generator" ||
|
|
2542
|
-
// Func arms map beside ANY sibling: `typeof x === "function"`
|
|
2543
|
-
// is the narrowing against data arms (typeofAnswer knows every
|
|
2544
|
-
// arm kind), unit TAG tests cover the nullable-callback shape
|
|
2545
|
-
// (cb !== null, cb ?? f, cb?.()), and against FUNC siblings
|
|
2546
|
-
// (`StringConstructor | NumberConstructor` — the option-table
|
|
2547
|
-
// field) closures compare by pointer identity per tag
|
|
2548
|
-
// (unionEq), so `x === String` narrows. No restriction left.
|
|
2549
|
-
// Promise arms follow the func rule (typeof gives no test
|
|
2550
|
-
// against sibling data arms): only the promise-or-absent shape
|
|
2551
|
-
// maps — `Promise<T> | undefined`, and `Promise<T> | void`
|
|
2552
|
-
// return types whose void part became the undefined arm above.
|
|
2553
|
-
(a.kind === "promise" && !arms.every((b) => b === a || isUnitType(b))))) {
|
|
2719
|
+
a.kind === "date" || a.kind === "dyn" ||
|
|
2720
|
+
a.kind === "generator") || !unionContainerArmsOk(arms)) {
|
|
2554
2721
|
return null;
|
|
2555
2722
|
}
|
|
2556
2723
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2724
|
+
const discriminant = unionDiscriminant(recordParts, arms, ctx);
|
|
2557
2725
|
if (unions.recursivePending(widened)) {
|
|
2558
2726
|
// The knot closed through this union. A frame that resolved
|
|
2559
2727
|
// through context-sensitive hooks (generic type parameters, mixin
|
|
@@ -2562,9 +2730,9 @@ function mapTypeInner(type, ctx) {
|
|
|
2562
2730
|
// recursive generic-open unions stay fenced.
|
|
2563
2731
|
if (contextResolutions !== sensitivityAtEntry)
|
|
2564
2732
|
return null;
|
|
2565
|
-
return { kind: "union", unionId: unions.finalizeRecursive(widened, arms) };
|
|
2733
|
+
return { kind: "union", unionId: unions.finalizeRecursive(widened, arms, discriminant) };
|
|
2566
2734
|
}
|
|
2567
|
-
return { kind: "union", unionId: unions.intern(arms) };
|
|
2735
|
+
return { kind: "union", unionId: unions.intern(arms, discriminant) };
|
|
2568
2736
|
}
|
|
2569
2737
|
finally {
|
|
2570
2738
|
unions.inProgress.delete(widened);
|
|
@@ -2572,6 +2740,231 @@ function mapTypeInner(type, ctx) {
|
|
|
2572
2740
|
}
|
|
2573
2741
|
return null;
|
|
2574
2742
|
}
|
|
2743
|
+
/** Retain a literal discriminator before widening erases its values. A
|
|
2744
|
+
* structural match alone is insufficient: `{ kind: "loop", body: ... }`
|
|
2745
|
+
* also fits a smaller `{ kind: "empty" }` record. Choosing that layout
|
|
2746
|
+
* makes a later switch on kind read fields outside the allocated object.
|
|
2747
|
+
*
|
|
2748
|
+
* Require one common, required data property with finite literal values.
|
|
2749
|
+
* Values may repeat within a single storage arm (several variants share a
|
|
2750
|
+
* shape), but never select different arms. Non-record arms keep their
|
|
2751
|
+
* ordinary kind checks. Types without an unambiguous discriminator retain
|
|
2752
|
+
* their structural boundary behavior. */
|
|
2753
|
+
function unionDiscriminant(parts, arms, ctx) {
|
|
2754
|
+
if (arms.filter((arm) => arm.kind === "record").length < 2 || parts.length < 2)
|
|
2755
|
+
return undefined;
|
|
2756
|
+
const { checker } = ctx;
|
|
2757
|
+
for (const candidate of checker.getPropertiesOfType(parts[0].source)) {
|
|
2758
|
+
if (candidate.name.startsWith("__@"))
|
|
2759
|
+
continue;
|
|
2760
|
+
const byTag = new Map();
|
|
2761
|
+
const owner = new Map();
|
|
2762
|
+
let complete = true;
|
|
2763
|
+
for (const part of parts) {
|
|
2764
|
+
const prop = checker.getPropertyOfType(part.source, candidate.name);
|
|
2765
|
+
if (!prop || prop.flags & (ts.SymbolFlags.Optional | ts.SymbolFlags.GetAccessor | ts.SymbolFlags.SetAccessor)) {
|
|
2766
|
+
complete = false;
|
|
2767
|
+
break;
|
|
2768
|
+
}
|
|
2769
|
+
const values = literalValues(checker.getTypeOfSymbol(prop));
|
|
2770
|
+
if (!values) {
|
|
2771
|
+
complete = false;
|
|
2772
|
+
break;
|
|
2773
|
+
}
|
|
2774
|
+
const tag = arms.findIndex((arm) => typeEquals(arm, part.mapped));
|
|
2775
|
+
const grouped = byTag.get(tag) ?? [];
|
|
2776
|
+
for (const value of values) {
|
|
2777
|
+
const key = JSON.stringify(value);
|
|
2778
|
+
const previous = owner.get(key);
|
|
2779
|
+
if (previous !== undefined && previous !== tag) {
|
|
2780
|
+
complete = false;
|
|
2781
|
+
break;
|
|
2782
|
+
}
|
|
2783
|
+
owner.set(key, tag);
|
|
2784
|
+
if (!grouped.includes(value))
|
|
2785
|
+
grouped.push(value);
|
|
2786
|
+
}
|
|
2787
|
+
if (!complete)
|
|
2788
|
+
break;
|
|
2789
|
+
byTag.set(tag, grouped);
|
|
2790
|
+
}
|
|
2791
|
+
if (complete) {
|
|
2792
|
+
return {
|
|
2793
|
+
field: candidate.name,
|
|
2794
|
+
cases: [...byTag].sort(([a], [b]) => a - b).map(([tag, values]) => ({
|
|
2795
|
+
tag, values: values.sort((a, b) => JSON.stringify(a) < JSON.stringify(b) ? -1 : JSON.stringify(a) > JSON.stringify(b) ? 1 : 0),
|
|
2796
|
+
})),
|
|
2797
|
+
};
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
return undefined;
|
|
2801
|
+
}
|
|
2802
|
+
/** A class-derived interface or intersection can refine existing members
|
|
2803
|
+
* without changing the object's layout. Keep the unique program class as
|
|
2804
|
+
* its representation; structural lookalikes without a class base do not
|
|
2805
|
+
* qualify. Construction and coercion must still supply that actual class.
|
|
2806
|
+
* Undefined means no class view, while null is a recognized but unsupported
|
|
2807
|
+
* view: do not fall through and copy an identity-bearing object to a record. */
|
|
2808
|
+
function mapClassView(type, ctx, seen = new Set()) {
|
|
2809
|
+
const { checker } = ctx;
|
|
2810
|
+
if (seen.has(type) || seen.size >= MAP_TYPE_MAX_DEPTH)
|
|
2811
|
+
return null;
|
|
2812
|
+
let bases;
|
|
2813
|
+
let viewCtx = ctx;
|
|
2814
|
+
if (type.isIntersectionType()) {
|
|
2815
|
+
bases = ts.constituentTypes(type);
|
|
2816
|
+
}
|
|
2817
|
+
else {
|
|
2818
|
+
const symbol = type.getSymbol();
|
|
2819
|
+
const declarations = symbol ? checker.declarationsOf(symbol) : [];
|
|
2820
|
+
if (declarations.length === 0 || !declarations.every((decl) => ts.isInterfaceDeclaration(decl) && !ctx.isStdlibFile(decl.getSourceFile())))
|
|
2821
|
+
return undefined;
|
|
2822
|
+
const target = type.isTypeReference() ? type.getTarget() : type;
|
|
2823
|
+
if (target === undefined || !target.isClassOrInterface())
|
|
2824
|
+
return undefined;
|
|
2825
|
+
bases = checker.getBaseTypes(target);
|
|
2826
|
+
if (type.isTypeReference() && target.isTypeReference()) {
|
|
2827
|
+
const params = checker.getTypeArguments(target);
|
|
2828
|
+
const args = checker.getTypeArguments(type);
|
|
2829
|
+
viewCtx = {
|
|
2830
|
+
...ctx,
|
|
2831
|
+
canMemoizeType: () => false,
|
|
2832
|
+
resolveTypeParam: (param) => {
|
|
2833
|
+
const index = params.indexOf(param);
|
|
2834
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2835
|
+
return arg && arg !== param ? mapType(arg, ctx) : ctx.resolveTypeParam?.(param) ?? null;
|
|
2836
|
+
},
|
|
2837
|
+
resolveTypeParamTs: (param) => {
|
|
2838
|
+
const index = params.indexOf(param);
|
|
2839
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2840
|
+
return arg && arg !== param ? ctx.resolveTypeParamTs?.(arg) ?? arg : ctx.resolveTypeParamTs?.(param) ?? null;
|
|
2841
|
+
},
|
|
2842
|
+
};
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
seen.add(type);
|
|
2846
|
+
try {
|
|
2847
|
+
let baseType;
|
|
2848
|
+
let representation;
|
|
2849
|
+
for (const base of bases) {
|
|
2850
|
+
const symbol = base.getSymbol();
|
|
2851
|
+
const declaration = symbol ? checker.valueDeclarationOf(symbol) : undefined;
|
|
2852
|
+
const classBase = declaration && (ts.isClassDeclaration(declaration) || ts.isClassExpression(declaration)) &&
|
|
2853
|
+
!declaration.getSourceFile().isDeclarationFile;
|
|
2854
|
+
const mapped = classBase ? mapType(base, viewCtx) : mapClassView(base, viewCtx, seen);
|
|
2855
|
+
if (mapped === null)
|
|
2856
|
+
return null;
|
|
2857
|
+
if (mapped === undefined)
|
|
2858
|
+
continue;
|
|
2859
|
+
if (mapped.kind !== "object" || (representation && !typeEquals(representation, mapped)))
|
|
2860
|
+
return null;
|
|
2861
|
+
baseType = base;
|
|
2862
|
+
representation = mapped;
|
|
2863
|
+
}
|
|
2864
|
+
if (!representation || !baseType)
|
|
2865
|
+
return undefined;
|
|
2866
|
+
if (checker.getCallSignatures(type).length || checker.getConstructSignatures(type).length ||
|
|
2867
|
+
checker.getIndexInfosOfType(type).length)
|
|
2868
|
+
return null;
|
|
2869
|
+
for (const property of checker.getPropertiesOfType(type)) {
|
|
2870
|
+
const original = checker.getPropertyOfType(baseType, property.name);
|
|
2871
|
+
if (!original)
|
|
2872
|
+
return null;
|
|
2873
|
+
if (original === property)
|
|
2874
|
+
continue;
|
|
2875
|
+
const originalDeclarations = checker.declarationsOf(original);
|
|
2876
|
+
const declarations = checker.declarationsOf(property);
|
|
2877
|
+
// Instantiating an inherited member can create a new symbol without
|
|
2878
|
+
// changing its declaration or ABI. Only refinements need validation.
|
|
2879
|
+
if (declarations.length > 0 && declarations.length === originalDeclarations.length &&
|
|
2880
|
+
declarations.every((declaration, index) => declaration === originalDeclarations[index]))
|
|
2881
|
+
continue;
|
|
2882
|
+
const before = checker.getTypeOfSymbol(original);
|
|
2883
|
+
const after = checker.getTypeOfSymbol(property);
|
|
2884
|
+
if (checker.getCallSignatures(before).length || checker.getCallSignatures(after).length) {
|
|
2885
|
+
const from = mapType(before, viewCtx);
|
|
2886
|
+
const to = mapType(after, viewCtx);
|
|
2887
|
+
if (!from || !to || !typeEquals(from, to))
|
|
2888
|
+
return null;
|
|
2889
|
+
}
|
|
2890
|
+
else if (!checker.isTypeAssignableTo(after, before)) {
|
|
2891
|
+
return null;
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
return representation;
|
|
2895
|
+
}
|
|
2896
|
+
finally {
|
|
2897
|
+
seen.delete(type);
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
/** Interface views of native collections may inherit their runtime surface
|
|
2901
|
+
* and refine `has` into a type predicate. Keep declaration provenance and
|
|
2902
|
+
* require the same call ABI; extra fields or replacement methods need a
|
|
2903
|
+
* different representation. Value construction/coercion still has to prove
|
|
2904
|
+
* a native Map/Set, so structural mocks cannot acquire a native handle. */
|
|
2905
|
+
function mapCollectionView(type, ctx, seen = new Set()) {
|
|
2906
|
+
if (!type.isTypeReference())
|
|
2907
|
+
return null;
|
|
2908
|
+
const { checker } = ctx;
|
|
2909
|
+
const symbol = type.getSymbol();
|
|
2910
|
+
const declarations = symbol ? checker.declarationsOf(symbol) : [];
|
|
2911
|
+
if (declarations.length === 0 || !declarations.every((decl) => ts.isInterfaceDeclaration(decl) && !ctx.isStdlibFile(decl.getSourceFile())))
|
|
2912
|
+
return null;
|
|
2913
|
+
const target = type.getTarget();
|
|
2914
|
+
if (target === undefined || !target.isClassOrInterface() || seen.has(target) || seen.size >= MAP_TYPE_MAX_DEPTH)
|
|
2915
|
+
return null;
|
|
2916
|
+
const bases = checker.getBaseTypes(target);
|
|
2917
|
+
if (bases.length !== 1)
|
|
2918
|
+
return null;
|
|
2919
|
+
if (checker.getCallSignatures(type).length || checker.getConstructSignatures(type).length ||
|
|
2920
|
+
checker.getIndexInfosOfType(type).length)
|
|
2921
|
+
return null;
|
|
2922
|
+
// Base declarations contain the interface's parameters, even when this
|
|
2923
|
+
// reference is instantiated. Resolve those through this reference before
|
|
2924
|
+
// mapping the base; never cache a template under one instantiation's ABI.
|
|
2925
|
+
const params = checker.getTypeArguments(target);
|
|
2926
|
+
const args = checker.getTypeArguments(type);
|
|
2927
|
+
const baseCtx = {
|
|
2928
|
+
...ctx,
|
|
2929
|
+
canMemoizeType: () => false,
|
|
2930
|
+
resolveTypeParam: (param) => {
|
|
2931
|
+
const index = params.indexOf(param);
|
|
2932
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2933
|
+
return arg && arg !== param ? mapType(arg, ctx) : ctx.resolveTypeParam?.(param) ?? null;
|
|
2934
|
+
},
|
|
2935
|
+
resolveTypeParamTs: (param) => {
|
|
2936
|
+
const index = params.indexOf(param);
|
|
2937
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2938
|
+
return arg && arg !== param ? ctx.resolveTypeParamTs?.(arg) ?? arg : ctx.resolveTypeParamTs?.(param) ?? null;
|
|
2939
|
+
},
|
|
2940
|
+
};
|
|
2941
|
+
seen.add(target);
|
|
2942
|
+
try {
|
|
2943
|
+
const base = bases[0];
|
|
2944
|
+
const baseSymbol = base.getSymbol();
|
|
2945
|
+
const native = baseSymbol && ["Map", "ReadonlyMap", "Set", "ReadonlySet"].includes(baseSymbol.name) &&
|
|
2946
|
+
checker.declarationsOf(baseSymbol).some((decl) => ts.isInterfaceDeclaration(decl) && ctx.isStdlibFile(decl.getSourceFile()));
|
|
2947
|
+
const mapped = native ? mapType(base, baseCtx) : mapCollectionView(base, baseCtx, seen);
|
|
2948
|
+
if (mapped?.kind !== "map" && mapped?.kind !== "set")
|
|
2949
|
+
return null;
|
|
2950
|
+
const hasType = funcOf([mapped.kind === "map" ? mapped.key : mapped.elem], BOOL);
|
|
2951
|
+
for (const property of checker.getPropertiesOfType(type)) {
|
|
2952
|
+
const own = checker.declarationsOf(property).filter((decl) => !ctx.isStdlibFile(decl.getSourceFile()));
|
|
2953
|
+
if (own.length === 0)
|
|
2954
|
+
continue;
|
|
2955
|
+
if (property.name !== "has" || (property.flags & ts.SymbolFlags.Optional) ||
|
|
2956
|
+
!own.every((decl) => decl.kind === ts.SyntaxKind.MethodSignature))
|
|
2957
|
+
return null;
|
|
2958
|
+
const method = mapType(checker.getTypeOfSymbol(property), ctx);
|
|
2959
|
+
if (!method || !typeEquals(method, hasType))
|
|
2960
|
+
return null;
|
|
2961
|
+
}
|
|
2962
|
+
return mapped;
|
|
2963
|
+
}
|
|
2964
|
+
finally {
|
|
2965
|
+
seen.delete(target);
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2575
2968
|
/** The narrowed-type-parameter recognizer behind mapType's early return:
|
|
2576
2969
|
* a union/intersection over exactly ONE type parameter whose companions
|
|
2577
2970
|
* are all `{}`-empty shapes or the null/undefined units. Returns the
|
|
@@ -2651,7 +3044,7 @@ function mapBoundIndexedAccess(type, ctx) {
|
|
|
2651
3044
|
const { checker, resolveTypeParamTs } = ctx;
|
|
2652
3045
|
if (!resolveTypeParamTs || !type.isIndexedAccessType())
|
|
2653
3046
|
return null;
|
|
2654
|
-
const resolveSide = (t) => t.flags & ts.TypeFlags.TypeParameter ? resolveTypeParamTs(t) : t;
|
|
3047
|
+
const resolveSide = (t) => t === undefined ? null : t.flags & ts.TypeFlags.TypeParameter ? resolveTypeParamTs(t) : t;
|
|
2655
3048
|
const objT = resolveSide(type.getObjectType());
|
|
2656
3049
|
const idxT = resolveSide(type.getIndexType());
|
|
2657
3050
|
if (!objT || !idxT)
|
|
@@ -2768,7 +3161,7 @@ function mapGenericIndexedAccess(type, ctx) {
|
|
|
2768
3161
|
if (!resolveTypeParam || !type.isIndexedAccessType())
|
|
2769
3162
|
return null;
|
|
2770
3163
|
const obj = type.getObjectType();
|
|
2771
|
-
if (!(obj.flags & ts.TypeFlags.TypeParameter))
|
|
3164
|
+
if (obj === undefined || !(obj.flags & ts.TypeFlags.TypeParameter))
|
|
2772
3165
|
return null;
|
|
2773
3166
|
const bound = resolveTypeParam(obj);
|
|
2774
3167
|
if (!bound || bound.kind !== "record")
|
|
@@ -2777,13 +3170,15 @@ function mapGenericIndexedAccess(type, ctx) {
|
|
|
2777
3170
|
if (!shape || shape.tuple)
|
|
2778
3171
|
return null;
|
|
2779
3172
|
const idx = type.getIndexType();
|
|
3173
|
+
if (idx === undefined)
|
|
3174
|
+
return null;
|
|
2780
3175
|
let covered = null;
|
|
2781
3176
|
if (idx.isStringLiteralType()) {
|
|
2782
3177
|
const f = shape.fields.find((x) => x.name === idx.value);
|
|
2783
3178
|
covered = f ? [f.type] : shape.indexValue ? [shape.indexValue] : null;
|
|
2784
3179
|
}
|
|
2785
3180
|
else {
|
|
2786
|
-
const allKeys = (idx.flags & ts.TypeFlags.TypeParameter && resolveTypeParam(idx)?.kind === "string") ||
|
|
3181
|
+
const allKeys = ((idx.flags & ts.TypeFlags.TypeParameter) !== 0 && resolveTypeParam(idx)?.kind === "string") ||
|
|
2787
3182
|
(idx.isIndexType() && idx.getTarget() === obj);
|
|
2788
3183
|
if (allKeys) {
|
|
2789
3184
|
covered = shape.fields.map((f) => f.type);
|
|
@@ -2864,8 +3259,8 @@ export function unitOnlyUnion(unions) {
|
|
|
2864
3259
|
* answers undefined). ONE shape per channel pair — `g.next()`'s lowering,
|
|
2865
3260
|
* `.return()`, `.throw()`, the for-of desugar, and mapType's
|
|
2866
3261
|
* IteratorResult alias mapping all intern through here, so reads agree.
|
|
2867
|
-
* Null when the combined union would be illegal (a
|
|
2868
|
-
* data arms, a
|
|
3262
|
+
* Null when the combined union would be illegal (a container arm beside
|
|
3263
|
+
* data arms, a regex/Date arm — kinds with no narrowing test here): such
|
|
2869
3264
|
* generators stay unmapped. */
|
|
2870
3265
|
export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
2871
3266
|
let valueT;
|
|
@@ -2882,7 +3277,7 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2882
3277
|
byKey.set(typeKey(a), a);
|
|
2883
3278
|
return true;
|
|
2884
3279
|
}
|
|
2885
|
-
if (t.kind === "
|
|
3280
|
+
if (t.kind === "regex" || t.kind === "date" ||
|
|
2886
3281
|
t.kind === "jsval" || t.kind === "generator") {
|
|
2887
3282
|
return false; // no legal union arm exists for these kinds
|
|
2888
3283
|
}
|
|
@@ -2893,9 +3288,9 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2893
3288
|
return null;
|
|
2894
3289
|
byKey.set(typeKey(UNDEFINED_T), UNDEFINED_T);
|
|
2895
3290
|
const arms = [...byKey.values()];
|
|
2896
|
-
//
|
|
2897
|
-
//
|
|
2898
|
-
if (arms.some((a) =>
|
|
3291
|
+
// Containers keep the shared nullable-only rule. Generator function
|
|
3292
|
+
// payloads retain their existing unit-only boundary too.
|
|
3293
|
+
if (!unionContainerArmsOk(arms) || arms.some((a) => a.kind === "func" && !arms.every((b) => b === a || isUnitType(b)))) {
|
|
2899
3294
|
return null;
|
|
2900
3295
|
}
|
|
2901
3296
|
if (arms.every(isUnitType) && arms.length < 2) {
|
|
@@ -2922,37 +3317,45 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2922
3317
|
* fields, tuple/array elements, variable slots) substitute unitOnlyUnion
|
|
2923
3318
|
* for these; RETURN positions keep the VOID mapping (a void return is not
|
|
2924
3319
|
* a value). */
|
|
2925
|
-
export function isUnitOnlyTsType(t) {
|
|
3320
|
+
export function isUnitOnlyTsType(t, resolveTypeParam) {
|
|
2926
3321
|
const UNIT = ts.TypeFlags.Undefined | ts.TypeFlags.Void | ts.TypeFlags.Null;
|
|
2927
3322
|
const parts = t.isUnionType() ? ts.constituentTypes(t) : [t];
|
|
2928
|
-
return parts.every((p) => (p.flags & UNIT) !== 0
|
|
3323
|
+
return parts.every((p) => (p.flags & UNIT) !== 0 ||
|
|
3324
|
+
((p.flags & ts.TypeFlags.TypeParameter) !== 0 && resolveTypeParam?.(p)?.kind === "void"));
|
|
2929
3325
|
}
|
|
2930
3326
|
/** IR-level `t | undefined`, canonicalized and fenced exactly like the
|
|
2931
|
-
* ts-union branch of mapType (typeKey-sorted arms, deduplicated;
|
|
2932
|
-
*
|
|
3327
|
+
* ts-union branch of mapType (typeKey-sorted arms, deduplicated;
|
|
3328
|
+
* Date/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
2933
3329
|
* result is exactly the nullable-callback shape mapType's union branch
|
|
2934
3330
|
* admits, `(() => void) | undefined`) so the interned union is IDENTICAL
|
|
2935
3331
|
* to what mapping the checker's own `T | undefined` produces. */
|
|
2936
3332
|
export function withUndefinedArm(t, unions) {
|
|
3333
|
+
return withUnitArm(t, "undefinedT", unions);
|
|
3334
|
+
}
|
|
3335
|
+
/** Preserve a nullish runtime value that JavaScript inference omitted. */
|
|
3336
|
+
export function withUnitArm(t, kind, unions) {
|
|
3337
|
+
const unit = { kind };
|
|
3338
|
+
if (t.kind === "jsval")
|
|
3339
|
+
return t;
|
|
2937
3340
|
if (t.kind === "union") {
|
|
2938
3341
|
const def = unions.get(t.unionId);
|
|
2939
3342
|
if (!def)
|
|
2940
3343
|
return null;
|
|
2941
3344
|
if (def.arms.some((a) => a.kind === "date"))
|
|
2942
3345
|
return null;
|
|
2943
|
-
if (def.arms.some((a) => a.kind ===
|
|
3346
|
+
if (def.arms.some((a) => a.kind === kind))
|
|
2944
3347
|
return t;
|
|
2945
|
-
const arms = [...def.arms,
|
|
3348
|
+
const arms = [...def.arms, unit];
|
|
2946
3349
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2947
|
-
return { kind: "union", unionId: unions.
|
|
3350
|
+
return { kind: "union", unionId: unions.transform(def, arms) };
|
|
2948
3351
|
}
|
|
2949
|
-
if (t.kind === "void" || t.kind === "
|
|
3352
|
+
if (t.kind === "void" || t.kind === "date" || t.kind === "dyn" ||
|
|
2950
3353
|
// A bare unit field type cannot occur (units live only inside unions),
|
|
2951
3354
|
// but guard against constructing a single-arm union from one.
|
|
2952
3355
|
isUnitType(t)) {
|
|
2953
3356
|
return null;
|
|
2954
3357
|
}
|
|
2955
|
-
const arms = [t,
|
|
3358
|
+
const arms = [t, unit];
|
|
2956
3359
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2957
3360
|
return { kind: "union", unionId: unions.intern(arms) };
|
|
2958
3361
|
}
|
|
@@ -3130,8 +3533,11 @@ function recordProvenanceOk(t, ctx) {
|
|
|
3130
3533
|
return true;
|
|
3131
3534
|
const tSym = t.getSymbol();
|
|
3132
3535
|
const decls = tSym ? checker.declarationsOf(tSym) : undefined;
|
|
3133
|
-
if (!decls || decls.length === 0)
|
|
3134
|
-
|
|
3536
|
+
if (!decls || decls.length === 0) {
|
|
3537
|
+
// Inferred destructuring parameters can have a synthesized anonymous
|
|
3538
|
+
// shape with no declaration or member symbols to trace to a source.
|
|
3539
|
+
return checker.getPropertiesOfType(t).every((property) => checker.declarationsOf(property).every((decl) => !decl.getSourceFile().isDeclarationFile || ctx.isExternalTypeFile(decl.getSourceFile())));
|
|
3540
|
+
}
|
|
3135
3541
|
return !decls.some((d) => {
|
|
3136
3542
|
const sf = d.getSourceFile();
|
|
3137
3543
|
return sf.isDeclarationFile && !ctx.isExternalTypeFile(sf);
|
|
@@ -3200,6 +3606,15 @@ function mapRecordType(widened, ctx) {
|
|
|
3200
3606
|
shapeId: shapes.finalizeRecursive(widened, inner.fields, inner.indexValue, inner.declaredOrder),
|
|
3201
3607
|
};
|
|
3202
3608
|
}
|
|
3609
|
+
// A record with no typed payload contract is a view of an existing
|
|
3610
|
+
// object, including across parameters and returns. Building a native
|
|
3611
|
+
// struct for it would copy a checked-dynamic object at each boundary
|
|
3612
|
+
// and sever mutation/identity. Keep the same representation as unknown;
|
|
3613
|
+
// constrained records and tuples retain their native layouts.
|
|
3614
|
+
if ((inner.fields.length > 0 || inner.indexValue !== undefined) &&
|
|
3615
|
+
inner.fields.every((field) => field.type.kind === "dyn") &&
|
|
3616
|
+
(inner.indexValue === undefined || inner.indexValue.kind === "dyn"))
|
|
3617
|
+
return DYN;
|
|
3203
3618
|
return { kind: "record", shapeId: shapes.intern(inner.fields, false, inner.indexValue, inner.declaredOrder) };
|
|
3204
3619
|
}
|
|
3205
3620
|
finally {
|
|
@@ -3343,6 +3758,10 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
3343
3758
|
const computed = widened.isIntersectionType() || isMappedShape(widened);
|
|
3344
3759
|
{
|
|
3345
3760
|
const props = checker.getPropertiesOfType(widened);
|
|
3761
|
+
// Symbol-keyed records use the checked object's descriptor table. A
|
|
3762
|
+
// checker-internal __@ name is not a string field in a native struct.
|
|
3763
|
+
if (props.some((property) => property.name.startsWith("__@")))
|
|
3764
|
+
return DYN;
|
|
3346
3765
|
// A computed shape with NO members is not a real empty record: inside a
|
|
3347
3766
|
// generic body `Partial<T>` resolves to no members at all (keyof T is
|
|
3348
3767
|
// still unknown there) — interning `{}` would be silently wrong. The
|
|
@@ -3463,11 +3882,13 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
3463
3882
|
if ((pt === null || pt.kind === "jsval") && (fieldTs.flags & ts.TypeFlags.Any) !== 0 && constAssertedEmptyArrayProp(p, ctx)) {
|
|
3464
3883
|
pt = arrayOf(unitOnlyUnion(ctx.unions));
|
|
3465
3884
|
}
|
|
3885
|
+
if (pt === null && !ctx.dynamic && (fieldTs.flags & ts.TypeFlags.Any) !== 0)
|
|
3886
|
+
pt = DYN;
|
|
3466
3887
|
// Unit-only FIELDS (`{ msg?: undefined }` — the discriminated-union
|
|
3467
3888
|
// absent-field idiom — and `{ p: undefined }` spellings): the
|
|
3468
3889
|
// unit-only union. The runtime value is the interned unit, JSON
|
|
3469
3890
|
// omits the undefined arm exactly like an omitted optional.
|
|
3470
|
-
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs))
|
|
3891
|
+
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs, ctx.resolveTypeParam))
|
|
3471
3892
|
pt = unitOnlyUnion(ctx.unions);
|
|
3472
3893
|
// dyn FIELDS map now (`{ v: unknown }`, `[string, unknown]` tuples):
|
|
3473
3894
|
// the slot carries a dyn value exactly like an `unknown`-valued
|
|
@@ -3556,15 +3977,15 @@ function armHasUnionHome(arm, siblingCount) {
|
|
|
3556
3977
|
switch (arm.kind) {
|
|
3557
3978
|
case "void":
|
|
3558
3979
|
case "union":
|
|
3559
|
-
case "map":
|
|
3560
|
-
case "set":
|
|
3561
3980
|
case "regex":
|
|
3562
3981
|
case "date":
|
|
3563
3982
|
case "generator":
|
|
3564
3983
|
case "dyn":
|
|
3565
3984
|
return false;
|
|
3566
|
-
//
|
|
3567
|
-
//
|
|
3985
|
+
// Containers map only beside unit siblings; data siblings have no
|
|
3986
|
+
// supported runtime narrowing test against them.
|
|
3987
|
+
case "map":
|
|
3988
|
+
case "set":
|
|
3568
3989
|
case "promise":
|
|
3569
3990
|
return siblingCount === 0;
|
|
3570
3991
|
default:
|
|
@@ -3598,14 +4019,14 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
3598
4019
|
if (!mapped) {
|
|
3599
4020
|
return `the ${container} shape is supported, but its ${role} type '${text(arg)}' does not compile`;
|
|
3600
4021
|
}
|
|
3601
|
-
if ((container === "Map" || container === "ReadonlyMap") && i === 0 && !isSupportedMapKey(mapped)) {
|
|
3602
|
-
return `the ${container} shape is supported, but
|
|
4022
|
+
if ((container === "Map" || container === "ReadonlyMap") && i === 0 && !isSupportedMapKey(mapped, mapped.kind === "union" ? ctx.unions.get(mapped.unionId)?.arms : undefined)) {
|
|
4023
|
+
return `the ${container} shape is supported, but '${text(arg)}' is outside its supported key domain (numbers, strings, identity references, or unions of identity references)`;
|
|
3603
4024
|
}
|
|
3604
4025
|
if ((container === "Map" || container === "ReadonlyMap") && i === 1 && !isSupportedMapValue(mapped)) {
|
|
3605
|
-
return `the ${container} shape is supported, but '${text(arg)}' values have no Map slot yet
|
|
4026
|
+
return `the ${container} shape is supported, but '${text(arg)}' values have no Map slot yet`;
|
|
3606
4027
|
}
|
|
3607
|
-
if ((container === "Set" || container === "ReadonlySet") && !isSupportedSetElem(mapped)) {
|
|
3608
|
-
return `the ${container} shape is supported, but
|
|
4028
|
+
if ((container === "Set" || container === "ReadonlySet") && !isSupportedSetElem(mapped, mapped.kind === "union" ? ctx.unions.get(mapped.unionId)?.arms : undefined)) {
|
|
4029
|
+
return `the ${container} shape is supported, but '${text(arg)}' is outside its supported element domain (numbers, strings, identity references, or unions of identity references)`;
|
|
3609
4030
|
}
|
|
3610
4031
|
}
|
|
3611
4032
|
// Every argument passed the per-slot checks and the type still failed:
|
|
@@ -3631,7 +4052,7 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
3631
4052
|
if (checker.isTupleType(widened)) {
|
|
3632
4053
|
for (const arg of checker.getTypeArguments(widened)) {
|
|
3633
4054
|
const et = mapType(arg, ctx);
|
|
3634
|
-
if (et?.kind === "void" && isUnitOnlyTsType(arg))
|
|
4055
|
+
if (et?.kind === "void" && isUnitOnlyTsType(arg, ctx.resolveTypeParam))
|
|
3635
4056
|
continue;
|
|
3636
4057
|
if (!et || et.kind === "void") {
|
|
3637
4058
|
return `the tuple shape is supported, but its element type '${text(arg)}' does not compile`;
|
|
@@ -3745,7 +4166,7 @@ export function describeRecordMemberBlocker(widened, ctx) {
|
|
|
3745
4166
|
if (isGenericCallableMemberType(fieldTs, checker))
|
|
3746
4167
|
continue;
|
|
3747
4168
|
let pt = mapType(fieldTs, ctx);
|
|
3748
|
-
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs))
|
|
4169
|
+
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs, ctx.resolveTypeParam))
|
|
3749
4170
|
pt = unitOnlyUnion(ctx.unions);
|
|
3750
4171
|
if (!pt || pt.kind === "void") {
|
|
3751
4172
|
return `the record shape is supported, but its member '${p.name}' has type '${checker.typeToString(fieldTs)}', which does not compile`;
|