@scriptc/compiler 0.4.2 → 0.4.3
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 +397 -37
- package/dist/backend/cycle-analysis.d.ts +4 -1
- package/dist/backend/cycle-analysis.js +6 -4
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-analysis.test.js +55 -0
- package/dist/backend/cycle-analysis.test.js.map +1 -1
- package/dist/backend/cycle-mutability.d.ts +7 -0
- package/dist/backend/cycle-mutability.js +19 -1
- package/dist/backend/cycle-mutability.js.map +1 -1
- package/dist/backend/executable-features.js +2 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +6 -3
- package/dist/backend/immutability.js +33 -29
- package/dist/backend/immutability.js.map +1 -1
- package/dist/backend/library-pack.js +1 -0
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +16 -1
- package/dist/backend/llvm/alloc.js +54 -4
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/appended-array-literals.d.ts +2 -1
- package/dist/backend/llvm/appended-array-literals.js +44 -36
- package/dist/backend/llvm/appended-array-literals.js.map +1 -1
- package/dist/backend/llvm/appended-array-literals.test.js +4 -3
- package/dist/backend/llvm/appended-array-literals.test.js.map +1 -1
- package/dist/backend/llvm/array-search.d.ts +4 -3
- package/dist/backend/llvm/array-search.js +21 -9
- package/dist/backend/llvm/array-search.js.map +1 -1
- package/dist/backend/llvm/blocks.d.ts +1 -1
- package/dist/backend/llvm/blocks.js +2 -2
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/byte-windows.js +2 -0
- package/dist/backend/llvm/byte-windows.js.map +1 -1
- package/dist/backend/llvm/bytes-alias.d.ts +6 -1
- package/dist/backend/llvm/bytes-alias.js +8 -2
- package/dist/backend/llvm/bytes-alias.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.d.ts +47 -5
- package/dist/backend/llvm/bytes-loop-versions.js +473 -32
- package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +258 -2
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/checked-value-lifetimes.js +2 -0
- package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +7 -5
- package/dist/backend/llvm/classes.js +44 -20
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +167 -7
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +9 -3
- package/dist/backend/llvm/common.js +9 -3
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +2 -1
- package/dist/backend/llvm/constant-callbacks.js +83 -52
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/counted-loops.d.ts +7 -0
- package/dist/backend/llvm/counted-loops.js +18 -0
- package/dist/backend/llvm/counted-loops.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +39 -8
- package/dist/backend/llvm/dense-array-access.js +222 -52
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +36 -0
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.d.ts +17 -1
- package/dist/backend/llvm/dense-array-loops.js +194 -5
- package/dist/backend/llvm/dense-array-loops.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.test.js +90 -1
- package/dist/backend/llvm/dense-array-loops.test.js.map +1 -1
- package/dist/backend/llvm/dyn-handle-tags.test.js +6 -1
- package/dist/backend/llvm/dyn-handle-tags.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +26 -0
- package/dist/backend/llvm/dyn.js +352 -61
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +11 -20
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-journal.d.ts +93 -0
- package/dist/backend/llvm/emit-journal.js +170 -0
- package/dist/backend/llvm/emit-journal.js.map +1 -0
- package/dist/backend/llvm/emit-module.js +195 -27
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-statements.d.ts +0 -4
- package/dist/backend/llvm/emit-statements.js +268 -84
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter-state.d.ts +7 -0
- package/dist/backend/llvm/emitter-state.js +14 -0
- package/dist/backend/llvm/emitter-state.js.map +1 -0
- package/dist/backend/llvm/emitter.d.ts +176 -37
- package/dist/backend/llvm/emitter.js +724 -85
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +54 -5
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +34 -12
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.js +47 -0
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +28 -14
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +14 -2
- package/dist/backend/llvm/expr-containers.js +129 -37
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +14 -0
- package/dist/backend/llvm/expr-dynamic.js +18 -11
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +100 -28
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +11 -6
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +12 -0
- package/dist/backend/llvm/expr-records.js +106 -0
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +2 -2
- package/dist/backend/llvm/expr-stream-bridges.js +194 -65
- 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/expr-stream-bridges.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +2 -2
- package/dist/backend/llvm/expr-stream-callbacks.js +74 -20
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/int32-kind-loops.d.ts +39 -0
- package/dist/backend/llvm/int32-kind-loops.js +106 -0
- package/dist/backend/llvm/int32-kind-loops.js.map +1 -0
- package/dist/backend/llvm/integer-or-nan-indexes.test.d.ts +1 -0
- package/dist/backend/llvm/integer-or-nan-indexes.test.js +118 -0
- package/dist/backend/llvm/integer-or-nan-indexes.test.js.map +1 -0
- package/dist/backend/llvm/integer-values.d.ts +20 -1
- package/dist/backend/llvm/integer-values.js +71 -0
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/js-ic.d.ts +1 -1
- package/dist/backend/llvm/js-ic.js +1 -1
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/key-orders.d.ts +7 -0
- package/dist/backend/llvm/key-orders.js +33 -0
- package/dist/backend/llvm/key-orders.js.map +1 -0
- package/dist/backend/llvm/lib-connect.js +4 -0
- package/dist/backend/llvm/lib-connect.js.map +1 -1
- package/dist/backend/llvm/lib-datagram.js +11 -0
- package/dist/backend/llvm/lib-datagram.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +80 -2
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +4 -4
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.js +4 -0
- package/dist/backend/llvm/lib-http2.js.map +1 -1
- package/dist/backend/llvm/lib-lookup.js +16 -6
- package/dist/backend/llvm/lib-lookup.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +73 -2
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +35 -5
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +115 -19
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +14 -0
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/loop-state.d.ts +33 -0
- package/dist/backend/llvm/loop-state.js +42 -0
- package/dist/backend/llvm/loop-state.js.map +1 -0
- package/dist/backend/llvm/map-number-lookup.d.ts +26 -8
- package/dist/backend/llvm/map-number-lookup.js +91 -31
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +55 -0
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.js +4 -2
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.d.ts +2 -1
- package/dist/backend/llvm/nullable-unions.js +15 -3
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +10 -0
- package/dist/backend/llvm/publish.js +12 -0
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/receivers.js +6 -1
- package/dist/backend/llvm/receivers.js.map +1 -1
- package/dist/backend/llvm/record-results.d.ts +1 -9
- package/dist/backend/llvm/record-results.js +2 -11
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/reference-writes.d.ts +7 -2
- package/dist/backend/llvm/reference-writes.js +89 -72
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/running-extrema.d.ts +11 -0
- package/dist/backend/llvm/running-extrema.js +115 -0
- package/dist/backend/llvm/running-extrema.js.map +1 -0
- package/dist/backend/llvm/running-extrema.test.d.ts +1 -0
- package/dist/backend/llvm/running-extrema.test.js +89 -0
- package/dist/backend/llvm/running-extrema.test.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +71 -15
- package/dist/backend/llvm/shapes.js +222 -33
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +53 -7
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +6 -0
- package/dist/backend/llvm/speculative-integers.js +2 -2
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +3 -2
- package/dist/backend/llvm/stack-objects.js +5 -2
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +12 -0
- package/dist/backend/llvm/string-reads.js +44 -0
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/walk-borrows.d.ts +3 -0
- package/dist/backend/llvm/walk-borrows.js +46 -41
- package/dist/backend/llvm/walk-borrows.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +3 -0
- package/dist/backend/llvm/walkers.js +88 -65
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/llvm/wrapping-sums.d.ts +16 -1
- package/dist/backend/llvm/wrapping-sums.js +126 -0
- package/dist/backend/llvm/wrapping-sums.js.map +1 -1
- package/dist/backend/may-throw.d.ts +8 -10
- package/dist/backend/may-throw.js +14 -10
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +5 -0
- package/dist/backend/native/executable.js +7 -0
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +1 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +4 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/publication.d.ts +12 -1
- package/dist/backend/publication.js +37 -14
- package/dist/backend/publication.js.map +1 -1
- package/dist/backend/publication.test.js +30 -0
- package/dist/backend/publication.test.js.map +1 -1
- package/dist/backend/result-slots.d.ts +16 -0
- package/dist/backend/result-slots.js +23 -0
- package/dist/backend/result-slots.js.map +1 -0
- 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 -0
- package/dist/backend/runtime-pack-core.js +1 -0
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +2 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +2 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/stack-observations.d.ts +2 -1
- package/dist/backend/stack-observations.js +67 -42
- package/dist/backend/stack-observations.js.map +1 -1
- package/dist/backend/target-diagnostics.js +5 -3
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/warm-cache.js +1 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/usage.d.ts +1 -1
- package/dist/cli/usage.js +3 -3
- package/dist/compat/fetch-profile.js +1 -1
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/contracts/check.js +4 -3
- package/dist/contracts/check.js.map +1 -1
- package/dist/contracts/int32-elements.js +10 -2
- package/dist/contracts/int32-elements.js.map +1 -1
- package/dist/coverage/report.js +12 -3
- package/dist/coverage/report.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +4 -0
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +3 -0
- package/dist/diagnostics/envelope.js +1 -0
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +2 -0
- package/dist/executable/executable-cache.js +1 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +1 -0
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/decl-projection.d.ts +41 -0
- package/dist/frontend/decl-projection.js +854 -0
- package/dist/frontend/decl-projection.js.map +1 -0
- package/dist/frontend/decl-projection.test.d.ts +1 -0
- package/dist/frontend/decl-projection.test.js +30 -0
- package/dist/frontend/decl-projection.test.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +15 -0
- package/dist/frontend/dts-paths.js +25 -0
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/input-tracker.d.ts +6 -0
- package/dist/frontend/input-tracker.js +51 -28
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +19 -0
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +100 -2
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.js +46 -15
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.js +13 -2
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.js +84 -9
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/global-namespace-keys.d.ts +3 -0
- package/dist/frontend/lowering/builtins/global-namespace-keys.js +122 -0
- package/dist/frontend/lowering/builtins/global-namespace-keys.js.map +1 -0
- package/dist/frontend/lowering/builtins/numbers.js +9 -1
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.d.ts +6 -0
- package/dist/frontend/lowering/builtins/promises.js +88 -2
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +5 -1
- package/dist/frontend/lowering/builtins/readline.js +35 -3
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +24 -1
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/webassembly.js +6 -3
- package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
- package/dist/frontend/lowering/class-callbacks.d.ts +5 -2
- package/dist/frontend/lowering/class-callbacks.js +82 -12
- package/dist/frontend/lowering/class-callbacks.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +4 -1
- package/dist/frontend/lowering/class-construction.js +17 -3
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +39 -2
- package/dist/frontend/lowering/class-dynamic-dispatch.js +766 -108
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +47 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-iterables.d.ts +2 -1
- package/dist/frontend/lowering/class-iterables.js +9 -1
- package/dist/frontend/lowering/class-iterables.js.map +1 -1
- package/dist/frontend/lowering/class-method-mutations.js +32 -9
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +31 -2
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.d.ts +9 -3
- package/dist/frontend/lowering/class-runtime-statics.js +29 -4
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +48 -1
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +91 -1
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callback-call.js +2 -2
- package/dist/frontend/lowering/containers/array-callback-call.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +338 -18
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-concat.js +10 -0
- package/dist/frontend/lowering/containers/array-concat.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +15 -0
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/array-pipelines.js +19 -8
- package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +2 -1
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.js +3 -0
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +7 -2
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.d.ts +6 -0
- package/dist/frontend/lowering/containers/filter-predicates.js +205 -0
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -0
- package/dist/frontend/lowering/containers/indexed-objects.d.ts +0 -12
- package/dist/frontend/lowering/containers/indexed-objects.js +46 -7
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +55 -9
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.js +43 -19
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
- package/dist/frontend/lowering/dispatch-sites.js +15 -1
- package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
- package/dist/frontend/lowering/divergences.js +9 -1
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/error-methods.js +47 -2
- package/dist/frontend/lowering/error-methods.js.map +1 -1
- package/dist/frontend/lowering/expressions/array-literals.js +47 -0
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +36 -2
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +90 -13
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +33 -4
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.js +95 -1
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +3 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +10 -0
- package/dist/frontend/lowering/expressions/object-literals.js +138 -51
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +12 -0
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.js +113 -11
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +212 -33
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.js +4 -0
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +22 -3
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.d.ts +28 -0
- package/dist/frontend/lowering/frozen-records.js +322 -0
- package/dist/frontend/lowering/frozen-records.js.map +1 -0
- package/dist/frontend/lowering/function-returns.js +49 -0
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.js +7 -2
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/iterable-values.d.ts +49 -0
- package/dist/frontend/lowering/iterable-values.js +297 -0
- package/dist/frontend/lowering/iterable-values.js.map +1 -0
- package/dist/frontend/lowering/iterator-adapters.js +186 -1
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/js-class-fields.d.ts +8 -0
- package/dist/frontend/lowering/js-class-fields.js +45 -10
- package/dist/frontend/lowering/js-class-fields.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.d.ts +18 -3
- package/dist/frontend/lowering/key-order-witness.js +770 -22
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +428 -8
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js +4 -1
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +7 -0
- package/dist/frontend/lowering/lower-calls.js +443 -41
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +11 -2
- package/dist/frontend/lowering/lower-classes.js +302 -22
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +3 -1
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +10 -2
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.d.ts +11 -0
- package/dist/frontend/lowering/lower-functions.js +83 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +41 -31
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.js +6 -3
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +18 -6
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +32 -0
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +5 -1
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +2 -2
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +5 -0
- package/dist/frontend/lowering/lower-stdlib.js +30 -0
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +23 -0
- package/dist/frontend/lowering/lower-stmts.js +454 -48
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +20 -2
- package/dist/frontend/lowering/lower-stream.js +1483 -156
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +77 -6
- package/dist/frontend/lowering/lowerer.js +313 -29
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/module-namespace-elements.d.ts +11 -1
- package/dist/frontend/lowering/module-namespace-elements.js +82 -5
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/new-target.d.ts +12 -0
- package/dist/frontend/lowering/new-target.js +280 -0
- package/dist/frontend/lowering/new-target.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +3 -0
- package/dist/frontend/lowering/surfaces.js +18 -6
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/undefined-index.d.ts +27 -0
- package/dist/frontend/lowering/undefined-index.js +82 -0
- package/dist/frontend/lowering/undefined-index.js.map +1 -0
- package/dist/frontend/lowering/var-hoisting.js +29 -13
- package/dist/frontend/lowering/var-hoisting.js.map +1 -1
- package/dist/frontend/lowering/width-lift.d.ts +18 -0
- package/dist/frontend/npm-static-bundled-chunks.js +9 -11
- package/dist/frontend/npm-static-bundled-chunks.js.map +1 -1
- package/dist/frontend/npm-static-bundled-chunks.test.js +6 -5
- package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +9 -1
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/npm-static.js +4 -20
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/package-shims.d.ts +3 -0
- package/dist/frontend/package-shims.js +71 -8
- package/dist/frontend/package-shims.js.map +1 -1
- package/dist/frontend/pipeline.js +18 -10
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/process-fork.d.ts +25 -0
- package/dist/frontend/process-fork.js +2 -0
- package/dist/frontend/process-fork.js.map +1 -0
- package/dist/frontend/program.d.ts +8 -1
- package/dist/frontend/program.js +484 -69
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +43 -3
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/token-equivalence.d.ts +3 -0
- package/dist/frontend/token-equivalence.js +409 -0
- package/dist/frontend/token-equivalence.js.map +1 -0
- package/dist/frontend/token-equivalence.test.d.ts +1 -0
- package/dist/frontend/token-equivalence.test.js +67 -0
- package/dist/frontend/token-equivalence.test.js.map +1 -0
- package/dist/frontend/ts7/ast-node.d.ts +22 -0
- package/dist/frontend/ts7/ast-node.js +1048 -103
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-node.test.js +24 -0
- package/dist/frontend/ts7/ast-node.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.d.ts +4 -3
- package/dist/frontend/ts7/ast-wire.js +34 -24
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.test.js +23 -0
- package/dist/frontend/ts7/ast-wire.test.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.d.ts +3 -4
- package/dist/frontend/ts7/checker-backend.js +2 -2
- package/dist/frontend/ts7/checker-backend.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.test.js +5 -9
- package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +4 -0
- package/dist/frontend/ts7/checker.js +7 -0
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/lib-diagnostics.d.ts +24 -0
- package/dist/frontend/ts7/lib-diagnostics.js +307 -0
- package/dist/frontend/ts7/lib-diagnostics.js.map +1 -0
- package/dist/frontend/ts7/lib-diagnostics.test.d.ts +1 -0
- package/dist/frontend/ts7/lib-diagnostics.test.js +199 -0
- package/dist/frontend/ts7/lib-diagnostics.test.js.map +1 -0
- package/dist/frontend/ts7/program-host.d.ts +7 -0
- package/dist/frontend/ts7/program-host.js +25 -2
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/session.d.ts +14 -1
- package/dist/frontend/ts7/session.js +22 -0
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +13 -1
- package/dist/frontend/type-mapper.js +191 -11
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.js +5 -3
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/array-length-stability.d.ts +4 -0
- package/dist/ir/array-length-stability.js +19 -6
- package/dist/ir/array-length-stability.js.map +1 -1
- package/dist/ir/array-length-stability.test.js +24 -0
- package/dist/ir/array-length-stability.test.js.map +1 -1
- package/dist/ir/builtin-effects.d.ts +7 -0
- package/dist/ir/builtin-effects.js +52 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +6 -4
- package/dist/ir/builtin-signatures.js +166 -13
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/callback-specialization.d.ts +2 -1
- package/dist/ir/callback-specialization.js +23 -18
- package/dist/ir/callback-specialization.js.map +1 -1
- package/dist/ir/char-unit-locals.d.ts +19 -0
- package/dist/ir/char-unit-locals.js +185 -0
- package/dist/ir/char-unit-locals.js.map +1 -0
- package/dist/ir/char-unit-locals.test.d.ts +1 -0
- package/dist/ir/char-unit-locals.test.js +94 -0
- package/dist/ir/char-unit-locals.test.js.map +1 -0
- package/dist/ir/final-fields.d.ts +2 -1
- package/dist/ir/final-fields.js +14 -16
- package/dist/ir/final-fields.js.map +1 -1
- package/dist/ir/function-references.d.ts +2 -0
- package/dist/ir/function-references.js +2 -0
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +3 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/initializer-bindings.d.ts +2 -1
- package/dist/ir/initializer-bindings.js +27 -20
- package/dist/ir/initializer-bindings.js.map +1 -1
- package/dist/ir/int32-arrays.d.ts +108 -0
- package/dist/ir/int32-arrays.js +831 -0
- package/dist/ir/int32-arrays.js.map +1 -0
- package/dist/ir/int32-slots.d.ts +24 -2
- package/dist/ir/int32-slots.js +259 -57
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/integer-loops.d.ts +3 -3
- package/dist/ir/integer-loops.js +14 -6
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +10 -0
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +5 -0
- package/dist/ir/integer-ranges.js +125 -12
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +30 -0
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +70 -7
- package/dist/ir/ir.js +58 -1
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +21 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/js-ic.d.ts +19 -2
- package/dist/ir/js-ic.js +95 -11
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +188 -0
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/node-index.d.ts +57 -0
- package/dist/ir/node-index.js +215 -0
- package/dist/ir/node-index.js.map +1 -0
- package/dist/ir/paired-while-loops.d.ts +25 -0
- package/dist/ir/paired-while-loops.js +335 -0
- package/dist/ir/paired-while-loops.js.map +1 -0
- package/dist/ir/paired-while-loops.test.d.ts +1 -0
- package/dist/ir/paired-while-loops.test.js +163 -0
- package/dist/ir/paired-while-loops.test.js.map +1 -0
- package/dist/ir/parameter-versions.d.ts +25 -0
- package/dist/ir/parameter-versions.js +300 -0
- package/dist/ir/parameter-versions.js.map +1 -0
- package/dist/ir/runtime-features.d.ts +34 -13
- package/dist/ir/runtime-features.js +152 -38
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/serialize.d.ts +12 -2
- package/dist/ir/serialize.js +16 -3
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.js +17 -0
- package/dist/ir/serialize.test.js.map +1 -1
- package/dist/ir/traverse.js +18 -6
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +122 -36
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/ir-policy.js +2 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/native/cache.d.ts +6 -1
- package/dist/native/cache.js +28 -5
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +16 -2
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +21 -1
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +8 -6
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache.d.ts +1 -1
- package/dist/native/executable-cache.js +2 -2
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.d.ts +3 -1
- package/dist/native/prepare.js +119 -31
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +78 -18
- package/dist/native/prepare.test.js.map +1 -1
- package/dist/native/sanitizer.test.js +2 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/text-file.d.ts +13 -3
- package/dist/native/text-file.js +63 -9
- package/dist/native/text-file.js.map +1 -1
- package/dist/native/text-file.test.d.ts +1 -0
- package/dist/native/text-file.test.js +49 -0
- package/dist/native/text-file.test.js.map +1 -0
- package/dist/native/toolchain.js +4 -4
- package/dist/native/toolchain.js.map +1 -1
- package/dist/native/toolchain.test.js +3 -3
- package/dist/native/toolchain.test.js.map +1 -1
- package/package.json +21 -21
- package/shims/chalk/v5.ts +688 -0
- package/shims/hono-node-server/v2.ts +645 -0
- package/shims/hot-shots/client.ts +1126 -0
- package/shims/hot-shots/v8-unix-dgram.ts +8 -0
- package/shims/hot-shots/v8.ts +8 -0
- package/surface-manifest.json +26 -4
package/dist/frontend/program.js
CHANGED
|
@@ -61,6 +61,7 @@ import { forkTargetPaths } from "./fork-target.js";
|
|
|
61
61
|
import { workerTargetPaths } from "./worker-target.js";
|
|
62
62
|
import { erasedTypeOnlyImport, typeOnlyNamedImport, typeOnlyReachedFiles, } from "./type-only-imports.js";
|
|
63
63
|
import { moduleSourceCandidates } from "./module-source-candidates.js";
|
|
64
|
+
import { planDeclProjection } from "./decl-projection.js";
|
|
64
65
|
import { inferredJsDiagnosticSuppressed } from "./inferred-js-diagnostics.js";
|
|
65
66
|
import { containsJsx, firstJsx, jsxEmitName, jsxEmitPlan, jsxPragmas, lowerJsx, } from "./jsx-source.js";
|
|
66
67
|
const BASE_OPTIONS = {
|
|
@@ -600,7 +601,10 @@ function lowerProgramJsx7(program, options) {
|
|
|
600
601
|
}
|
|
601
602
|
function loadProgram7(host, entryPath, externalTypes = new Map(),
|
|
602
603
|
/** The --npm-static lowering world: root opted-in packages' deep edges. */
|
|
603
|
-
rootNpmStaticEdges = false
|
|
604
|
+
rootNpmStaticEdges = false,
|
|
605
|
+
/** The declaration-typed boundary's projection (decl-projection.ts):
|
|
606
|
+
* answers rewritten user files for the lowering world, or null. */
|
|
607
|
+
projector) {
|
|
604
608
|
const config = adoptProjectConfig7(host, entryPath);
|
|
605
609
|
const configuredPaths = config.options["paths"];
|
|
606
610
|
setProjectPathMappings(configuredPaths !== undefined && typeof configuredPaths === "object" && configuredPaths !== null
|
|
@@ -678,6 +682,7 @@ rootNpmStaticEdges = false) {
|
|
|
678
682
|
// lowering compiles holds them with their JSX lowered.
|
|
679
683
|
const jsx = lowerProgramJsx7(program, options);
|
|
680
684
|
let tscWorld;
|
|
685
|
+
const declBoundaryNotes = [];
|
|
681
686
|
if (jsx.refusal !== null) {
|
|
682
687
|
config.diags.push(jsx.refusal);
|
|
683
688
|
}
|
|
@@ -696,6 +701,57 @@ rootNpmStaticEdges = false) {
|
|
|
696
701
|
host.addVirtualFile(file, lowered.text);
|
|
697
702
|
program = host.createProgram([...programRoots, overridesDtsPath()], options);
|
|
698
703
|
}
|
|
704
|
+
else if (projector !== undefined) {
|
|
705
|
+
// The declaration-typed boundary: user files typed from package
|
|
706
|
+
// declarations (decl-projection.ts). The tsc gate reads the original
|
|
707
|
+
// text; the lowering compiles the rewritten files.
|
|
708
|
+
const projection = projector(program);
|
|
709
|
+
if (projection !== null) {
|
|
710
|
+
const original = program;
|
|
711
|
+
const baseline = new Map();
|
|
712
|
+
for (const file of projection.files.keys()) {
|
|
713
|
+
const sf = original.getSourceFile(file);
|
|
714
|
+
if (sf !== undefined)
|
|
715
|
+
baseline.set(file, original.getSemanticDiagnostics(sf).length);
|
|
716
|
+
}
|
|
717
|
+
for (const [file, text] of projection.files)
|
|
718
|
+
host.addVirtualFile(file, text);
|
|
719
|
+
host.addVirtualFile(projection.declFile, projection.declText);
|
|
720
|
+
programRoots.push(projection.declFile);
|
|
721
|
+
program = host.createProgram([...programRoots, overridesDtsPath()], options);
|
|
722
|
+
// A rewrite the lowering world disagrees with (new errors) is
|
|
723
|
+
// dropped for that file: the file lowers as it would without it.
|
|
724
|
+
const dropped = [];
|
|
725
|
+
for (const file of projection.files.keys()) {
|
|
726
|
+
const sf = program.getSourceFile(file);
|
|
727
|
+
if (sf === undefined)
|
|
728
|
+
continue;
|
|
729
|
+
if (program.getSemanticDiagnostics(sf).length > (baseline.get(file) ?? 0)) {
|
|
730
|
+
dropped.push(file);
|
|
731
|
+
host.addVirtualFile(file, original.getSourceFile(file).text);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
if (dropped.length > 0) {
|
|
735
|
+
program.dispose();
|
|
736
|
+
program = host.createProgram([...programRoots, overridesDtsPath()], options);
|
|
737
|
+
for (const file of dropped)
|
|
738
|
+
declBoundaryNotes.push(declBoundaryDroppedDiag(file));
|
|
739
|
+
}
|
|
740
|
+
if (dropped.length === projection.files.size) {
|
|
741
|
+
program.dispose();
|
|
742
|
+
programRoots.pop();
|
|
743
|
+
program = original;
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
tscWorld = {
|
|
747
|
+
program: original,
|
|
748
|
+
diagnostics: ts.getPreEmitDiagnostics(original),
|
|
749
|
+
projectWorld: null,
|
|
750
|
+
declWorldFallback: true,
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
699
755
|
const entry = program.getSourceFile(entryPath);
|
|
700
756
|
if (!entry)
|
|
701
757
|
throw new Error(`could not load ${entryPath}`);
|
|
@@ -706,6 +762,7 @@ rootNpmStaticEdges = false) {
|
|
|
706
762
|
entry,
|
|
707
763
|
moduleOrder: [],
|
|
708
764
|
configDiags: config.diags,
|
|
765
|
+
...(declBoundaryNotes.length > 0 ? { declBoundaryNotes } : {}),
|
|
709
766
|
typeWorld: {
|
|
710
767
|
nodeFallback: nodeTypes === null,
|
|
711
768
|
projectLib: config.projectLib ?? null,
|
|
@@ -877,25 +934,58 @@ export function loadProgram(entryPath, services, opts) {
|
|
|
877
934
|
hideFile: (path) => (npmShadow?.hideFile(path) ?? false) || projectDtsRuntimeSibling(path) !== null,
|
|
878
935
|
};
|
|
879
936
|
const host = services.createProgramHost({ cwd: dirname(entryPath), fsShadow });
|
|
937
|
+
let authoredHost = null;
|
|
938
|
+
let authoredLoad = null;
|
|
939
|
+
const authored = () => {
|
|
940
|
+
if (!authoredLoad) {
|
|
941
|
+
authoredHost = services.createProgramHost({ cwd: dirname(entryPath) });
|
|
942
|
+
authoredLoad = loadProgram7(authoredHost, entryPath, externalTypes);
|
|
943
|
+
}
|
|
944
|
+
return authoredLoad;
|
|
945
|
+
};
|
|
946
|
+
const declPackages = npmStaticPackages.filter((pkg) => {
|
|
947
|
+
const resolved = resolveBareModule(entryPath, pkg, "types-only");
|
|
948
|
+
return resolved !== null && /\.d\.(?:ts|mts|cts)$/.test(resolved.typesFile);
|
|
949
|
+
});
|
|
950
|
+
const projector = declPackages.length === 0
|
|
951
|
+
? undefined
|
|
952
|
+
: (program) => {
|
|
953
|
+
const userFiles = declBoundaryUserFiles(program, declPackages);
|
|
954
|
+
if (userFiles.length === 0)
|
|
955
|
+
return null;
|
|
956
|
+
let projection;
|
|
957
|
+
try {
|
|
958
|
+
projection = planDeclProjection({
|
|
959
|
+
jsProgram: program,
|
|
960
|
+
declProgram: authored().program,
|
|
961
|
+
userFiles,
|
|
962
|
+
outDir: dirname(entryPath),
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
catch (error) {
|
|
966
|
+
if (process.env["SCRIPTC_DEBUG_DECL_BOUNDARY"] === "1")
|
|
967
|
+
throw error;
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
if (process.env["SCRIPTC_DEBUG_DECL_BOUNDARY"] === "1") {
|
|
971
|
+
process.stderr.write(`[decl-boundary] ${projection === null ? "no projection" : projection.plan.join("\n[decl-boundary] ")}\n`);
|
|
972
|
+
if (projection !== null)
|
|
973
|
+
process.stderr.write(projection.declText);
|
|
974
|
+
}
|
|
975
|
+
return projection;
|
|
976
|
+
};
|
|
880
977
|
try {
|
|
881
|
-
const load = loadProgram7(host, entryPath, externalTypes, npmStaticPackages.length > 0);
|
|
882
|
-
let authoredHost = null;
|
|
883
|
-
let authoredLoad = null;
|
|
978
|
+
const load = loadProgram7(host, entryPath, externalTypes, npmStaticPackages.length > 0, projector);
|
|
884
979
|
return {
|
|
885
980
|
...load,
|
|
886
981
|
services,
|
|
887
982
|
projectWorld: npmStaticPackages.length === 0
|
|
888
983
|
? load.projectWorld
|
|
889
|
-
: () =>
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
authoredHost = services.createProgramHost({ cwd: dirname(entryPath) });
|
|
895
|
-
authoredLoad = loadProgram7(authoredHost, entryPath, externalTypes);
|
|
896
|
-
}
|
|
897
|
-
return authoredLoad.projectWorld();
|
|
898
|
-
},
|
|
984
|
+
: () =>
|
|
985
|
+
// Check authored code against the package's published declarations.
|
|
986
|
+
// Runtime bodies still lower from JavaScript in the original world;
|
|
987
|
+
// inference there must not manufacture errors in valid user code.
|
|
988
|
+
authored().projectWorld(),
|
|
899
989
|
dispose: () => {
|
|
900
990
|
try {
|
|
901
991
|
authoredLoad?.disposeAll();
|
|
@@ -913,10 +1003,39 @@ export function loadProgram(entryPath, services, opts) {
|
|
|
913
1003
|
};
|
|
914
1004
|
}
|
|
915
1005
|
catch (error) {
|
|
1006
|
+
authoredLoad?.disposeAll();
|
|
1007
|
+
authoredHost?.close();
|
|
916
1008
|
host.close();
|
|
917
1009
|
throw error;
|
|
918
1010
|
}
|
|
919
1011
|
}
|
|
1012
|
+
/** User TypeScript files (outside node_modules) that import one of the
|
|
1013
|
+
* packages whose declarations the boundary projects from. */
|
|
1014
|
+
function declBoundaryUserFiles(program, packages) {
|
|
1015
|
+
const out = [];
|
|
1016
|
+
for (const sf of program.getSourceFiles()) {
|
|
1017
|
+
const name = sf.fileName.split("\\").join("/");
|
|
1018
|
+
if (sf.isDeclarationFile || name.includes("/node_modules/") || !/\.[mc]?tsx?$/.test(name))
|
|
1019
|
+
continue;
|
|
1020
|
+
if (name.endsWith(".tsx"))
|
|
1021
|
+
continue; // JSX files: not projected yet
|
|
1022
|
+
const text = sf.text;
|
|
1023
|
+
if (packages.some((pkg) => text.includes(`"${pkg}"`) ||
|
|
1024
|
+
text.includes(`'${pkg}'`) ||
|
|
1025
|
+
text.includes(`"${pkg}/`) ||
|
|
1026
|
+
text.includes(`'${pkg}/`)))
|
|
1027
|
+
out.push(sf.fileName);
|
|
1028
|
+
}
|
|
1029
|
+
return out;
|
|
1030
|
+
}
|
|
1031
|
+
/** SC6102 — a projected file the lowering world disagreed with. */
|
|
1032
|
+
function declBoundaryDroppedDiag(file) {
|
|
1033
|
+
return {
|
|
1034
|
+
code: "SC6102",
|
|
1035
|
+
message: "values from npm packages stay checked-dynamic in this file: the types projected from the packages' declarations do not type-check against their JavaScript",
|
|
1036
|
+
loc: { file, start: 0, end: 0 },
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
920
1039
|
/** tsc diagnostics (syntax + types), the supported-import fence, and the
|
|
921
1040
|
* module evaluation order: fills load.moduleOrder (the SourceFiles
|
|
922
1041
|
* themselves — the lowering consumes them directly) and returns the
|
|
@@ -1023,8 +1142,17 @@ function requiresOf7(stmt) {
|
|
|
1023
1142
|
}
|
|
1024
1143
|
return out;
|
|
1025
1144
|
}
|
|
1145
|
+
/** `true`, or `!0`, its minified spelling. */
|
|
1146
|
+
function isTrueLiteral(expr) {
|
|
1147
|
+
return (expr.kind === ts.SyntaxKind.TrueKeyword ||
|
|
1148
|
+
(ts.isPrefixUnaryExpression(expr) &&
|
|
1149
|
+
expr.operator === ts.SyntaxKind.ExclamationToken &&
|
|
1150
|
+
ts.isNumericLiteral(expr.operand) &&
|
|
1151
|
+
expr.operand.text === "0"));
|
|
1152
|
+
}
|
|
1026
1153
|
/** The exact `Object.defineProperty(exports|module.exports, "__esModule",
|
|
1027
|
-
* { value: true })` interop stamp (shared by preflight and the no-op lowering)
|
|
1154
|
+
* { value: true })` interop stamp (shared by preflight and the no-op lowering);
|
|
1155
|
+
* `{ value: !0 }` is the same stamp. */
|
|
1028
1156
|
export function isEsModuleStamp(expr) {
|
|
1029
1157
|
if (!ts.isCallExpression(expr) || expr.questionDotToken !== undefined)
|
|
1030
1158
|
return false;
|
|
@@ -1055,7 +1183,7 @@ export function isEsModuleStamp(expr) {
|
|
|
1055
1183
|
return (ts.isPropertyAssignment(p) &&
|
|
1056
1184
|
ts.isIdentifier(p.name) &&
|
|
1057
1185
|
p.name.text === "value" &&
|
|
1058
|
-
p.initializer
|
|
1186
|
+
isTrueLiteral(p.initializer));
|
|
1059
1187
|
}
|
|
1060
1188
|
/** Plain CommonJS prologue writes only publish values; in particular,
|
|
1061
1189
|
* publishing a hoisted function does not invoke its body. Later runnable
|
|
@@ -3362,6 +3490,7 @@ function computeCycleEarlyBindings7(program, entry, order, singleRoot, exact) {
|
|
|
3362
3490
|
start: ts.tokenStartOfNode(stmt),
|
|
3363
3491
|
end: stmt.end,
|
|
3364
3492
|
reference: null,
|
|
3493
|
+
deferredReference: null,
|
|
3365
3494
|
folded: null,
|
|
3366
3495
|
localNames: new Map(),
|
|
3367
3496
|
});
|
|
@@ -3438,10 +3567,13 @@ function computeCycleEarlyBindings7(program, entry, order, singleRoot, exact) {
|
|
|
3438
3567
|
ts.tokenStartOfNode(ref) >= c.start &&
|
|
3439
3568
|
ref.end <= c.end)
|
|
3440
3569
|
continue;
|
|
3570
|
+
if (inDeferredPosition7(ref)) {
|
|
3571
|
+
if (c.exposed && c.deferredReference === null)
|
|
3572
|
+
c.deferredReference = ref;
|
|
3573
|
+
continue;
|
|
3574
|
+
}
|
|
3441
3575
|
let early;
|
|
3442
|
-
if (
|
|
3443
|
-
early = c.exposed;
|
|
3444
|
-
else if (sf === c.module)
|
|
3576
|
+
if (sf === c.module)
|
|
3445
3577
|
early = ts.tokenStartOfNode(ref) < c.start;
|
|
3446
3578
|
else if (!memberSet.has(sf) || !rankOf.has(sf))
|
|
3447
3579
|
early = false;
|
|
@@ -3451,7 +3583,15 @@ function computeCycleEarlyBindings7(program, entry, order, singleRoot, exact) {
|
|
|
3451
3583
|
c.reference = ref;
|
|
3452
3584
|
}
|
|
3453
3585
|
}
|
|
3586
|
+
// With a static evaluation order, a deferred reference only runs early
|
|
3587
|
+
// when the code that runs before the declaration completes can reach
|
|
3588
|
+
// the function holding it.
|
|
3589
|
+
const reached = known && [...candidates.values()].some((c) => c.reference === null && c.deferredReference)
|
|
3590
|
+
? cycleReachedDeferredReferences7(program, evaluation, candidates)
|
|
3591
|
+
: null;
|
|
3454
3592
|
for (const c of candidates.values()) {
|
|
3593
|
+
if (c.reference === null && c.deferredReference !== null)
|
|
3594
|
+
c.reference = reached === null ? c.deferredReference : (reached.get(c.symbol) ?? null);
|
|
3455
3595
|
if (c.reference === null)
|
|
3456
3596
|
continue;
|
|
3457
3597
|
const settled = new Set(order.filter((sf) => !rankOf.has(sf)));
|
|
@@ -3472,6 +3612,292 @@ function computeCycleEarlyBindings7(program, entry, order, singleRoot, exact) {
|
|
|
3472
3612
|
}
|
|
3473
3613
|
return out;
|
|
3474
3614
|
}
|
|
3615
|
+
/** Collects into `units` the callables an initializer expression stores
|
|
3616
|
+
* (see moduleEarlyBindingsOf7), recording in `immediate` the parts of a
|
|
3617
|
+
* stored node that run where it is evaluated. */
|
|
3618
|
+
function storedCallables7(checker, e, units, immediate) {
|
|
3619
|
+
while (ts.isParenthesizedExpression(e) ||
|
|
3620
|
+
ts.isAsExpression(e) ||
|
|
3621
|
+
ts.isSatisfiesExpression(e) ||
|
|
3622
|
+
ts.isNonNullExpression(e))
|
|
3623
|
+
e = e.expression;
|
|
3624
|
+
if (ts.isArrowFunction(e) || ts.isFunctionExpression(e)) {
|
|
3625
|
+
units.push(e);
|
|
3626
|
+
}
|
|
3627
|
+
else if (ts.isClassExpression(e)) {
|
|
3628
|
+
units.push(e);
|
|
3629
|
+
immediate.set(e, classSyncParts7(e));
|
|
3630
|
+
}
|
|
3631
|
+
else if (ts.isObjectLiteralExpression(e)) {
|
|
3632
|
+
for (const p of e.properties.nodes) {
|
|
3633
|
+
if (ts.isMethodDeclaration(p) ||
|
|
3634
|
+
ts.isGetAccessorDeclaration(p) ||
|
|
3635
|
+
ts.isSetAccessorDeclaration(p)) {
|
|
3636
|
+
// A computed key evaluates where the literal does; a plain
|
|
3637
|
+
// member-chain key (`[Equal.symbol]`) runs no user code.
|
|
3638
|
+
if (!ts.isComputedPropertyName(p.name))
|
|
3639
|
+
units.push(p);
|
|
3640
|
+
else if (memberChainKey7(p.name.expression)) {
|
|
3641
|
+
units.push(p);
|
|
3642
|
+
immediate.set(p, [p.name]);
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
else if (ts.isPropertyAssignment(p))
|
|
3646
|
+
storedCallables7(checker, p.initializer, units, immediate);
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
else if (ts.isArrayLiteralExpression(e)) {
|
|
3650
|
+
for (const el of e.elements.nodes)
|
|
3651
|
+
if (!ts.isSpreadElement(el))
|
|
3652
|
+
storedCallables7(checker, el, units, immediate);
|
|
3653
|
+
}
|
|
3654
|
+
else if (ts.isCallExpression(e)) {
|
|
3655
|
+
// `const f = wrap(callback)` where wrap only returns closures over
|
|
3656
|
+
// the callback: it runs when the stored result is called.
|
|
3657
|
+
e.arguments.nodes.forEach((arg, index) => {
|
|
3658
|
+
let fn = arg;
|
|
3659
|
+
while (ts.isParenthesizedExpression(fn))
|
|
3660
|
+
fn = fn.expression;
|
|
3661
|
+
if ((ts.isArrowFunction(fn) || ts.isFunctionExpression(fn)) &&
|
|
3662
|
+
returnsOnlyClosuresOver7(checker, e.expression, index))
|
|
3663
|
+
units.push(fn);
|
|
3664
|
+
});
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
/** For one import cycle with a static evaluation order: the first deferred
|
|
3668
|
+
* reference to each candidate that code running before the candidate's
|
|
3669
|
+
* declaration completes can reach, or null when the walk cannot be precise
|
|
3670
|
+
* (top-level await, a default-exported function or class declaration).
|
|
3671
|
+
*
|
|
3672
|
+
* The cycle's top-level code runs in evaluation order. A stored callable
|
|
3673
|
+
* (a function or class declaration, or a function, class or object-literal
|
|
3674
|
+
* method stored by a variable initializer) becomes reachable once
|
|
3675
|
+
* reachable code names its binding, through an import alias or a
|
|
3676
|
+
* namespace member too; every other function-like in reachable code counts
|
|
3677
|
+
* as reachable, since it may be handed to a callee. A namespace import of
|
|
3678
|
+
* a cycle member used other than for a member read makes every stored
|
|
3679
|
+
* callable reachable. moduleEarlyBindingsOf7 is the single-module form. */
|
|
3680
|
+
function cycleReachedDeferredReferences7(program, evaluation, candidates) {
|
|
3681
|
+
const checker = program.getTypeChecker();
|
|
3682
|
+
const members = new Set(evaluation);
|
|
3683
|
+
for (const sf of evaluation) {
|
|
3684
|
+
if (hasTopLevelAwait7(sf))
|
|
3685
|
+
return null;
|
|
3686
|
+
for (const stmt of sf.statements.nodes) {
|
|
3687
|
+
if ((ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) &&
|
|
3688
|
+
(ts.getCombinedModifierFlags(stmt) &
|
|
3689
|
+
ts.ModifierFlags.Default) !==
|
|
3690
|
+
0)
|
|
3691
|
+
return null;
|
|
3692
|
+
}
|
|
3693
|
+
}
|
|
3694
|
+
const stored = new Set();
|
|
3695
|
+
const immediate = new Map();
|
|
3696
|
+
const storedNames = [];
|
|
3697
|
+
const unitsOfName = new Map();
|
|
3698
|
+
const store = (name, units) => {
|
|
3699
|
+
if (units.length === 0)
|
|
3700
|
+
return;
|
|
3701
|
+
for (const u of units)
|
|
3702
|
+
stored.add(u);
|
|
3703
|
+
storedNames.push(name);
|
|
3704
|
+
unitsOfName.set(name, units);
|
|
3705
|
+
};
|
|
3706
|
+
for (const sf of evaluation) {
|
|
3707
|
+
for (const stmt of sf.statements.nodes) {
|
|
3708
|
+
if ((ts.getCombinedModifierFlags(stmt) &
|
|
3709
|
+
ts.ModifierFlags.Ambient) !==
|
|
3710
|
+
0)
|
|
3711
|
+
continue;
|
|
3712
|
+
if (ts.isFunctionDeclaration(stmt) && stmt.name !== undefined && stmt.body !== undefined) {
|
|
3713
|
+
store(stmt.name, [stmt]);
|
|
3714
|
+
}
|
|
3715
|
+
else if (ts.isClassDeclaration(stmt) && stmt.name !== undefined) {
|
|
3716
|
+
store(stmt.name, [stmt]);
|
|
3717
|
+
}
|
|
3718
|
+
else if (ts.isVariableStatement(stmt)) {
|
|
3719
|
+
for (const d of stmt.declarationList.declarations.nodes) {
|
|
3720
|
+
if (ts.isIdentifier(d.name) && d.initializer !== undefined) {
|
|
3721
|
+
const units = [];
|
|
3722
|
+
storedCallables7(checker, d.initializer, units, immediate);
|
|
3723
|
+
store(d.name, units);
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
const unitsBySymbol = new Map();
|
|
3730
|
+
const allUnits = [];
|
|
3731
|
+
for (const name of storedNames) {
|
|
3732
|
+
const symbol = checker.getSymbolAtLocation(name);
|
|
3733
|
+
if (symbol === undefined)
|
|
3734
|
+
continue;
|
|
3735
|
+
const units = unitsOfName.get(name);
|
|
3736
|
+
unitsBySymbol.set(symbol, [...(unitsBySymbol.get(symbol) ?? []), ...units]);
|
|
3737
|
+
allUnits.push(...units);
|
|
3738
|
+
}
|
|
3739
|
+
// A named class expression's inner name (`class Impl { static x =
|
|
3740
|
+
// Impl.m(); }`) names the class inside its own body, as the binding it
|
|
3741
|
+
// is stored in names it outside.
|
|
3742
|
+
const innerNames = [];
|
|
3743
|
+
for (const unit of allUnits) {
|
|
3744
|
+
if (!ts.isClassExpression(unit) || unit.name === undefined)
|
|
3745
|
+
continue;
|
|
3746
|
+
const symbol = checker.getSymbolAtLocation(unit.name);
|
|
3747
|
+
if (symbol === undefined)
|
|
3748
|
+
continue;
|
|
3749
|
+
innerNames.push(unit.name);
|
|
3750
|
+
unitsBySymbol.set(symbol, [...(unitsBySymbol.get(symbol) ?? []), unit]);
|
|
3751
|
+
}
|
|
3752
|
+
// The identifier texts worth resolving: declared names, and the local
|
|
3753
|
+
// names of imports (named, default and namespace) in cycle members.
|
|
3754
|
+
const names = new Set();
|
|
3755
|
+
for (const c of candidates.values())
|
|
3756
|
+
names.add(c.name.text);
|
|
3757
|
+
for (const name of storedNames)
|
|
3758
|
+
names.add(name.text);
|
|
3759
|
+
for (const name of innerNames)
|
|
3760
|
+
names.add(name.text);
|
|
3761
|
+
for (const sf of evaluation) {
|
|
3762
|
+
for (const stmt of sf.statements.nodes) {
|
|
3763
|
+
if (!ts.isImportDeclaration(stmt) || stmt.importClause === undefined)
|
|
3764
|
+
continue;
|
|
3765
|
+
const clause = stmt.importClause;
|
|
3766
|
+
if (clause.name !== undefined)
|
|
3767
|
+
names.add(clause.name.text);
|
|
3768
|
+
const bindings = clause.namedBindings;
|
|
3769
|
+
if (bindings === undefined)
|
|
3770
|
+
continue;
|
|
3771
|
+
if (ts.isNamedImports(bindings))
|
|
3772
|
+
for (const element of bindings.elements.nodes)
|
|
3773
|
+
names.add(element.name.text);
|
|
3774
|
+
else
|
|
3775
|
+
names.add(bindings.name.text);
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
const idents = [];
|
|
3779
|
+
for (const sf of evaluation) {
|
|
3780
|
+
ts.walkPreorder(sf, (node) => {
|
|
3781
|
+
if (ts.isImportDeclaration(node))
|
|
3782
|
+
return "skip";
|
|
3783
|
+
if (ts.isIdentifier(node) && names.has(node.text))
|
|
3784
|
+
idents.push(node);
|
|
3785
|
+
return undefined;
|
|
3786
|
+
});
|
|
3787
|
+
}
|
|
3788
|
+
checker.prefetchSymbolNodesExact(idents);
|
|
3789
|
+
const symbolOf = (id) => {
|
|
3790
|
+
const parent = id.parent;
|
|
3791
|
+
let symbol = checker.getSymbolAtLocation(id);
|
|
3792
|
+
if (parent !== undefined && ts.isShorthandPropertyAssignment(parent) && parent.name === id) {
|
|
3793
|
+
symbol = checker.getShorthandAssignmentValueSymbol(parent) ?? symbol;
|
|
3794
|
+
}
|
|
3795
|
+
if (symbol !== undefined && symbol.flags & ts.SymbolFlags.Alias) {
|
|
3796
|
+
symbol = checker.getAliasedSymbol(symbol);
|
|
3797
|
+
}
|
|
3798
|
+
return symbol;
|
|
3799
|
+
};
|
|
3800
|
+
const isMemberNamespace = (symbol) => (symbol.flags & ts.SymbolFlags.ValueModule) !== 0 &&
|
|
3801
|
+
symbol.declarations.some((d) => ts.isSourceFile(d) && members.has(d));
|
|
3802
|
+
const declared = new Set();
|
|
3803
|
+
const reachedUnits = new Set();
|
|
3804
|
+
const out = new Map();
|
|
3805
|
+
const work = [];
|
|
3806
|
+
const reach = (unit) => {
|
|
3807
|
+
if (reachedUnits.has(unit))
|
|
3808
|
+
return;
|
|
3809
|
+
reachedUnits.add(unit);
|
|
3810
|
+
work.push(unit);
|
|
3811
|
+
};
|
|
3812
|
+
const visit = (root) => {
|
|
3813
|
+
ts.walkPreorder(root, (node) => {
|
|
3814
|
+
if (node !== root && stored.has(node)) {
|
|
3815
|
+
for (const part of immediate.get(node) ?? [])
|
|
3816
|
+
visit(part);
|
|
3817
|
+
return "skip";
|
|
3818
|
+
}
|
|
3819
|
+
if (ts.isImportDeclaration(node))
|
|
3820
|
+
return "skip";
|
|
3821
|
+
if (node.kind === ts.SyntaxKind.ThisKeyword) {
|
|
3822
|
+
// `this` in a static initializer or block names the class, so it
|
|
3823
|
+
// reaches the class's methods as naming the class does.
|
|
3824
|
+
const owner = staticThisClass7(node);
|
|
3825
|
+
if (owner !== undefined && stored.has(owner))
|
|
3826
|
+
reach(owner);
|
|
3827
|
+
return undefined;
|
|
3828
|
+
}
|
|
3829
|
+
if (!ts.isIdentifier(node) || !names.has(node.text))
|
|
3830
|
+
return undefined;
|
|
3831
|
+
if (inTypePosition7(node))
|
|
3832
|
+
return undefined;
|
|
3833
|
+
const parent = node.parent;
|
|
3834
|
+
if (parent !== undefined && ts.isExportSpecifier(parent))
|
|
3835
|
+
return undefined;
|
|
3836
|
+
if (parent !== undefined && declaredName7(parent) === node)
|
|
3837
|
+
return undefined;
|
|
3838
|
+
const symbol = symbolOf(node);
|
|
3839
|
+
if (symbol === undefined)
|
|
3840
|
+
return undefined;
|
|
3841
|
+
if (isMemberNamespace(symbol)) {
|
|
3842
|
+
// `ns.member` resolves through the member's own identifier; any
|
|
3843
|
+
// other use can reach every export.
|
|
3844
|
+
if (!(parent !== undefined &&
|
|
3845
|
+
ts.isPropertyAccessExpression(parent) &&
|
|
3846
|
+
parent.expression === node))
|
|
3847
|
+
for (const unit of allUnits)
|
|
3848
|
+
reach(unit);
|
|
3849
|
+
return undefined;
|
|
3850
|
+
}
|
|
3851
|
+
const c = candidates.get(symbol);
|
|
3852
|
+
if (c !== undefined &&
|
|
3853
|
+
node !== c.name &&
|
|
3854
|
+
!declared.has(symbol) &&
|
|
3855
|
+
!out.has(symbol) &&
|
|
3856
|
+
inDeferredPosition7(node) &&
|
|
3857
|
+
!(c.kind === "class" &&
|
|
3858
|
+
ts.getSourceFileOfNode(node) === c.module &&
|
|
3859
|
+
ts.tokenStartOfNode(node) >= c.start &&
|
|
3860
|
+
node.end <= c.end))
|
|
3861
|
+
out.set(symbol, node);
|
|
3862
|
+
for (const unit of unitsBySymbol.get(symbol) ?? [])
|
|
3863
|
+
reach(unit);
|
|
3864
|
+
return undefined;
|
|
3865
|
+
});
|
|
3866
|
+
};
|
|
3867
|
+
const drain = () => {
|
|
3868
|
+
while (work.length > 0)
|
|
3869
|
+
visit(work.pop());
|
|
3870
|
+
};
|
|
3871
|
+
const declare = (name) => {
|
|
3872
|
+
for (const id of boundNames7(name)) {
|
|
3873
|
+
const symbol = checker.getSymbolAtLocation(id);
|
|
3874
|
+
if (symbol !== undefined)
|
|
3875
|
+
declared.add(symbol);
|
|
3876
|
+
}
|
|
3877
|
+
};
|
|
3878
|
+
for (const sf of evaluation) {
|
|
3879
|
+
for (const stmt of sf.statements.nodes) {
|
|
3880
|
+
if (ts.isClassDeclaration(stmt)) {
|
|
3881
|
+
for (const part of classSyncParts7(stmt))
|
|
3882
|
+
visit(part);
|
|
3883
|
+
drain();
|
|
3884
|
+
if (stmt.name !== undefined)
|
|
3885
|
+
declare(stmt.name);
|
|
3886
|
+
}
|
|
3887
|
+
else if (ts.isVariableStatement(stmt)) {
|
|
3888
|
+
for (const d of stmt.declarationList.declarations.nodes) {
|
|
3889
|
+
visit(d);
|
|
3890
|
+
drain();
|
|
3891
|
+
declare(d.name);
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
else if (!ts.isFunctionDeclaration(stmt))
|
|
3895
|
+
visit(stmt);
|
|
3896
|
+
drain();
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
return out;
|
|
3900
|
+
}
|
|
3475
3901
|
/** Top-level let/const and class bindings, in modules outside the
|
|
3476
3902
|
* exactly-initialized cycles, that code running before their declaration
|
|
3477
3903
|
* completes can read.
|
|
@@ -3523,55 +3949,7 @@ function moduleEarlyBindingsOf7(program, sf, order) {
|
|
|
3523
3949
|
storedBy.set(name.text, list);
|
|
3524
3950
|
};
|
|
3525
3951
|
const checker = program.getTypeChecker();
|
|
3526
|
-
const storedIn = (e, units) =>
|
|
3527
|
-
while (ts.isParenthesizedExpression(e) ||
|
|
3528
|
-
ts.isAsExpression(e) ||
|
|
3529
|
-
ts.isSatisfiesExpression(e) ||
|
|
3530
|
-
ts.isNonNullExpression(e))
|
|
3531
|
-
e = e.expression;
|
|
3532
|
-
if (ts.isArrowFunction(e) || ts.isFunctionExpression(e)) {
|
|
3533
|
-
units.push(e);
|
|
3534
|
-
}
|
|
3535
|
-
else if (ts.isClassExpression(e)) {
|
|
3536
|
-
units.push(e);
|
|
3537
|
-
immediate.set(e, classSyncParts7(e));
|
|
3538
|
-
}
|
|
3539
|
-
else if (ts.isObjectLiteralExpression(e)) {
|
|
3540
|
-
for (const p of e.properties.nodes) {
|
|
3541
|
-
if (ts.isMethodDeclaration(p) ||
|
|
3542
|
-
ts.isGetAccessorDeclaration(p) ||
|
|
3543
|
-
ts.isSetAccessorDeclaration(p)) {
|
|
3544
|
-
// A computed key evaluates where the literal does; a plain
|
|
3545
|
-
// member-chain key (`[Equal.symbol]`) runs no user code.
|
|
3546
|
-
if (!ts.isComputedPropertyName(p.name))
|
|
3547
|
-
units.push(p);
|
|
3548
|
-
else if (memberChainKey7(p.name.expression)) {
|
|
3549
|
-
units.push(p);
|
|
3550
|
-
immediate.set(p, [p.name]);
|
|
3551
|
-
}
|
|
3552
|
-
}
|
|
3553
|
-
else if (ts.isPropertyAssignment(p))
|
|
3554
|
-
storedIn(p.initializer, units);
|
|
3555
|
-
}
|
|
3556
|
-
}
|
|
3557
|
-
else if (ts.isArrayLiteralExpression(e)) {
|
|
3558
|
-
for (const el of e.elements.nodes)
|
|
3559
|
-
if (!ts.isSpreadElement(el))
|
|
3560
|
-
storedIn(el, units);
|
|
3561
|
-
}
|
|
3562
|
-
else if (ts.isCallExpression(e)) {
|
|
3563
|
-
// `const f = wrap(callback)` where wrap only returns closures over
|
|
3564
|
-
// the callback: it runs when the stored result is called.
|
|
3565
|
-
e.arguments.nodes.forEach((arg, index) => {
|
|
3566
|
-
let fn = arg;
|
|
3567
|
-
while (ts.isParenthesizedExpression(fn))
|
|
3568
|
-
fn = fn.expression;
|
|
3569
|
-
if ((ts.isArrowFunction(fn) || ts.isFunctionExpression(fn)) &&
|
|
3570
|
-
returnsOnlyClosuresOver7(checker, e.expression, index))
|
|
3571
|
-
units.push(fn);
|
|
3572
|
-
});
|
|
3573
|
-
}
|
|
3574
|
-
};
|
|
3952
|
+
const storedIn = (e, units) => storedCallables7(checker, e, units, immediate);
|
|
3575
3953
|
sf.statements.nodes.forEach((stmt, index) => {
|
|
3576
3954
|
if (ambient(stmt))
|
|
3577
3955
|
return;
|
|
@@ -3853,6 +4231,41 @@ function returnsOnlyClosuresOver7(checker, callee, index) {
|
|
|
3853
4231
|
* expressions, decorators, computed member keys, static field
|
|
3854
4232
|
* initializers and static blocks. Methods and instance fields wait for a
|
|
3855
4233
|
* call or a construction. */
|
|
4234
|
+
/** The class whose static field initializer or static block evaluates `this`
|
|
4235
|
+
* (through arrow functions, which keep the enclosing `this`), or undefined
|
|
4236
|
+
* when another function or a class's instance side binds it. */
|
|
4237
|
+
function staticThisClass7(node) {
|
|
4238
|
+
let child = node;
|
|
4239
|
+
for (let n = node.parent; n !== undefined; child = n, n = n.parent) {
|
|
4240
|
+
if (ts.isArrowFunction(n))
|
|
4241
|
+
continue;
|
|
4242
|
+
if (ts.isClassStaticBlockDeclaration(n))
|
|
4243
|
+
return n.parent;
|
|
4244
|
+
if (ts.isPropertyDeclaration(n)) {
|
|
4245
|
+
if (n.initializer !== child)
|
|
4246
|
+
return undefined;
|
|
4247
|
+
return (ts.getCombinedModifierFlags(n) & ts.ModifierFlags.Static) !== 0
|
|
4248
|
+
? n.parent
|
|
4249
|
+
: undefined;
|
|
4250
|
+
}
|
|
4251
|
+
if (ts.isComputedPropertyName(n)) {
|
|
4252
|
+
// A computed key evaluates in the scope around the class.
|
|
4253
|
+
const member = n.parent;
|
|
4254
|
+
const cls = member?.parent;
|
|
4255
|
+
if (cls === undefined)
|
|
4256
|
+
return undefined;
|
|
4257
|
+
child = cls;
|
|
4258
|
+
n = cls;
|
|
4259
|
+
continue;
|
|
4260
|
+
}
|
|
4261
|
+
if (ts.isFunctionLike(n) ||
|
|
4262
|
+
ts.isClassDeclaration(n) ||
|
|
4263
|
+
ts.isClassExpression(n) ||
|
|
4264
|
+
ts.isSourceFile(n))
|
|
4265
|
+
return undefined;
|
|
4266
|
+
}
|
|
4267
|
+
return undefined;
|
|
4268
|
+
}
|
|
3856
4269
|
function classSyncParts7(c) {
|
|
3857
4270
|
const decorators = (n) => (n.modifiers?.nodes ?? []).filter((m) => m.kind === ts.SyntaxKind.Decorator);
|
|
3858
4271
|
const parts = [...decorators(c), ...(c.heritageClauses?.nodes ?? [])];
|
|
@@ -4356,7 +4769,9 @@ function preflight7(load) {
|
|
|
4356
4769
|
const tscWorld = load.tscWorld;
|
|
4357
4770
|
const tscErrors = tscWorld === undefined ? errorsOf(program) : keptErrors(tscWorld.program, tscWorld.diagnostics);
|
|
4358
4771
|
if (tscErrors.length > 0) {
|
|
4359
|
-
const world = tscWorld === undefined
|
|
4772
|
+
const world = tscWorld === undefined || tscWorld.declWorldFallback === true
|
|
4773
|
+
? load.projectWorld()
|
|
4774
|
+
: (tscWorld.projectWorld ?? tscWorld.program);
|
|
4360
4775
|
for (const d of errorsOf(world)) {
|
|
4361
4776
|
const diag = toPassthrough(d);
|
|
4362
4777
|
const lowered = tscWorld === undefined ? undefined : load.jsxSources?.get(diag.loc.file);
|