@scriptc/compiler 0.2.9 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +2 -36
- package/ambient/scriptc-overrides.d.ts +1 -25
- package/ambient/scriptc.d.ts +1 -9
- package/dist/backend/cycle-analysis.d.ts +56 -0
- package/dist/backend/cycle-analysis.js +175 -14
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-analysis.test.js +95 -2
- package/dist/backend/cycle-analysis.test.js.map +1 -1
- package/dist/backend/cycle-mutability.d.ts +3 -7
- package/dist/backend/cycle-mutability.js +4 -30
- package/dist/backend/cycle-mutability.js.map +1 -1
- package/dist/backend/executable-features.d.ts +1 -1
- package/dist/backend/executable-features.js +3 -8
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +57 -0
- package/dist/backend/immutability.js +178 -0
- package/dist/backend/immutability.js.map +1 -0
- package/dist/backend/immutability.test.js +131 -0
- package/dist/backend/immutability.test.js.map +1 -0
- package/dist/backend/library-pack.js +0 -2
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/linker.js +1 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/llvm/borrowed-inputs.d.ts +9 -2
- package/dist/backend/llvm/borrowed-inputs.js +31 -3
- package/dist/backend/llvm/borrowed-inputs.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.test.js +1 -1
- package/dist/backend/llvm/classes.d.ts +28 -0
- package/dist/backend/llvm/classes.js +48 -14
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +134 -6
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +13 -0
- package/dist/backend/llvm/common.js +13 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +1 -1
- package/dist/backend/llvm/constant-callbacks.js +3 -3
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +1 -1
- package/dist/backend/llvm/dense-array-access.js +5 -4
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +10 -2
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +2 -1
- package/dist/backend/llvm/dyn.js +3 -76
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +67 -19
- package/dist/backend/llvm/emitter.js +443 -226
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +21 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.test.js +1 -1
- package/dist/backend/llvm/expr-calls.js +14 -6
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +41 -14
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +4 -107
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.d.ts +1 -2
- package/dist/backend/llvm/expr-dispatch.js +0 -41
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.d.ts +1 -1
- package/dist/backend/llvm/expr-dynamic.js +13 -27
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +30 -3
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +55 -2
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +4 -4
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
- package/dist/backend/llvm/lib-dispatch.js +0 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +0 -13
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +0 -8
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +3 -3
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +1 -1
- package/dist/backend/llvm/loop-array-borrows.d.ts +5 -2
- package/dist/backend/llvm/loop-array-borrows.js +27 -8
- package/dist/backend/llvm/loop-array-borrows.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +14 -0
- package/dist/backend/llvm/map-number-lookup.js +33 -2
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.d.ts +5 -0
- package/dist/backend/llvm/map-read-lifetimes.js +20 -4
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +25 -3
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/reference-writes.d.ts +124 -0
- package/dist/backend/llvm/reference-writes.js +1090 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +8 -5
- package/dist/backend/llvm/shapes.js +37 -13
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +3 -3
- package/dist/backend/llvm/stack-unions.test.js +1 -1
- package/dist/backend/llvm/string-construction.test.js +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +40 -11
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +3 -0
- package/dist/backend/llvm/string-reads.js +31 -0
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.d.ts +2 -2
- package/dist/backend/llvm/switch-dispatch.js +35 -22
- package/dist/backend/llvm/switch-dispatch.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js +29 -11
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -1
- package/dist/backend/llvm/walk-borrows.d.ts +8 -1
- package/dist/backend/llvm/walk-borrows.js +15 -4
- package/dist/backend/llvm/walk-borrows.js.map +1 -1
- package/dist/backend/may-throw.d.ts +36 -2
- package/dist/backend/may-throw.js +308 -21
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +147 -2
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/artifact-stamps.js +0 -2
- package/dist/backend/native/artifact-stamps.js.map +1 -1
- package/dist/backend/native/cache-warm.d.ts +1 -1
- package/dist/backend/native/cache-warm.js +2 -3
- package/dist/backend/native/cache-warm.js.map +1 -1
- package/dist/backend/native/compiler-fingerprint.d.ts +1 -1
- package/dist/backend/native/compiler-fingerprint.js +4 -7
- package/dist/backend/native/compiler-fingerprint.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +3 -28
- package/dist/backend/native/driver.js +1 -3
- package/dist/backend/native/driver.js.map +1 -1
- package/dist/backend/native/executable.d.ts +0 -15
- package/dist/backend/native/executable.js +17 -172
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/tool-identity.js +0 -1
- package/dist/backend/native/tool-identity.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native/vendor.js +1 -1
- package/dist/backend/native/vendor.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +0 -2
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +23 -33
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/publication.d.ts +5 -0
- package/dist/backend/publication.js +10 -0
- package/dist/backend/publication.js.map +1 -1
- package/dist/backend/publication.test.js +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 +1 -2
- package/dist/backend/runtime-pack-core.js +5 -14
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +3 -8
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +22 -19
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.d.ts +0 -5
- package/dist/backend/target-diagnostics.js +1 -11
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +1 -1
- package/dist/backend/vendor-archives.d.ts +1 -7
- package/dist/backend/vendor-archives.js +9 -189
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +0 -1
- package/dist/backend/vendor-inputs.js +0 -1
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/warm-cache.js +3 -5
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +4 -8
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +1 -1
- package/dist/cli/usage.d.ts +1 -5
- package/dist/cli/usage.js +4 -9
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +2 -2
- package/dist/compat/fetch-profile.js +16 -25
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +2 -17
- package/dist/contracts/check.d.ts +8 -0
- package/dist/contracts/check.js +1573 -0
- package/dist/contracts/check.js.map +1 -0
- package/dist/coverage/report.d.ts +5 -22
- package/dist/coverage/report.js +12 -76
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.d.ts +3 -3
- package/dist/coverage/surface-manifest.js +22 -27
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/coverage/verdict-cache.d.ts +1 -3
- package/dist/coverage/verdict-cache.js +2 -7
- package/dist/coverage/verdict-cache.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +11 -60
- package/dist/diagnostics/diagnostic.js +39 -118
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +3 -4
- package/dist/diagnostics/envelope.js +0 -9
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/diagnostics/envelope.test.js +1 -1
- package/dist/diagnostics/envelope.test.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +0 -3
- package/dist/executable/executable-cache.js +2 -4
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +0 -4
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +14 -2
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +10 -10
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/cjs-syntax.js +0 -88
- package/dist/frontend/cjs-syntax.js.map +1 -1
- package/dist/frontend/contract-types.d.ts +50 -0
- package/dist/frontend/contract-types.js +232 -0
- package/dist/frontend/contract-types.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +1 -1
- package/dist/frontend/dts-paths.js +1 -1
- package/dist/frontend/lowering/abstract-equality.js +1 -4
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +4 -11
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/builtins/arguments.js +0 -13
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +0 -4
- package/dist/frontend/lowering/builtins/crypto.js +0 -4
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +1 -39
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +0 -15
- package/dist/frontend/lowering/builtins/module-resolution.js +5 -44
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +0 -6
- package/dist/frontend/lowering/builtins/numbers.js +6 -57
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +4 -67
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/workers.js +1 -1
- package/dist/frontend/lowering/builtins/workers.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +1 -37
- package/dist/frontend/lowering/call-arguments.js +11 -94
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +1 -6
- package/dist/frontend/lowering/call-signatures.js +16 -68
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +19 -4
- package/dist/frontend/lowering/class-dynamic-dispatch.js +168 -98
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +44 -4
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-method-mutations.js +0 -2
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.js +1 -1
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +5 -35
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +0 -1
- package/dist/frontend/lowering/coercions/state.js +0 -1
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +2 -4
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +2 -12
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +12 -0
- package/dist/frontend/lowering/coercions/unions.js +63 -1
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +9 -28
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +2 -3
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +10 -54
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +0 -1
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.js +2 -10
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +1 -6
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +0 -2
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +0 -6
- package/dist/frontend/lowering/containers/string-and-regexp.js +2 -10
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/expressions/evaluation-safety.js +0 -3
- package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +0 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +0 -8
- package/dist/frontend/lowering/expressions/object-literals.js +8 -35
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +0 -4
- package/dist/frontend/lowering/expressions/optional-chains.js +7 -67
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/function-context.js +0 -1
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.js +0 -1
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +10 -77
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.js +1 -10
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +2 -2
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +2 -3
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +2 -27
- package/dist/frontend/lowering/lower-calls.js +56 -465
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +11 -49
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.js +2 -3
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.js +5 -8
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +3 -4
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.js +3 -5
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +0 -8
- package/dist/frontend/lowering/lower-exprs.js +133 -908
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +2 -5
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +1 -50
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +0 -43
- package/dist/frontend/lowering/lower-modules.js +25 -329
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.js +5 -5
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +0 -30
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +98 -0
- package/dist/frontend/lowering/{lower-island.js → lower-stdlib.js} +97 -1160
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -0
- package/dist/frontend/lowering/lower-stmts.d.ts +0 -16
- package/dist/frontend/lowering/lower-stmts.js +58 -1016
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +1 -3
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +26 -151
- package/dist/frontend/lowering/lowerer.js +120 -770
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +4 -51
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/narrowing-stability.d.ts +100 -0
- package/dist/frontend/lowering/narrowing-stability.js +1174 -0
- package/dist/frontend/lowering/narrowing-stability.js.map +1 -0
- package/dist/frontend/lowering/narrowing-stability.test.js +150 -0
- package/dist/frontend/lowering/narrowing-stability.test.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.js +0 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.test.js +2 -2
- package/dist/frontend/lowering/strict-equality.js +1 -1
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +6 -45
- package/dist/frontend/lowering/surfaces.js +5 -65
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/module-syntax.d.ts +0 -3
- package/dist/frontend/module-syntax.js.map +1 -1
- package/dist/frontend/npm-node.d.ts +0 -7
- package/dist/frontend/npm-node.js +0 -7
- package/dist/frontend/npm-node.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.d.ts +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +6 -82
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/npm-static.d.ts +1 -1
- package/dist/frontend/npm-static.js +6 -71
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +3 -319
- package/dist/frontend/npm.js +6 -1007
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +2 -197
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.js +1 -2
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +3 -11
- package/dist/frontend/pipeline.js +37 -56
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +12 -6
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program.d.ts +0 -34
- package/dist/frontend/program.js +13 -98
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/provenance-core.d.ts +0 -4
- package/dist/frontend/provenance-core.js +4 -37
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/provenance-registry.d.ts +0 -4
- package/dist/frontend/provenance-registry.js +0 -20
- package/dist/frontend/provenance-registry.js.map +1 -1
- package/dist/frontend/resolve.d.ts +0 -12
- package/dist/frontend/resolve.js +0 -34
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.js +2 -2
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/services-node.js +2 -3
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services.d.ts +1 -8
- package/dist/frontend/services.js +2 -22
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +0 -38
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/tsc-codes.js +0 -11
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +2 -27
- package/dist/frontend/type-mapper.js +85 -153
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/builtin-effects.js +0 -5
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +1 -55
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/constant-globals.test.js +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/final-fields.test.js +1 -1
- package/dist/ir/initializer-bindings.test.js +1 -1
- package/dist/ir/int32-slots.d.ts +29 -3
- package/dist/ir/int32-slots.js +152 -66
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +1 -1
- package/dist/ir/integer-loops.js +3 -0
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +26 -1
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +20 -0
- package/dist/ir/integer-ranges.js +178 -21
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +148 -3
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +44 -284
- package/dist/ir/ir.js +10 -259
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +2 -7
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +3 -30
- package/dist/ir/runtime-features.js +5 -41
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +6 -2
- package/dist/ir/serialize.js +11 -3
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/traverse.js +0 -21
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/unshare.d.ts +14 -0
- package/dist/ir/unshare.js +60 -0
- package/dist/ir/unshare.js.map +1 -0
- package/dist/ir/unshare.test.js +115 -0
- package/dist/ir/unshare.test.js.map +1 -0
- package/dist/ir/validate.js +9 -207
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +6 -6
- package/dist/library/fence-eval.test.js +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/library-cache.test.js +5 -5
- package/dist/library/prepare.js +14 -20
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cli.js +0 -2
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.test.js +2 -4
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/prepare.js +2 -4
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.js +2 -16
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +0 -3
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/startup-cache.js +0 -2
- package/dist/startup-cache.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +80 -88
- package/dist/backend/llvm/expr-island.d.ts +0 -15
- package/dist/backend/llvm/expr-island.js +0 -709
- package/dist/backend/llvm/expr-island.js.map +0 -1
- package/dist/frontend/lowering/coercions/island.d.ts +0 -37
- package/dist/frontend/lowering/coercions/island.js +0 -350
- package/dist/frontend/lowering/coercions/island.js.map +0 -1
- package/dist/frontend/lowering/lower-island.d.ts +0 -229
- package/dist/frontend/lowering/lower-island.js.map +0 -1
- package/dist/frontend/lowering/lower-island.test.js +0 -56
- package/dist/frontend/lowering/lower-island.test.js.map +0 -1
- package/dist/frontend/npm-fetch-analysis.d.ts +0 -17
- package/dist/frontend/npm-fetch-analysis.js +0 -109
- package/dist/frontend/npm-fetch-analysis.js.map +0 -1
- package/dist/frontend/npm-fetch-analysis.test.js +0 -130
- package/dist/frontend/npm-fetch-analysis.test.js.map +0 -1
- package/dist/frontend/npm-fetch-node.d.ts +0 -2
- package/dist/frontend/npm-fetch-node.js +0 -12
- package/dist/frontend/npm-fetch-node.js.map +0 -1
- package/dist/frontend/npm-fetch-syntax.d.ts +0 -6
- package/dist/frontend/npm-fetch-syntax.js +0 -202
- package/dist/frontend/npm-fetch-syntax.js.map +0 -1
- package/dist/native/runtime-typescript.d.ts +0 -4
- package/dist/native/runtime-typescript.js +0 -74
- package/dist/native/runtime-typescript.js.map +0 -1
- package/dist/native/runtime-typescript.test.js +0 -41
- package/dist/native/runtime-typescript.test.js.map +0 -1
- /package/dist/{frontend/lowering/lower-island.test.d.ts → backend/immutability.test.d.ts} +0 -0
- /package/dist/frontend/{npm-fetch-analysis.test.d.ts → lowering/narrowing-stability.test.d.ts} +0 -0
- /package/dist/{native/runtime-typescript.test.d.ts → ir/unshare.test.d.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
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 { BYTES_ELEMENT_NAME, arrayOf, BOOL, bytesOf, canConvertToDyn, CHILD_T, CRYPTOHASH_T, CRYPTOHMAC_T, DATE_T, DYN, F64, funcOf, isSupportedArrayElem, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType,
|
|
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, 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
6
|
import { literalValues } from "./literal-values.js";
|
|
7
7
|
import { remapUnionDiscriminant } from "./union-discriminants.js";
|
|
@@ -66,15 +66,7 @@ export function jsOpenObjectType(decl, type, shapes, unions) {
|
|
|
66
66
|
? DYN
|
|
67
67
|
: type;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
* values live in the embedded engine and map to island handles (jsval).
|
|
71
|
-
* Static fetch gives Response, RequestInit, AbortController/AbortSignal, response
|
|
72
|
-
* Headers, and the readable Web Streams slice native checked-dynamic
|
|
73
|
-
* handle representations. The Headers constructor itself remains
|
|
74
|
-
* dynamic-only even though response.headers is native.
|
|
75
|
-
* Declaration provenance is checked in mapType so user types with the
|
|
76
|
-
* same names keep their ordinary structural representation. */
|
|
77
|
-
export const ISLAND_AMBIENT_TYPES = [
|
|
69
|
+
export const FETCH_AMBIENT_TYPES = [
|
|
78
70
|
"Response",
|
|
79
71
|
"Request",
|
|
80
72
|
"ResponseInit",
|
|
@@ -91,17 +83,6 @@ export const ISLAND_AMBIENT_TYPES = [
|
|
|
91
83
|
"ReadableStreamReadValueResult",
|
|
92
84
|
"ReadableStreamReadDoneResult",
|
|
93
85
|
];
|
|
94
|
-
function isAmbientAbortHandleType(type, ctx) {
|
|
95
|
-
if (type.isUnionType())
|
|
96
|
-
return ts.constituentTypes(type).some((part) => isAmbientAbortHandleType(part, ctx));
|
|
97
|
-
const symbol = type.getSymbol();
|
|
98
|
-
return (!!symbol &&
|
|
99
|
-
(symbol.name === "AbortSignal" || symbol.name === "AbortController") &&
|
|
100
|
-
ctx.checker
|
|
101
|
-
.declarationsOf(symbol)
|
|
102
|
-
.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
|
|
103
|
-
ctx.isStdlibFile(d.getSourceFile())));
|
|
104
|
-
}
|
|
105
86
|
/** node:util.parseArgs's public and @types/node helper type names. Values
|
|
106
87
|
* behind this surface use the checked-dynamic tree; see mapTypeInner. */
|
|
107
88
|
const PARSE_ARGS_DYN_TYPES = new Set([
|
|
@@ -640,8 +621,6 @@ export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
|
640
621
|
seen.delete(t.unionId);
|
|
641
622
|
}
|
|
642
623
|
}
|
|
643
|
-
case "jsval":
|
|
644
|
-
return append("any");
|
|
645
624
|
case "regex":
|
|
646
625
|
return append("RegExp");
|
|
647
626
|
case "date":
|
|
@@ -908,7 +887,7 @@ export function mapType(type, ctx) {
|
|
|
908
887
|
const topLevel = mapTypeDepth === 0;
|
|
909
888
|
const typeId = type.id;
|
|
910
889
|
const memoizable = typeId !== undefined && (ctx.canMemoizeType?.() ?? true);
|
|
911
|
-
const memoKey = memoizable ? `${
|
|
890
|
+
const memoKey = memoizable ? `${0}:${typeId}` : null;
|
|
912
891
|
if (memoKey !== null) {
|
|
913
892
|
const memo = ctx.typeMemo?.get(memoKey);
|
|
914
893
|
if (memo !== undefined)
|
|
@@ -945,11 +924,9 @@ function mapTypeInner(type, ctx) {
|
|
|
945
924
|
// TypeScript's intrinsic globalThis symbol has no declaration. A stored
|
|
946
925
|
// reference needs native object identity, including var's undefined state.
|
|
947
926
|
const intrinsic = type.getSymbol();
|
|
948
|
-
if (
|
|
949
|
-
intrinsic?.name === "globalThis" &&
|
|
950
|
-
checker.declarationsOf(intrinsic).length === 0)
|
|
927
|
+
if (intrinsic?.name === "globalThis" && checker.declarationsOf(intrinsic).length === 0)
|
|
951
928
|
return DYN;
|
|
952
|
-
|
|
929
|
+
{
|
|
953
930
|
const moduleId = ctx.moduleNamespaceId?.(type) ?? null;
|
|
954
931
|
if (moduleId !== null)
|
|
955
932
|
return { kind: "moduleNs", moduleId };
|
|
@@ -963,6 +940,11 @@ function mapTypeInner(type, ctx) {
|
|
|
963
940
|
checker.declarationsOf(directAlias).some((decl) => ctx.isStdlibFile(decl.getSourceFile()))) {
|
|
964
941
|
return { kind: "object", className: "%Error" };
|
|
965
942
|
}
|
|
943
|
+
// Immutable<T> (@scriptc/types) is a deep-readonly view: the value is
|
|
944
|
+
// still the T it maps.
|
|
945
|
+
const immutableSource = immutableSourceType(type, ctx);
|
|
946
|
+
if (immutableSource !== null)
|
|
947
|
+
return mapType(immutableSource, ctx);
|
|
966
948
|
if (resolveTypeParam && type.flags & ts.TypeFlags.TypeParameter) {
|
|
967
949
|
const bound = resolveTypeParam(type);
|
|
968
950
|
if (bound) {
|
|
@@ -1154,12 +1136,10 @@ function mapTypeInner(type, ctx) {
|
|
|
1154
1136
|
// (the Object.prototype surface) fence at their use sites.
|
|
1155
1137
|
if (flags & ts.TypeFlags.NonPrimitive)
|
|
1156
1138
|
return DYN;
|
|
1157
|
-
// `any`
|
|
1158
|
-
//
|
|
1159
|
-
// per-site diagnostic tells the user about --dynamic and the static
|
|
1160
|
-
// alternative (`unknown` + a checked cast).
|
|
1139
|
+
// Context-free `any` has no concrete storage shape. The lowering site
|
|
1140
|
+
// chooses checked-value storage when its operations support that boundary.
|
|
1161
1141
|
if (flags & ts.TypeFlags.Any)
|
|
1162
|
-
return
|
|
1142
|
+
return null;
|
|
1163
1143
|
// Enum types and enum member literal types: an enum VALUE at runtime IS
|
|
1164
1144
|
// its underlying primitive (tsc's own emit stores plain numbers/strings
|
|
1165
1145
|
// on the enum object; const enums inline them), so the enum type maps to
|
|
@@ -1194,23 +1174,10 @@ function mapTypeInner(type, ctx) {
|
|
|
1194
1174
|
return hasStr ? STRING : F64;
|
|
1195
1175
|
}
|
|
1196
1176
|
}
|
|
1197
|
-
//
|
|
1198
|
-
//
|
|
1199
|
-
//
|
|
1200
|
-
//
|
|
1201
|
-
// --dynamic they are island handles (jsval), and every operation on them
|
|
1202
|
-
// rides the engine ops with validated exits at typed boundaries.
|
|
1203
|
-
// Primitives/arrays/etc. REACHED THROUGH such types keep their
|
|
1204
|
-
// structural mapping (they were handled above or recurse normally); this
|
|
1205
|
-
// rule fires only when the type's own identity is declaration-file-
|
|
1206
|
-
// declared — interfaces, classes, type literals, and aliases from the
|
|
1207
|
-
// .d.ts. The standard library's declaration files are carved out (their
|
|
1208
|
-
// surfaces have static lowerings), as are declarations explicitly mapped
|
|
1209
|
-
// by --external-types: those describe project-owned structural data while
|
|
1210
|
-
// the Lowerer fences their imported runtime bindings. The program's own
|
|
1211
|
-
// compiled modules are never declaration files. Without --dynamic this
|
|
1212
|
-
// stays unmapped; badType reports the per-package requires-dynamic
|
|
1213
|
-
// diagnostic for node_modules types and the generic story otherwise.
|
|
1177
|
+
// Declaration-only package types have no compiled implementation.
|
|
1178
|
+
// Primitive and container types retain their structural mappings; types
|
|
1179
|
+
// owned by the standard library or explicit host mappings are handled
|
|
1180
|
+
// by their dedicated native rules.
|
|
1214
1181
|
const npmSym = widened.getAliasSymbol() ?? widened.getSymbol();
|
|
1215
1182
|
const npmDecls = npmSym ? checker.declarationsOf(npmSym) : undefined;
|
|
1216
1183
|
if (npmDecls &&
|
|
@@ -1219,22 +1186,17 @@ function mapTypeInner(type, ctx) {
|
|
|
1219
1186
|
const sf = d.getSourceFile();
|
|
1220
1187
|
return sf.isDeclarationFile && !ctx.isStdlibFile(sf) && !ctx.isExternalTypeFile(sf);
|
|
1221
1188
|
})) {
|
|
1222
|
-
return
|
|
1189
|
+
return null;
|
|
1223
1190
|
}
|
|
1224
|
-
// Module
|
|
1225
|
-
//
|
|
1226
|
-
// or supported builtin in a static build. Declaration-only package
|
|
1227
|
-
// namespaces retain the npm rule above; dynamic builds retain their
|
|
1228
|
-
// jsval import-handle path.
|
|
1191
|
+
// Module namespaces were claimed above when they name compiled source
|
|
1192
|
+
// modules or supported builtins. Declaration-only namespaces remain refused.
|
|
1229
1193
|
// T[]: monomorphic arrays, recursively (number[][] works). An element type
|
|
1230
1194
|
// that doesn't map (never from a context-free `[]`) makes the whole array
|
|
1231
1195
|
// unsupported — null propagates. Record/object/union elements ride the
|
|
1232
1196
|
// runtime's REF element kind (per-array RC entry points, the map-value
|
|
1233
1197
|
// technique), and PROMISE elements ride it too (Promise<T>[] is
|
|
1234
1198
|
// Promise.all's food: promises are refcounted, cycle-headered values
|
|
1235
|
-
// with `_v` adapters like any other ref element
|
|
1236
|
-
// JSON-serialize or cross the island boundary, which the safety
|
|
1237
|
-
// predicates already refuse). FUNCTION elements ride REF too (closure
|
|
1199
|
+
// with `_v` adapters like any other ref element). FUNCTION elements ride REF too (closure
|
|
1238
1200
|
// `_v` adapters + scr_closure_trace_v — closures are cycle-headered):
|
|
1239
1201
|
// `f === f` identity through indexOf/includes is sound because a
|
|
1240
1202
|
// function VALUE is one ScrClosure for its whole life — top-level
|
|
@@ -1255,17 +1217,6 @@ function mapTypeInner(type, ctx) {
|
|
|
1255
1217
|
// VOID mapping is a return-position artifact, not a value.
|
|
1256
1218
|
if (elem?.kind === "void" && isUnitOnlyTsType(elemTs, ctx.resolveTypeParam))
|
|
1257
1219
|
elem = unitOnlyUnion(unions);
|
|
1258
|
-
// A jsval element ABSORBS the array — with one carve-out. An array
|
|
1259
|
-
// type entangled with package-declared ('npm-jsval') elements
|
|
1260
|
-
// (`GeneratedFile[]`, `ModelMessage[]`) describes ISLAND values: the
|
|
1261
|
-
// handles those APIs produce are engine arrays, never the static
|
|
1262
|
-
// ScrArr this mapping would otherwise claim, so the whole array is
|
|
1263
|
-
// one handle and every operation on it is an engine op. The carve-out
|
|
1264
|
-
// is literal `any[]`: an EXPLICIT static array of dynamic values —
|
|
1265
|
-
// the messages-building pattern (`const content: any[] = []`) — which
|
|
1266
|
-
// keeps its static array-of-handles representation.
|
|
1267
|
-
if (elem?.kind === "jsval" && !(elemTs.flags & ts.TypeFlags.Any))
|
|
1268
|
-
return JSVAL;
|
|
1269
1220
|
if (!elem)
|
|
1270
1221
|
return null;
|
|
1271
1222
|
// A dyn ELEMENT makes the WHOLE array the checked-dynamic value:
|
|
@@ -1323,17 +1274,13 @@ function mapTypeInner(type, ctx) {
|
|
|
1323
1274
|
return arrayOf(unitOnlyUnion(unions));
|
|
1324
1275
|
if (tupleShape?.elementFlags === undefined)
|
|
1325
1276
|
return null;
|
|
1326
|
-
// Optional/rest elements
|
|
1327
|
-
// have no fixed shape — the ARITY is a runtime fact. Under --dynamic
|
|
1328
|
-
// the value lives in the engine, a real JS array carrying its true
|
|
1329
|
-
// length (reads, destructuring, JSON, .length all exact); static
|
|
1330
|
-
// builds stay unmapped and badType tells the dynamic-tier story.
|
|
1277
|
+
// Optional/rest elements have no fixed native tuple layout.
|
|
1331
1278
|
if (tupleShape.elementFlags.some((f) => !(f & ts.ElementFlags.Required))) {
|
|
1332
|
-
return
|
|
1279
|
+
return null;
|
|
1333
1280
|
}
|
|
1334
1281
|
const fields = [];
|
|
1335
1282
|
for (let i = 0; i < args.length; i++) {
|
|
1336
|
-
let et =
|
|
1283
|
+
let et = (args[i].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[i], ctx);
|
|
1337
1284
|
// A unit-only element (`[number, undefined]`) rides the unit-only
|
|
1338
1285
|
// union, the record-field rule.
|
|
1339
1286
|
if (et?.kind === "void" && isUnitOnlyTsType(args[i], ctx.resolveTypeParam))
|
|
@@ -1344,10 +1291,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1344
1291
|
// plumbing, values arrive dyn or convert via dynFrom.
|
|
1345
1292
|
if (!et || et.kind === "void")
|
|
1346
1293
|
return null;
|
|
1347
|
-
// A jsval member keeps this tuple in the island as a real JS array.
|
|
1348
1294
|
// Object records may instead keep ambient abort handles in slots.
|
|
1349
|
-
if (et.kind === "jsval")
|
|
1350
|
-
return JSVAL;
|
|
1351
1295
|
fields.push({ name: String(i), type: et });
|
|
1352
1296
|
}
|
|
1353
1297
|
fields.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
@@ -1765,7 +1709,6 @@ function mapTypeInner(type, ctx) {
|
|
|
1765
1709
|
// stdio and env values. Keep it checked-dynamic for native normalization.
|
|
1766
1710
|
if (isStdlibInterface("SpawnOptions"))
|
|
1767
1711
|
return DYN;
|
|
1768
|
-
// The fetch ambient slice: under --dynamic these are island handles
|
|
1769
1712
|
// exactly like npm-declared types. Static fetch has one deliberately
|
|
1770
1713
|
// narrower native representation: Response is an opaque checked-
|
|
1771
1714
|
// dynamic capsule consumed only by the Response method lowerings, and
|
|
@@ -1778,8 +1721,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1778
1721
|
// interfaces; @types/node's undici-types declares Response as a class).
|
|
1779
1722
|
{
|
|
1780
1723
|
const alias = widened.getAliasSymbol();
|
|
1781
|
-
if (
|
|
1782
|
-
alias?.name === "ReadableStreamReadResult" &&
|
|
1724
|
+
if (alias?.name === "ReadableStreamReadResult" &&
|
|
1783
1725
|
checker
|
|
1784
1726
|
.declarationsOf(alias)
|
|
1785
1727
|
.some((d) => ts.isTypeAliasDeclaration(d) && ctx.isStdlibFile(d.getSourceFile()))) {
|
|
@@ -1790,8 +1732,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1790
1732
|
return genResultRecord(elem, VOID, ctx.shapes, ctx.unions);
|
|
1791
1733
|
}
|
|
1792
1734
|
}
|
|
1793
|
-
if (
|
|
1794
|
-
psym &&
|
|
1735
|
+
if (psym &&
|
|
1795
1736
|
(psym.name === "ReadableStreamReadValueResult" ||
|
|
1796
1737
|
psym.name === "ReadableStreamReadDoneResult") &&
|
|
1797
1738
|
checker
|
|
@@ -1804,7 +1745,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1804
1745
|
return genResultRecord(elem, VOID, ctx.shapes, ctx.unions);
|
|
1805
1746
|
}
|
|
1806
1747
|
if (psym &&
|
|
1807
|
-
|
|
1748
|
+
FETCH_AMBIENT_TYPES.includes(psym.name) &&
|
|
1808
1749
|
!(psym.name === "ReadableStream" &&
|
|
1809
1750
|
checker
|
|
1810
1751
|
.declarationsOf(psym)
|
|
@@ -1813,7 +1754,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1813
1754
|
.declarationsOf(psym)
|
|
1814
1755
|
.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
|
|
1815
1756
|
ctx.isStdlibFile(d.getSourceFile()))) {
|
|
1816
|
-
return
|
|
1757
|
+
return DYN;
|
|
1817
1758
|
}
|
|
1818
1759
|
// ReadonlyMap/ReadonlySet are the SAME runtime values as Map/Set — the
|
|
1819
1760
|
// readonly-ness is a checker-only view (no mutating members on the
|
|
@@ -1823,11 +1764,11 @@ function mapTypeInner(type, ctx) {
|
|
|
1823
1764
|
const args = checker.getTypeArguments(widened);
|
|
1824
1765
|
if (args.length !== 2)
|
|
1825
1766
|
return null;
|
|
1826
|
-
const key =
|
|
1767
|
+
const key = (args[0].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[0], ctx);
|
|
1827
1768
|
if (!key ||
|
|
1828
1769
|
!isSupportedMapKey(key, key.kind === "union" ? ctx.unions.get(key.unionId)?.arms : undefined))
|
|
1829
1770
|
return null;
|
|
1830
|
-
const value =
|
|
1771
|
+
const value = (args[1].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[1], ctx);
|
|
1831
1772
|
if (!value || !isSupportedMapValue(value))
|
|
1832
1773
|
return null;
|
|
1833
1774
|
return mapOf(key, value);
|
|
@@ -1835,7 +1776,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1835
1776
|
// Native WeakMap keeps reference identities in checked-dynamic storage.
|
|
1836
1777
|
// The runtime rejects reference kinds without a weak lifetime contract.
|
|
1837
1778
|
if (isStdlibInterface("WeakMap") || isStdlibInterface("WeakSet"))
|
|
1838
|
-
return
|
|
1779
|
+
return DYN;
|
|
1839
1780
|
// Set<T>: Map's sibling — same provenance rule and key domain.
|
|
1840
1781
|
// Anything else stays unmapped;
|
|
1841
1782
|
// the `new Set` lowering names the offending element type specifically.
|
|
@@ -1843,7 +1784,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1843
1784
|
const args = checker.getTypeArguments(widened);
|
|
1844
1785
|
if (args.length !== 1)
|
|
1845
1786
|
return null;
|
|
1846
|
-
const elem =
|
|
1787
|
+
const elem = (args[0].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[0], ctx);
|
|
1847
1788
|
if (!elem ||
|
|
1848
1789
|
!isSupportedSetElem(elem, elem.kind === "union" ? ctx.unions.get(elem.unionId)?.arms : undefined))
|
|
1849
1790
|
return null;
|
|
@@ -2331,10 +2272,8 @@ function mapTypeInner(type, ctx) {
|
|
|
2331
2272
|
// Promise<any> in a STATIC build (untyped JS entries: `new
|
|
2332
2273
|
// Promise((resolve) => ...)` infers any): the settled value rides the
|
|
2333
2274
|
// dyn arm exactly like Promise<unknown> — every use of the awaited
|
|
2334
|
-
// value is checked-dynamic, the same
|
|
2335
|
-
|
|
2336
|
-
// handle).
|
|
2337
|
-
if (arg.flags & ts.TypeFlags.Any && !ctx.dynamic)
|
|
2275
|
+
// value is checked-dynamic, the same checks `unknown` gets.
|
|
2276
|
+
if (arg.flags & ts.TypeFlags.Any)
|
|
2338
2277
|
return { kind: "promise", inner: DYN };
|
|
2339
2278
|
const inner = mapType(arg, ctx);
|
|
2340
2279
|
if (!inner)
|
|
@@ -2412,9 +2351,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2412
2351
|
}
|
|
2413
2352
|
// PromiseSettledResult<T>'s parts: the lib's PromiseFulfilledResult<T> /
|
|
2414
2353
|
// PromiseRejectedResult interfaces map to the documented HONEST SUBSET
|
|
2415
|
-
// record { status: string }
|
|
2416
|
-
// record-field representation here (void fields don't exist; a jsval
|
|
2417
|
-
// field would absorb the record), and the manual-allSettled pattern this
|
|
2354
|
+
// record { status: string }. The manual-allSettled pattern this
|
|
2418
2355
|
// mapping exists for (pMap) discards them. Construction literals still
|
|
2419
2356
|
// EVALUATE a dropped initializer for its effects — the awaited mapper —
|
|
2420
2357
|
// via the object-literal lowering's drop path. Both interfaces intern
|
|
@@ -2750,8 +2687,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2750
2687
|
return hybrid;
|
|
2751
2688
|
// Recursive and Symbol-keyed callable objects need their complete live
|
|
2752
2689
|
// property table; dropping those members into a plain closure loses data.
|
|
2753
|
-
if (
|
|
2754
|
-
checker.getCallSignatures(widened).length > 0 &&
|
|
2690
|
+
if (checker.getCallSignatures(widened).length > 0 &&
|
|
2755
2691
|
checker.getPropertiesOfType(widened).length > 0)
|
|
2756
2692
|
return DYN;
|
|
2757
2693
|
}
|
|
@@ -2785,7 +2721,6 @@ function mapTypeInner(type, ctx) {
|
|
|
2785
2721
|
for (const p of sig.getParameters()) {
|
|
2786
2722
|
const decl = checker.valueDeclarationOf(p);
|
|
2787
2723
|
const rest = decl !== undefined && ts.isParameter(decl) && decl.dotDotDotToken !== undefined;
|
|
2788
|
-
// JavaScript rest values retain the checked-dynamic/island runtime-
|
|
2789
2724
|
// arity ABI selected by lambdaSignature. Treating an inferred any[]
|
|
2790
2725
|
// declaration as a typed packed-array closure would bypass its boxed
|
|
2791
2726
|
// spread/error semantics and change coverage classification.
|
|
@@ -2832,7 +2767,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2832
2767
|
// Belt and braces for non-strict type worlds: an optional param's
|
|
2833
2768
|
// ABI slot is always the undefined-armed union (strictNullChecks
|
|
2834
2769
|
// already spells it that way; arm it here if the world didn't).
|
|
2835
|
-
if (optional && pt && pt.kind !== "void" && pt.kind !== "
|
|
2770
|
+
if (optional && pt && pt.kind !== "void" && pt.kind !== "dyn") {
|
|
2836
2771
|
const armed = withUndefinedArm(pt, ctx.unions);
|
|
2837
2772
|
if (!armed)
|
|
2838
2773
|
return null;
|
|
@@ -2861,7 +2796,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2861
2796
|
const jsUnitReturn = sigDecl !== undefined &&
|
|
2862
2797
|
isJsSourceFile(sigDecl.getSourceFile()) &&
|
|
2863
2798
|
(retT.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) !== 0;
|
|
2864
|
-
let ret = jsUnitReturn || (
|
|
2799
|
+
let ret = jsUnitReturn || (retT.flags & ts.TypeFlags.Any) !== 0
|
|
2865
2800
|
? DYN
|
|
2866
2801
|
: retT.flags & ts.TypeFlags.Never
|
|
2867
2802
|
? VOID
|
|
@@ -3063,24 +2998,7 @@ function mapTypeInner(type, ctx) {
|
|
|
3063
2998
|
continue;
|
|
3064
2999
|
}
|
|
3065
3000
|
const mapped = mapType(part, ctx);
|
|
3066
|
-
// A jsval PART absorbs the union: `GeneratedFile | undefined` (a
|
|
3067
|
-
// package-declared arm) is one island handle — the engine's
|
|
3068
|
-
// undefined/null ARE handle values, and any data sibling is
|
|
3069
|
-
// representable in the engine too, so the handle is the one
|
|
3070
|
-
// runtime representation. Exactly tsc's own collapse for `any | T`
|
|
3071
|
-
// (which never even reaches here as a union). Sibling arms that
|
|
3072
|
-
// already mapped don't matter — and ones that would NOT map on
|
|
3073
|
-
// their own don't block the absorb either: a STATIC value of such
|
|
3074
|
-
// an arm flowing in still fences per-site at the marshal
|
|
3075
|
-
// (jsvalIn's boundary message).
|
|
3076
|
-
if (mapped?.kind === "jsval")
|
|
3077
|
-
return JSVAL;
|
|
3078
3001
|
if (!mapped) {
|
|
3079
|
-
// Before failing the whole union, let a LATER jsval part absorb.
|
|
3080
|
-
for (const rest of ts.constituentTypes(widened)) {
|
|
3081
|
-
if (mapType(rest, ctx)?.kind === "jsval")
|
|
3082
|
-
return JSVAL;
|
|
3083
|
-
}
|
|
3084
3002
|
return null;
|
|
3085
3003
|
}
|
|
3086
3004
|
if (mapped.kind === "void") {
|
|
@@ -3126,10 +3044,8 @@ function mapTypeInner(type, ctx) {
|
|
|
3126
3044
|
// DYN WHOLESALE — the checked-dynamic tree's scalar kinds ARE the scalar arms (===,
|
|
3127
3045
|
// typeof, switch dispatch all exact), typeof/Array.isArray/unit
|
|
3128
3046
|
// narrowing on dyn already dispatches natively (dynTest +
|
|
3129
|
-
// maybeNarrow's validated scalar extraction),
|
|
3130
|
-
//
|
|
3131
|
-
// tag is ever needed and the component fence retires at these
|
|
3132
|
-
// sites. The domain is dynSubsumableUnionArm's: scalars, units, dyn
|
|
3047
|
+
// maybeNarrow's validated scalar extraction), so no union tag is
|
|
3048
|
+
// needed. The domain is dynSubsumableUnionArm's: scalars, units, dyn
|
|
3133
3049
|
// itself, and records/arrays inside the dynFrom conversion domain
|
|
3134
3050
|
// (those enter as dyn data — the deep-copy stance, so identity and
|
|
3135
3051
|
// mutation coupling with the source value end at the slot;
|
|
@@ -3538,11 +3454,6 @@ function mapBoundIndexedAccess(type, ctx) {
|
|
|
3538
3454
|
* (`{a?: string}` and `{a: string | undefined}` are ONE shape) — those stay
|
|
3539
3455
|
* unmapped inside generic bodies; their concrete uses resolve structurally
|
|
3540
3456
|
* through mapRecordType. */
|
|
3541
|
-
/** `Awaited<T>` where T is a STILL-GENERIC type parameter, resolved against
|
|
3542
|
-
* the lowerer's binding: promise kinds unwrap recursively (the alias's own
|
|
3543
|
-
* recursion), everything else is already its awaited self — including
|
|
3544
|
-
* jsval (the engine's await handles thenables natively). Null off the
|
|
3545
|
-
* shape (not the lib's Awaited over a bound parameter). */
|
|
3546
3457
|
/** True for a TypeNode spelling the `const` assertion (`e as const`). */
|
|
3547
3458
|
export function isConstAssertionTypeNode(t) {
|
|
3548
3459
|
return (t.kind === ts.SyntaxKind.TypeReference &&
|
|
@@ -3746,7 +3657,7 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
3746
3657
|
byKey.set(typeKey(a), a);
|
|
3747
3658
|
return true;
|
|
3748
3659
|
}
|
|
3749
|
-
if (t.kind === "regex" || t.kind === "date" || t.kind === "
|
|
3660
|
+
if (t.kind === "regex" || t.kind === "date" || t.kind === "generator") {
|
|
3750
3661
|
return false; // no legal union arm exists for these kinds
|
|
3751
3662
|
}
|
|
3752
3663
|
byKey.set(typeKey(t), t);
|
|
@@ -3804,8 +3715,6 @@ export function withUndefinedArm(t, unions) {
|
|
|
3804
3715
|
/** Preserve a nullish runtime value that JavaScript inference omitted. */
|
|
3805
3716
|
export function withUnitArm(t, kind, unions) {
|
|
3806
3717
|
const unit = { kind };
|
|
3807
|
-
if (t.kind === "jsval")
|
|
3808
|
-
return t;
|
|
3809
3718
|
if (t.kind === "union") {
|
|
3810
3719
|
const def = unions.get(t.unionId);
|
|
3811
3720
|
if (!def)
|
|
@@ -3873,8 +3782,7 @@ function mapHybridCallableIntersection(widened, ctx) {
|
|
|
3873
3782
|
if (p.flags & (ts.SymbolFlags.GetAccessor | ts.SymbolFlags.SetAccessor))
|
|
3874
3783
|
return null;
|
|
3875
3784
|
const pt = mapType(checker.getTypeOfSymbol(p), ctx);
|
|
3876
|
-
|
|
3877
|
-
if (!pt || pt.kind === "void" || pt.kind === "jsval")
|
|
3785
|
+
if (!pt || pt.kind === "void")
|
|
3878
3786
|
return null;
|
|
3879
3787
|
fields.push({ name: p.name, type: pt });
|
|
3880
3788
|
declaredOrder.push(p.name);
|
|
@@ -4027,6 +3935,44 @@ function mapBrandedPrimitiveIntersection(widened, ctx) {
|
|
|
4027
3935
|
}
|
|
4028
3936
|
return primitive && markerParts > 0 ? primitive : null;
|
|
4029
3937
|
}
|
|
3938
|
+
/** The declaration file of @scriptc/types (installed, pnpm-linked or the
|
|
3939
|
+
* workspace package). */
|
|
3940
|
+
const CONTRACT_TYPES_FILE = /[\\/](?:@scriptc[\\/]types|packages[\\/]types)[\\/]index\.d\.ts$/;
|
|
3941
|
+
/** `Immutable<T>` over a class, interface or object literal type resolves to
|
|
3942
|
+
* a mapped type declared in @scriptc/types; TypeScript drops the alias, but
|
|
3943
|
+
* homomorphic mapped members keep their original declarations. The source
|
|
3944
|
+
* type is the non-generic declaration that declares every member (the most
|
|
3945
|
+
* derived class or interface). Null for every other type. */
|
|
3946
|
+
function immutableSourceType(type, ctx) {
|
|
3947
|
+
if (!isMappedShape(type))
|
|
3948
|
+
return null;
|
|
3949
|
+
const { checker } = ctx;
|
|
3950
|
+
const symbol = type.getSymbol();
|
|
3951
|
+
const decl = symbol ? checker.declarationsOf(symbol)[0] : undefined;
|
|
3952
|
+
if (decl === undefined || !CONTRACT_TYPES_FILE.test(decl.getSourceFile().fileName))
|
|
3953
|
+
return null;
|
|
3954
|
+
const props = checker.getPropertiesOfType(type);
|
|
3955
|
+
const seen = new Set();
|
|
3956
|
+
for (const prop of props) {
|
|
3957
|
+
const owner = checker.declarationsOf(prop)[0]?.parent;
|
|
3958
|
+
if (owner === undefined || seen.has(owner))
|
|
3959
|
+
continue;
|
|
3960
|
+
seen.add(owner);
|
|
3961
|
+
let source = null;
|
|
3962
|
+
if (ts.isTypeLiteralNode(owner))
|
|
3963
|
+
source = checker.getTypeFromTypeNode(owner);
|
|
3964
|
+
else if ((ts.isClassDeclaration(owner) || ts.isInterfaceDeclaration(owner)) &&
|
|
3965
|
+
owner.name !== undefined &&
|
|
3966
|
+
(owner.typeParameters?.length ?? 0) === 0) {
|
|
3967
|
+
const ownerSymbol = checker.getSymbolAtLocation(owner.name);
|
|
3968
|
+
if (ownerSymbol)
|
|
3969
|
+
source = checker.getDeclaredTypeOfSymbol(ownerSymbol);
|
|
3970
|
+
}
|
|
3971
|
+
if (source !== null && checker.getPropertiesOfType(source).length === props.length)
|
|
3972
|
+
return source;
|
|
3973
|
+
}
|
|
3974
|
+
return null;
|
|
3975
|
+
}
|
|
4030
3976
|
/** True for MAPPED-type results — `Partial<Config>`, `Record<"a", n>`,
|
|
4031
3977
|
* whatever `Pick`/`Omit` reduce to. Their shape is computed by the checker,
|
|
4032
3978
|
* not declared anywhere: the only declaration behind them is the utility
|
|
@@ -4120,11 +4066,10 @@ function mapRecordType(widened, ctx) {
|
|
|
4120
4066
|
if (inner === null)
|
|
4121
4067
|
return null; // a pending placeholder, if minted, stays unfinalized (prunes as unreachable)
|
|
4122
4068
|
if (!("fields" in inner)) {
|
|
4123
|
-
// A whole-type answer (the jsval/dyn absorbs, the header-family
|
|
4124
4069
|
// canonical shape). If a back-reference minted a placeholder for
|
|
4125
4070
|
// this very type meanwhile, the two answers disagree — fence rather
|
|
4126
4071
|
// than leave references to a shape that is not this type's mapping.
|
|
4127
|
-
if (shapes.recursivePending(widened) && inner.kind !== "
|
|
4072
|
+
if (shapes.recursivePending(widened) && inner.kind !== "dyn")
|
|
4128
4073
|
return null;
|
|
4129
4074
|
return inner;
|
|
4130
4075
|
}
|
|
@@ -4251,12 +4196,7 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
4251
4196
|
if (!stringKey(info.keyType) && !(info.keyType.flags & ts.TypeFlags.Number))
|
|
4252
4197
|
return null;
|
|
4253
4198
|
const iv = mapType(info.valueType, ctx);
|
|
4254
|
-
// A jsval-valued signature absorbs the shape: `Record<string,
|
|
4255
4199
|
// JSONValue>` (a package's own JSON alias) and `Record<string, any>`
|
|
4256
|
-
// are one island object — the overflow map has no handle slot, and
|
|
4257
|
-
// island objects hold arbitrary engine values natively.
|
|
4258
|
-
if (iv?.kind === "jsval")
|
|
4259
|
-
return JSVAL;
|
|
4260
4200
|
if (!iv || !isSupportedIndexValue(iv))
|
|
4261
4201
|
return null;
|
|
4262
4202
|
if (v !== null && !typeEquals(v, iv))
|
|
@@ -4420,7 +4360,7 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
4420
4360
|
let readT = null;
|
|
4421
4361
|
if (getDecl) {
|
|
4422
4362
|
readT = mapType(checker.getTypeOfSymbol(p), ctx);
|
|
4423
|
-
if (readT === null
|
|
4363
|
+
if (readT === null)
|
|
4424
4364
|
return null;
|
|
4425
4365
|
}
|
|
4426
4366
|
let writeT = null;
|
|
@@ -4432,10 +4372,7 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
4432
4372
|
// A void/unit-typed write slot has no value form; DIVERGENT
|
|
4433
4373
|
// getter/setter types stay out too (one property, one type —
|
|
4434
4374
|
// the class-accessor stance).
|
|
4435
|
-
if (writeT === null ||
|
|
4436
|
-
writeT.kind === "void" ||
|
|
4437
|
-
writeT.kind === "jsval" ||
|
|
4438
|
-
isUnitType(writeT))
|
|
4375
|
+
if (writeT === null || writeT.kind === "void" || isUnitType(writeT))
|
|
4439
4376
|
return null;
|
|
4440
4377
|
if (readT !== null && typeKey(readT) !== typeKey(writeT))
|
|
4441
4378
|
return null;
|
|
@@ -4472,12 +4409,12 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
4472
4409
|
// initializer is an EMPTY array literal inside a const assertion IS
|
|
4473
4410
|
// the empty tuple — map it exactly as the tuple branch does (the
|
|
4474
4411
|
// unit-element array; see the `[] as const` rule there).
|
|
4475
|
-
if (
|
|
4412
|
+
if (pt === null &&
|
|
4476
4413
|
(fieldTs.flags & ts.TypeFlags.Any) !== 0 &&
|
|
4477
4414
|
constAssertedEmptyArrayProp(p, ctx)) {
|
|
4478
4415
|
pt = arrayOf(unitOnlyUnion(ctx.unions));
|
|
4479
4416
|
}
|
|
4480
|
-
if (pt === null &&
|
|
4417
|
+
if (pt === null && (fieldTs.flags & ts.TypeFlags.Any) !== 0)
|
|
4481
4418
|
pt = DYN;
|
|
4482
4419
|
// Unit-only FIELDS (`{ msg?: undefined }` — the discriminated-union
|
|
4483
4420
|
// absent-field idiom — and `{ p: undefined }` spellings): the
|
|
@@ -4497,12 +4434,7 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
4497
4434
|
// accessor dispatch, so the shape stays unmapped.
|
|
4498
4435
|
if (accessorSlotProp(p.name) !== null)
|
|
4499
4436
|
return null;
|
|
4500
|
-
// Keep ambient abort handles in a native record slot under --dynamic:
|
|
4501
4437
|
// an options record with `signal?: AbortSignal` must not turn its
|
|
4502
|
-
// unrelated static fields into island properties. Other bare jsval
|
|
4503
|
-
// fields still absorb the record into one island object.
|
|
4504
|
-
if (pt.kind === "jsval" && !(ctx.dynamic && isAmbientAbortHandleType(fieldTs, ctx)))
|
|
4505
|
-
return JSVAL;
|
|
4506
4438
|
fields.push({ name: p.name, type: pt });
|
|
4507
4439
|
}
|
|
4508
4440
|
// getPropertiesOfType yields DECLARATION order (interface/alias/literal
|