@scriptc/compiler 0.4.2 → 0.4.4
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 +470 -66
- 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 +479 -32
- package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +263 -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/debug-info.js +2 -5
- package/dist/backend/llvm/debug-info.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 +30 -0
- package/dist/backend/llvm/dyn.js +373 -70
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +13 -28
- 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 +211 -33
- 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 +186 -37
- package/dist/backend/llvm/emitter.js +733 -90
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +65 -7
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +11 -13
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +48 -20
- 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 +143 -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 +119 -38
- 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 +210 -69
- 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 +25 -1
- package/dist/backend/llvm/integer-values.js +95 -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 +213 -5
- 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-process.js +37 -1
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +94 -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 +15 -3
- 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-effects.js +3 -0
- package/dist/backend/llvm/reference-effects.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 +224 -40
- 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-captures.js +1 -5
- package/dist/backend/llvm/stack-captures.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/union-repr.d.ts +4 -3
- package/dist/backend/llvm/union-repr.js +6 -5
- package/dist/backend/llvm/union-repr.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 +101 -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-codegen-core.d.ts +5 -3
- package/dist/backend/native-codegen-core.js +13 -6
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.test.js +6 -4
- package/dist/backend/native-codegen.test.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-cpu.d.ts +26 -0
- package/dist/backend/target-cpu.js +98 -0
- package/dist/backend/target-cpu.js.map +1 -0
- package/dist/backend/target-cpu.test.d.ts +1 -0
- package/dist/backend/target-cpu.test.js +38 -0
- package/dist/backend/target-cpu.test.js.map +1 -0
- 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/command.js +20 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/usage.d.ts +4 -1
- package/dist/cli/usage.js +10 -3
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.js +1 -1
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +7 -0
- 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 +1 -1
- 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 +5 -0
- package/dist/executable/executable-cache.js +5 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +3 -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 +949 -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/async-context.d.ts +8 -2
- package/dist/frontend/lowering/builtins/async-context.js +62 -3
- package/dist/frontend/lowering/builtins/async-context.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 +87 -10
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.js +4 -1
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.js +3 -3
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/fs-glob.js +6 -3
- package/dist/frontend/lowering/builtins/fs-glob.js.map +1 -1
- package/dist/frontend/lowering/builtins/fs-paths.d.ts +43 -5
- package/dist/frontend/lowering/builtins/fs-paths.js +245 -93
- package/dist/frontend/lowering/builtins/fs-paths.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/module-calls.js +6 -3
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- 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 +7 -1
- package/dist/frontend/lowering/builtins/promises.js +236 -139
- 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/call-signatures.js +0 -1
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
- package/dist/frontend/lowering/cjs-inline-require.d.ts +32 -0
- package/dist/frontend/lowering/cjs-inline-require.js +307 -4
- package/dist/frontend/lowering/cjs-inline-require.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 +49 -2
- package/dist/frontend/lowering/class-dynamic-dispatch.js +880 -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 +83 -24
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +25 -0
- package/dist/frontend/lowering/class-protocols.js +183 -1
- package/dist/frontend/lowering/class-protocols.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/completion-callbacks.d.ts +4 -0
- package/dist/frontend/lowering/completion-callbacks.js +146 -0
- package/dist/frontend/lowering/completion-callbacks.js.map +1 -0
- 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.d.ts +5 -4
- package/dist/frontend/lowering/containers/array-callbacks.js +345 -24
- 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-construction.js +5 -0
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +26 -3
- 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.d.ts +25 -17
- package/dist/frontend/lowering/containers/bytes.js +455 -46
- 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/date-values.d.ts +11 -0
- package/dist/frontend/lowering/date-values.js +207 -0
- package/dist/frontend/lowering/date-values.js.map +1 -0
- 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 +53 -0
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +100 -28
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +169 -13
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +64 -5
- 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 +168 -10
- 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/typeof.js +6 -0
- package/dist/frontend/lowering/expressions/typeof.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 +39 -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 +64 -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/indexed-unions.d.ts +54 -0
- package/dist/frontend/lowering/indexed-unions.js +401 -0
- package/dist/frontend/lowering/indexed-unions.js.map +1 -0
- 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 +974 -48
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +530 -10
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +15 -3
- package/dist/frontend/lowering/lower-assert.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 +462 -44
- 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 +324 -69
- 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 +215 -3
- 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 +42 -32
- 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.d.ts +1 -1
- package/dist/frontend/lowering/lower-inspect.js +53 -17
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +53 -5
- 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 +553 -81
- 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 +107 -8
- package/dist/frontend/lowering/lowerer.js +381 -36
- 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/object-factory-new.d.ts +5 -0
- package/dist/frontend/lowering/object-factory-new.js +20 -6
- package/dist/frontend/lowering/object-factory-new.js.map +1 -1
- package/dist/frontend/lowering/overload-choice.d.ts +33 -0
- package/dist/frontend/lowering/overload-choice.js +190 -0
- package/dist/frontend/lowering/overload-choice.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +3 -0
- package/dist/frontend/lowering/surfaces.js +73 -8
- 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 +19 -11
- 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-analysis.d.ts +5 -1
- package/dist/frontend/program-analysis.js +5 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program.d.ts +21 -6
- package/dist/frontend/program.js +681 -83
- 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/semantic-model.d.ts +3 -0
- package/dist/frontend/ts7/semantic-model.js +5 -0
- package/dist/frontend/ts7/semantic-model.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.test.js +6 -1
- package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-types.d.ts +1 -1
- package/dist/frontend/ts7/semantic-types.js +1 -1
- package/dist/frontend/ts7/semantic-types.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 +229 -20
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +46 -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 +60 -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 +222 -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 +266 -57
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +33 -0
- package/dist/ir/int32-slots.test.js.map +1 -1
- package/dist/ir/integer-loops.d.ts +3 -3
- package/dist/ir/integer-loops.js +28 -10
- 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 +83 -10
- package/dist/ir/ir.js +77 -6
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +23 -2
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/js-ic.d.ts +4 -0
- package/dist/ir/js-ic.js +17 -1
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +46 -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 +177 -39
- 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 +167 -40
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/ir-policy.js +3 -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 +4 -2
- package/dist/native/prepare.js +130 -32
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +96 -20
- 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 +27 -7
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
|
|
@@ -968,6 +1087,11 @@ function suppressedJsStrictness7(d) {
|
|
|
968
1087
|
if (JS_ANY_OPERATOR_CODES.has(d.code)) {
|
|
969
1088
|
return ts.flattenDiagnosticMessageText(d, "\n").includes("'any'");
|
|
970
1089
|
}
|
|
1090
|
+
// The deprecated Buffer(...) call without `new`, which Node's Buffer
|
|
1091
|
+
// function accepts (containers/bytes.ts lowers it).
|
|
1092
|
+
if (d.code === 2348) {
|
|
1093
|
+
return ts.flattenDiagnosticMessageText(d, "\n").includes("'BufferConstructor'");
|
|
1094
|
+
}
|
|
971
1095
|
return false;
|
|
972
1096
|
}
|
|
973
1097
|
/** The specifier of a `require("...")` call: the callee is the bare
|
|
@@ -1007,9 +1131,15 @@ function isRequireStatement7(stmt) {
|
|
|
1007
1131
|
decls.every((d) => d.initializer !== undefined && requireSpecOf7(d.initializer) !== null));
|
|
1008
1132
|
}
|
|
1009
1133
|
/** The require() occurrences of one top-level statement: the declaration
|
|
1010
|
-
* forms
|
|
1011
|
-
|
|
1134
|
+
* forms, the bare side-effect call, and the assignment of a split require
|
|
1135
|
+
* binding. Empty for everything else. */
|
|
1136
|
+
function requiresOf7(stmt, program) {
|
|
1012
1137
|
if (ts.isExpressionStatement(stmt)) {
|
|
1138
|
+
const split = splitRequireOfStatement7(program, stmt);
|
|
1139
|
+
if (split !== null)
|
|
1140
|
+
return [
|
|
1141
|
+
{ spec: requireSpecOf7(split.call), node: split.call, decl: split.decl, split: true },
|
|
1142
|
+
];
|
|
1013
1143
|
const spec = requireSpecOf7(stmt.expression);
|
|
1014
1144
|
return spec !== null ? [{ spec, node: stmt.expression, decl: null }] : [];
|
|
1015
1145
|
}
|
|
@@ -1023,8 +1153,169 @@ function requiresOf7(stmt) {
|
|
|
1023
1153
|
}
|
|
1024
1154
|
return out;
|
|
1025
1155
|
}
|
|
1156
|
+
/** CommonJS require bindings split into a declaration and one later
|
|
1157
|
+
* assignment (`var m; m = require("./x")`): a top-level `var` or `let`
|
|
1158
|
+
* declaration without initializer in a CommonJS file, assigned by exactly one
|
|
1159
|
+
* top-level `m = require("<literal>")` statement of the require global over
|
|
1160
|
+
* a compiled program module, and written nowhere else. The binding holds the
|
|
1161
|
+
* module's exports from the assignment on, as `const m = require("./x")`
|
|
1162
|
+
* does, so preflight treats the assignment as that require: its module edge,
|
|
1163
|
+
* its cycle admission and its early-read fence. The lowering's recognizer
|
|
1164
|
+
* (splitRequireBindingOf in cjs-inline-require.ts) accepts only these
|
|
1165
|
+
* bindings. Keyed by declaration, with the assignment's require call. */
|
|
1166
|
+
function splitRequireBindings7(program, sf) {
|
|
1167
|
+
const memo = program.analysis.splitRequireBindings;
|
|
1168
|
+
const cached = memo.get(sf);
|
|
1169
|
+
if (cached !== undefined)
|
|
1170
|
+
return cached;
|
|
1171
|
+
const out = new Map();
|
|
1172
|
+
memo.set(sf, out);
|
|
1173
|
+
if (sf.isDeclarationFile || !isCjsJsFile7(sf, program) || !sf.text.includes("require"))
|
|
1174
|
+
return out;
|
|
1175
|
+
const checker = program.getTypeChecker();
|
|
1176
|
+
const stmts = sf.statements.nodes;
|
|
1177
|
+
const candidates = new Map();
|
|
1178
|
+
for (const stmt of stmts) {
|
|
1179
|
+
if (!ts.isVariableStatement(stmt))
|
|
1180
|
+
continue;
|
|
1181
|
+
if ((stmt.declarationList.flags & (ts.NodeFlags.Const | ts.NodeFlags.Using)) !== 0)
|
|
1182
|
+
continue;
|
|
1183
|
+
for (const decl of stmt.declarationList.declarations.nodes) {
|
|
1184
|
+
if (!ts.isIdentifier(decl.name) || decl.initializer !== undefined)
|
|
1185
|
+
continue;
|
|
1186
|
+
const symbol = checker.getSymbolAtLocation(decl.name);
|
|
1187
|
+
if (symbol === undefined || symbol.declarations.length !== 1)
|
|
1188
|
+
continue;
|
|
1189
|
+
candidates.set(symbol, { decl, call: null, assigns: 0 });
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
if (candidates.size === 0)
|
|
1193
|
+
return out;
|
|
1194
|
+
// The one top-level `m = ...` statement, whose right side is the require.
|
|
1195
|
+
for (const stmt of stmts) {
|
|
1196
|
+
if (!ts.isExpressionStatement(stmt) || !ts.isBinaryExpression(stmt.expression))
|
|
1197
|
+
continue;
|
|
1198
|
+
const assign = stmt.expression;
|
|
1199
|
+
if (assign.operatorToken.kind !== ts.SyntaxKind.EqualsToken || !ts.isIdentifier(assign.left))
|
|
1200
|
+
continue;
|
|
1201
|
+
const symbol = checker.getSymbolAtLocation(assign.left);
|
|
1202
|
+
const candidate = symbol !== undefined ? candidates.get(symbol) : undefined;
|
|
1203
|
+
if (candidate === undefined)
|
|
1204
|
+
continue;
|
|
1205
|
+
candidate.assigns++;
|
|
1206
|
+
let right = assign.right;
|
|
1207
|
+
while (ts.isParenthesizedExpression(right))
|
|
1208
|
+
right = right.expression;
|
|
1209
|
+
if (ts.isCallExpression(right) && splitRequireTarget7(program, sf, right))
|
|
1210
|
+
candidate.call = right;
|
|
1211
|
+
}
|
|
1212
|
+
const names = new Set();
|
|
1213
|
+
for (const candidate of candidates.values()) {
|
|
1214
|
+
if (candidate.assigns === 1 && candidate.call !== null)
|
|
1215
|
+
names.add(candidate.decl.name.text);
|
|
1216
|
+
}
|
|
1217
|
+
if (names.size === 0)
|
|
1218
|
+
return out;
|
|
1219
|
+
// Exactly one write in the whole file: the assignment itself.
|
|
1220
|
+
const writes = new Map();
|
|
1221
|
+
ts.walkPreorder(sf, (node) => {
|
|
1222
|
+
if (!ts.isIdentifier(node) || !names.has(node.text))
|
|
1223
|
+
return undefined;
|
|
1224
|
+
const parent = node.parent;
|
|
1225
|
+
const symbol = parent !== undefined && ts.isShorthandPropertyAssignment(parent) && parent.name === node
|
|
1226
|
+
? (checker.getShorthandAssignmentValueSymbol(parent) ?? checker.getSymbolAtLocation(node))
|
|
1227
|
+
: checker.getSymbolAtLocation(node);
|
|
1228
|
+
if (symbol === undefined || !candidates.has(symbol) || !isWriteReference7(node))
|
|
1229
|
+
return undefined;
|
|
1230
|
+
writes.set(symbol, (writes.get(symbol) ?? 0) + 1);
|
|
1231
|
+
return undefined;
|
|
1232
|
+
});
|
|
1233
|
+
for (const [symbol, candidate] of candidates) {
|
|
1234
|
+
if (candidate.assigns === 1 && candidate.call !== null && writes.get(symbol) === 1)
|
|
1235
|
+
out.set(candidate.decl, candidate.call);
|
|
1236
|
+
}
|
|
1237
|
+
return out;
|
|
1238
|
+
}
|
|
1239
|
+
/** True when `call` is a require of the CommonJS global over a compiled
|
|
1240
|
+
* program module: not a builtin, a JSON document or a declaration file. */
|
|
1241
|
+
function splitRequireTarget7(program, sf, call) {
|
|
1242
|
+
const spec = requireSpecOf7(call);
|
|
1243
|
+
if (spec === null || canonicalBuiltinModule(spec) !== null)
|
|
1244
|
+
return false;
|
|
1245
|
+
if (requireCallBindingKind7(program, call) !== "ambient")
|
|
1246
|
+
return false;
|
|
1247
|
+
const dep = resolveImport7(program, sf, spec, "require") ?? npmStaticDepSf7(program, sf, spec, "require");
|
|
1248
|
+
return dep !== null && !dep.isDeclarationFile && !dep.fileName.endsWith(".json");
|
|
1249
|
+
}
|
|
1250
|
+
/** The split require binding a top-level statement assigns, or null. */
|
|
1251
|
+
function splitRequireOfStatement7(program, stmt) {
|
|
1252
|
+
if (!ts.isExpressionStatement(stmt) ||
|
|
1253
|
+
!ts.isBinaryExpression(stmt.expression) ||
|
|
1254
|
+
!ts.isSourceFile(stmt.parent))
|
|
1255
|
+
return null;
|
|
1256
|
+
let right = stmt.expression.right;
|
|
1257
|
+
while (ts.isParenthesizedExpression(right))
|
|
1258
|
+
right = right.expression;
|
|
1259
|
+
for (const [decl, call] of splitRequireBindings7(program, stmt.parent))
|
|
1260
|
+
if (call === right)
|
|
1261
|
+
return { decl, call };
|
|
1262
|
+
return null;
|
|
1263
|
+
}
|
|
1264
|
+
/** The top-level statement of a split require binding's assignment, from
|
|
1265
|
+
* its require call (`m = require("./x")` or `m = (require("./x"))`). */
|
|
1266
|
+
function splitRequireStatementOf7(call) {
|
|
1267
|
+
let node = call;
|
|
1268
|
+
while (node.parent !== undefined && ts.isParenthesizedExpression(node.parent))
|
|
1269
|
+
node = node.parent;
|
|
1270
|
+
return node.parent?.parent;
|
|
1271
|
+
}
|
|
1272
|
+
/** The require call of a split require binding's declaration, or null. */
|
|
1273
|
+
function splitRequireCallOf7(program, decl) {
|
|
1274
|
+
return splitRequireBindings7(program, ts.getSourceFileOfNode(decl)).get(decl) ?? null;
|
|
1275
|
+
}
|
|
1276
|
+
/** True when `id` is written: an assignment target (compound and
|
|
1277
|
+
* destructuring included), an update operand, or a for-in/of target. */
|
|
1278
|
+
function isWriteReference7(id) {
|
|
1279
|
+
let n = id;
|
|
1280
|
+
for (;;) {
|
|
1281
|
+
const p = n.parent;
|
|
1282
|
+
if (p === undefined)
|
|
1283
|
+
return false;
|
|
1284
|
+
if (ts.isBinaryExpression(p)) {
|
|
1285
|
+
const k = p.operatorToken.kind;
|
|
1286
|
+
return (p.left === n && k >= ts.SyntaxKind.FirstAssignment && k <= ts.SyntaxKind.LastAssignment);
|
|
1287
|
+
}
|
|
1288
|
+
if (ts.isPostfixUnaryExpression(p) || ts.isPrefixUnaryExpression(p)) {
|
|
1289
|
+
return ((p.operator === ts.SyntaxKind.PlusPlusToken ||
|
|
1290
|
+
p.operator === ts.SyntaxKind.MinusMinusToken) &&
|
|
1291
|
+
p.operand === n);
|
|
1292
|
+
}
|
|
1293
|
+
if (ts.isForOfStatement(p) || ts.isForInStatement(p))
|
|
1294
|
+
return p.initializer === n;
|
|
1295
|
+
if (ts.isParenthesizedExpression(p) ||
|
|
1296
|
+
ts.isArrayLiteralExpression(p) ||
|
|
1297
|
+
ts.isSpreadElement(p) ||
|
|
1298
|
+
ts.isSpreadAssignment(p) ||
|
|
1299
|
+
ts.isShorthandPropertyAssignment(p) ||
|
|
1300
|
+
ts.isObjectLiteralExpression(p) ||
|
|
1301
|
+
(ts.isPropertyAssignment(p) && p.initializer === n)) {
|
|
1302
|
+
n = p;
|
|
1303
|
+
continue;
|
|
1304
|
+
}
|
|
1305
|
+
return false;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
/** `true`, or `!0`, its minified spelling. */
|
|
1309
|
+
function isTrueLiteral(expr) {
|
|
1310
|
+
return (expr.kind === ts.SyntaxKind.TrueKeyword ||
|
|
1311
|
+
(ts.isPrefixUnaryExpression(expr) &&
|
|
1312
|
+
expr.operator === ts.SyntaxKind.ExclamationToken &&
|
|
1313
|
+
ts.isNumericLiteral(expr.operand) &&
|
|
1314
|
+
expr.operand.text === "0"));
|
|
1315
|
+
}
|
|
1026
1316
|
/** The exact `Object.defineProperty(exports|module.exports, "__esModule",
|
|
1027
|
-
* { value: true })` interop stamp (shared by preflight and the no-op lowering)
|
|
1317
|
+
* { value: true })` interop stamp (shared by preflight and the no-op lowering);
|
|
1318
|
+
* `{ value: !0 }` is the same stamp. */
|
|
1028
1319
|
export function isEsModuleStamp(expr) {
|
|
1029
1320
|
if (!ts.isCallExpression(expr) || expr.questionDotToken !== undefined)
|
|
1030
1321
|
return false;
|
|
@@ -1055,7 +1346,7 @@ export function isEsModuleStamp(expr) {
|
|
|
1055
1346
|
return (ts.isPropertyAssignment(p) &&
|
|
1056
1347
|
ts.isIdentifier(p.name) &&
|
|
1057
1348
|
p.name.text === "value" &&
|
|
1058
|
-
p.initializer
|
|
1349
|
+
isTrueLiteral(p.initializer));
|
|
1059
1350
|
}
|
|
1060
1351
|
/** Plain CommonJS prologue writes only publish values; in particular,
|
|
1061
1352
|
* publishing a hoisted function does not invoke its body. Later runnable
|
|
@@ -1141,7 +1432,7 @@ function purePrefixStmt7(program, s) {
|
|
|
1141
1432
|
return true;
|
|
1142
1433
|
if (ts.isExpressionStatement(s) && ts.isStringLiteral(s.expression))
|
|
1143
1434
|
return true; // directive
|
|
1144
|
-
if (isRequireStatement7(s))
|
|
1435
|
+
if (isRequireStatement7(s) || splitRequireOfStatement7(program, s) !== null)
|
|
1145
1436
|
return true;
|
|
1146
1437
|
if (isCjsJsFile7(ts.getSourceFileOfNode(s), program)) {
|
|
1147
1438
|
if (ts.isExpressionStatement(s) && isEsModuleStamp(s.expression)) {
|
|
@@ -1265,12 +1556,18 @@ function requireEarlyReference7(program, decl) {
|
|
|
1265
1556
|
if (cached !== undefined)
|
|
1266
1557
|
return cached;
|
|
1267
1558
|
let found = null;
|
|
1268
|
-
const stmt = decl.parent?.parent;
|
|
1269
1559
|
const sf = ts.getSourceFileOfNode(decl);
|
|
1270
|
-
|
|
1560
|
+
// A split require binding is bound at its assignment statement.
|
|
1561
|
+
const splitCall = splitRequireCallOf7(program, decl);
|
|
1562
|
+
const stmt = splitCall !== null ? splitRequireStatementOf7(splitCall) : decl.parent?.parent;
|
|
1563
|
+
if (stmt !== undefined &&
|
|
1564
|
+
(ts.isVariableStatement(stmt) || splitCall !== null) &&
|
|
1565
|
+
ts.isSourceFile(stmt.parent)) {
|
|
1271
1566
|
const stmts = sf.statements.nodes;
|
|
1272
1567
|
const k = stmts.indexOf(stmt);
|
|
1273
|
-
const declarations = stmt
|
|
1568
|
+
const declarations = ts.isVariableStatement(stmt)
|
|
1569
|
+
? stmt.declarationList.declarations.nodes
|
|
1570
|
+
: [];
|
|
1274
1571
|
// Earlier declarators run too: `const x = read(), dep = require('./dep')`.
|
|
1275
1572
|
const precedingDecls = declarations.slice(0, declarations.indexOf(decl));
|
|
1276
1573
|
let firstRunnable = program.analysis.requireFirstRunnable.get(sf);
|
|
@@ -1318,6 +1615,12 @@ exactEarlyRead) {
|
|
|
1318
1615
|
}
|
|
1319
1616
|
if (bindings.size === 0)
|
|
1320
1617
|
return null;
|
|
1618
|
+
// A split require binding's assignment writes the binding; it reads nothing.
|
|
1619
|
+
let splitWrite = splitRequireCallOf7(program, decl);
|
|
1620
|
+
while (splitWrite !== null && ts.isParenthesizedExpression(splitWrite.parent))
|
|
1621
|
+
splitWrite = splitWrite.parent;
|
|
1622
|
+
splitWrite =
|
|
1623
|
+
splitWrite !== null && ts.isBinaryExpression(splitWrite.parent) ? splitWrite.parent.left : null;
|
|
1321
1624
|
const stmts = sf.statements.nodes;
|
|
1322
1625
|
const cjs = isCjsJsFile7(sf, program);
|
|
1323
1626
|
const symbolOf = (id) => {
|
|
@@ -1562,7 +1865,7 @@ exactEarlyRead) {
|
|
|
1562
1865
|
if (sym === undefined)
|
|
1563
1866
|
return undefined;
|
|
1564
1867
|
if (bindings.has(sym)) {
|
|
1565
|
-
if (exactEarlyRead?.(n) === true)
|
|
1868
|
+
if (n === splitWrite || exactEarlyRead?.(n) === true)
|
|
1566
1869
|
return undefined;
|
|
1567
1870
|
hit = n;
|
|
1568
1871
|
return "stop";
|
|
@@ -2963,7 +3266,7 @@ function cjsCycleRefusal7(program, comp, lineOf) {
|
|
|
2963
3266
|
}
|
|
2964
3267
|
// Bindings of other members must stay unreachable from top-level code.
|
|
2965
3268
|
for (const st of stmts) {
|
|
2966
|
-
for (const req of requiresOf7(st)) {
|
|
3269
|
+
for (const req of requiresOf7(st, program)) {
|
|
2967
3270
|
if (req.decl === null)
|
|
2968
3271
|
continue;
|
|
2969
3272
|
const dep = resolveImport7(program, m, req.spec, "require");
|
|
@@ -3362,6 +3665,7 @@ function computeCycleEarlyBindings7(program, entry, order, singleRoot, exact) {
|
|
|
3362
3665
|
start: ts.tokenStartOfNode(stmt),
|
|
3363
3666
|
end: stmt.end,
|
|
3364
3667
|
reference: null,
|
|
3668
|
+
deferredReference: null,
|
|
3365
3669
|
folded: null,
|
|
3366
3670
|
localNames: new Map(),
|
|
3367
3671
|
});
|
|
@@ -3438,10 +3742,13 @@ function computeCycleEarlyBindings7(program, entry, order, singleRoot, exact) {
|
|
|
3438
3742
|
ts.tokenStartOfNode(ref) >= c.start &&
|
|
3439
3743
|
ref.end <= c.end)
|
|
3440
3744
|
continue;
|
|
3745
|
+
if (inDeferredPosition7(ref)) {
|
|
3746
|
+
if (c.exposed && c.deferredReference === null)
|
|
3747
|
+
c.deferredReference = ref;
|
|
3748
|
+
continue;
|
|
3749
|
+
}
|
|
3441
3750
|
let early;
|
|
3442
|
-
if (
|
|
3443
|
-
early = c.exposed;
|
|
3444
|
-
else if (sf === c.module)
|
|
3751
|
+
if (sf === c.module)
|
|
3445
3752
|
early = ts.tokenStartOfNode(ref) < c.start;
|
|
3446
3753
|
else if (!memberSet.has(sf) || !rankOf.has(sf))
|
|
3447
3754
|
early = false;
|
|
@@ -3451,7 +3758,15 @@ function computeCycleEarlyBindings7(program, entry, order, singleRoot, exact) {
|
|
|
3451
3758
|
c.reference = ref;
|
|
3452
3759
|
}
|
|
3453
3760
|
}
|
|
3761
|
+
// With a static evaluation order, a deferred reference only runs early
|
|
3762
|
+
// when the code that runs before the declaration completes can reach
|
|
3763
|
+
// the function holding it.
|
|
3764
|
+
const reached = known && [...candidates.values()].some((c) => c.reference === null && c.deferredReference)
|
|
3765
|
+
? cycleReachedDeferredReferences7(program, evaluation, candidates)
|
|
3766
|
+
: null;
|
|
3454
3767
|
for (const c of candidates.values()) {
|
|
3768
|
+
if (c.reference === null && c.deferredReference !== null)
|
|
3769
|
+
c.reference = reached === null ? c.deferredReference : (reached.get(c.symbol) ?? null);
|
|
3455
3770
|
if (c.reference === null)
|
|
3456
3771
|
continue;
|
|
3457
3772
|
const settled = new Set(order.filter((sf) => !rankOf.has(sf)));
|
|
@@ -3472,6 +3787,292 @@ function computeCycleEarlyBindings7(program, entry, order, singleRoot, exact) {
|
|
|
3472
3787
|
}
|
|
3473
3788
|
return out;
|
|
3474
3789
|
}
|
|
3790
|
+
/** Collects into `units` the callables an initializer expression stores
|
|
3791
|
+
* (see moduleEarlyBindingsOf7), recording in `immediate` the parts of a
|
|
3792
|
+
* stored node that run where it is evaluated. */
|
|
3793
|
+
function storedCallables7(checker, e, units, immediate) {
|
|
3794
|
+
while (ts.isParenthesizedExpression(e) ||
|
|
3795
|
+
ts.isAsExpression(e) ||
|
|
3796
|
+
ts.isSatisfiesExpression(e) ||
|
|
3797
|
+
ts.isNonNullExpression(e))
|
|
3798
|
+
e = e.expression;
|
|
3799
|
+
if (ts.isArrowFunction(e) || ts.isFunctionExpression(e)) {
|
|
3800
|
+
units.push(e);
|
|
3801
|
+
}
|
|
3802
|
+
else if (ts.isClassExpression(e)) {
|
|
3803
|
+
units.push(e);
|
|
3804
|
+
immediate.set(e, classSyncParts7(e));
|
|
3805
|
+
}
|
|
3806
|
+
else if (ts.isObjectLiteralExpression(e)) {
|
|
3807
|
+
for (const p of e.properties.nodes) {
|
|
3808
|
+
if (ts.isMethodDeclaration(p) ||
|
|
3809
|
+
ts.isGetAccessorDeclaration(p) ||
|
|
3810
|
+
ts.isSetAccessorDeclaration(p)) {
|
|
3811
|
+
// A computed key evaluates where the literal does; a plain
|
|
3812
|
+
// member-chain key (`[Equal.symbol]`) runs no user code.
|
|
3813
|
+
if (!ts.isComputedPropertyName(p.name))
|
|
3814
|
+
units.push(p);
|
|
3815
|
+
else if (memberChainKey7(p.name.expression)) {
|
|
3816
|
+
units.push(p);
|
|
3817
|
+
immediate.set(p, [p.name]);
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
else if (ts.isPropertyAssignment(p))
|
|
3821
|
+
storedCallables7(checker, p.initializer, units, immediate);
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
else if (ts.isArrayLiteralExpression(e)) {
|
|
3825
|
+
for (const el of e.elements.nodes)
|
|
3826
|
+
if (!ts.isSpreadElement(el))
|
|
3827
|
+
storedCallables7(checker, el, units, immediate);
|
|
3828
|
+
}
|
|
3829
|
+
else if (ts.isCallExpression(e)) {
|
|
3830
|
+
// `const f = wrap(callback)` where wrap only returns closures over
|
|
3831
|
+
// the callback: it runs when the stored result is called.
|
|
3832
|
+
e.arguments.nodes.forEach((arg, index) => {
|
|
3833
|
+
let fn = arg;
|
|
3834
|
+
while (ts.isParenthesizedExpression(fn))
|
|
3835
|
+
fn = fn.expression;
|
|
3836
|
+
if ((ts.isArrowFunction(fn) || ts.isFunctionExpression(fn)) &&
|
|
3837
|
+
returnsOnlyClosuresOver7(checker, e.expression, index))
|
|
3838
|
+
units.push(fn);
|
|
3839
|
+
});
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
/** For one import cycle with a static evaluation order: the first deferred
|
|
3843
|
+
* reference to each candidate that code running before the candidate's
|
|
3844
|
+
* declaration completes can reach, or null when the walk cannot be precise
|
|
3845
|
+
* (top-level await, a default-exported function or class declaration).
|
|
3846
|
+
*
|
|
3847
|
+
* The cycle's top-level code runs in evaluation order. A stored callable
|
|
3848
|
+
* (a function or class declaration, or a function, class or object-literal
|
|
3849
|
+
* method stored by a variable initializer) becomes reachable once
|
|
3850
|
+
* reachable code names its binding, through an import alias or a
|
|
3851
|
+
* namespace member too; every other function-like in reachable code counts
|
|
3852
|
+
* as reachable, since it may be handed to a callee. A namespace import of
|
|
3853
|
+
* a cycle member used other than for a member read makes every stored
|
|
3854
|
+
* callable reachable. moduleEarlyBindingsOf7 is the single-module form. */
|
|
3855
|
+
function cycleReachedDeferredReferences7(program, evaluation, candidates) {
|
|
3856
|
+
const checker = program.getTypeChecker();
|
|
3857
|
+
const members = new Set(evaluation);
|
|
3858
|
+
for (const sf of evaluation) {
|
|
3859
|
+
if (hasTopLevelAwait7(sf))
|
|
3860
|
+
return null;
|
|
3861
|
+
for (const stmt of sf.statements.nodes) {
|
|
3862
|
+
if ((ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) &&
|
|
3863
|
+
(ts.getCombinedModifierFlags(stmt) &
|
|
3864
|
+
ts.ModifierFlags.Default) !==
|
|
3865
|
+
0)
|
|
3866
|
+
return null;
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
const stored = new Set();
|
|
3870
|
+
const immediate = new Map();
|
|
3871
|
+
const storedNames = [];
|
|
3872
|
+
const unitsOfName = new Map();
|
|
3873
|
+
const store = (name, units) => {
|
|
3874
|
+
if (units.length === 0)
|
|
3875
|
+
return;
|
|
3876
|
+
for (const u of units)
|
|
3877
|
+
stored.add(u);
|
|
3878
|
+
storedNames.push(name);
|
|
3879
|
+
unitsOfName.set(name, units);
|
|
3880
|
+
};
|
|
3881
|
+
for (const sf of evaluation) {
|
|
3882
|
+
for (const stmt of sf.statements.nodes) {
|
|
3883
|
+
if ((ts.getCombinedModifierFlags(stmt) &
|
|
3884
|
+
ts.ModifierFlags.Ambient) !==
|
|
3885
|
+
0)
|
|
3886
|
+
continue;
|
|
3887
|
+
if (ts.isFunctionDeclaration(stmt) && stmt.name !== undefined && stmt.body !== undefined) {
|
|
3888
|
+
store(stmt.name, [stmt]);
|
|
3889
|
+
}
|
|
3890
|
+
else if (ts.isClassDeclaration(stmt) && stmt.name !== undefined) {
|
|
3891
|
+
store(stmt.name, [stmt]);
|
|
3892
|
+
}
|
|
3893
|
+
else if (ts.isVariableStatement(stmt)) {
|
|
3894
|
+
for (const d of stmt.declarationList.declarations.nodes) {
|
|
3895
|
+
if (ts.isIdentifier(d.name) && d.initializer !== undefined) {
|
|
3896
|
+
const units = [];
|
|
3897
|
+
storedCallables7(checker, d.initializer, units, immediate);
|
|
3898
|
+
store(d.name, units);
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
const unitsBySymbol = new Map();
|
|
3905
|
+
const allUnits = [];
|
|
3906
|
+
for (const name of storedNames) {
|
|
3907
|
+
const symbol = checker.getSymbolAtLocation(name);
|
|
3908
|
+
if (symbol === undefined)
|
|
3909
|
+
continue;
|
|
3910
|
+
const units = unitsOfName.get(name);
|
|
3911
|
+
unitsBySymbol.set(symbol, [...(unitsBySymbol.get(symbol) ?? []), ...units]);
|
|
3912
|
+
allUnits.push(...units);
|
|
3913
|
+
}
|
|
3914
|
+
// A named class expression's inner name (`class Impl { static x =
|
|
3915
|
+
// Impl.m(); }`) names the class inside its own body, as the binding it
|
|
3916
|
+
// is stored in names it outside.
|
|
3917
|
+
const innerNames = [];
|
|
3918
|
+
for (const unit of allUnits) {
|
|
3919
|
+
if (!ts.isClassExpression(unit) || unit.name === undefined)
|
|
3920
|
+
continue;
|
|
3921
|
+
const symbol = checker.getSymbolAtLocation(unit.name);
|
|
3922
|
+
if (symbol === undefined)
|
|
3923
|
+
continue;
|
|
3924
|
+
innerNames.push(unit.name);
|
|
3925
|
+
unitsBySymbol.set(symbol, [...(unitsBySymbol.get(symbol) ?? []), unit]);
|
|
3926
|
+
}
|
|
3927
|
+
// The identifier texts worth resolving: declared names, and the local
|
|
3928
|
+
// names of imports (named, default and namespace) in cycle members.
|
|
3929
|
+
const names = new Set();
|
|
3930
|
+
for (const c of candidates.values())
|
|
3931
|
+
names.add(c.name.text);
|
|
3932
|
+
for (const name of storedNames)
|
|
3933
|
+
names.add(name.text);
|
|
3934
|
+
for (const name of innerNames)
|
|
3935
|
+
names.add(name.text);
|
|
3936
|
+
for (const sf of evaluation) {
|
|
3937
|
+
for (const stmt of sf.statements.nodes) {
|
|
3938
|
+
if (!ts.isImportDeclaration(stmt) || stmt.importClause === undefined)
|
|
3939
|
+
continue;
|
|
3940
|
+
const clause = stmt.importClause;
|
|
3941
|
+
if (clause.name !== undefined)
|
|
3942
|
+
names.add(clause.name.text);
|
|
3943
|
+
const bindings = clause.namedBindings;
|
|
3944
|
+
if (bindings === undefined)
|
|
3945
|
+
continue;
|
|
3946
|
+
if (ts.isNamedImports(bindings))
|
|
3947
|
+
for (const element of bindings.elements.nodes)
|
|
3948
|
+
names.add(element.name.text);
|
|
3949
|
+
else
|
|
3950
|
+
names.add(bindings.name.text);
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
const idents = [];
|
|
3954
|
+
for (const sf of evaluation) {
|
|
3955
|
+
ts.walkPreorder(sf, (node) => {
|
|
3956
|
+
if (ts.isImportDeclaration(node))
|
|
3957
|
+
return "skip";
|
|
3958
|
+
if (ts.isIdentifier(node) && names.has(node.text))
|
|
3959
|
+
idents.push(node);
|
|
3960
|
+
return undefined;
|
|
3961
|
+
});
|
|
3962
|
+
}
|
|
3963
|
+
checker.prefetchSymbolNodesExact(idents);
|
|
3964
|
+
const symbolOf = (id) => {
|
|
3965
|
+
const parent = id.parent;
|
|
3966
|
+
let symbol = checker.getSymbolAtLocation(id);
|
|
3967
|
+
if (parent !== undefined && ts.isShorthandPropertyAssignment(parent) && parent.name === id) {
|
|
3968
|
+
symbol = checker.getShorthandAssignmentValueSymbol(parent) ?? symbol;
|
|
3969
|
+
}
|
|
3970
|
+
if (symbol !== undefined && symbol.flags & ts.SymbolFlags.Alias) {
|
|
3971
|
+
symbol = checker.getAliasedSymbol(symbol);
|
|
3972
|
+
}
|
|
3973
|
+
return symbol;
|
|
3974
|
+
};
|
|
3975
|
+
const isMemberNamespace = (symbol) => (symbol.flags & ts.SymbolFlags.ValueModule) !== 0 &&
|
|
3976
|
+
symbol.declarations.some((d) => ts.isSourceFile(d) && members.has(d));
|
|
3977
|
+
const declared = new Set();
|
|
3978
|
+
const reachedUnits = new Set();
|
|
3979
|
+
const out = new Map();
|
|
3980
|
+
const work = [];
|
|
3981
|
+
const reach = (unit) => {
|
|
3982
|
+
if (reachedUnits.has(unit))
|
|
3983
|
+
return;
|
|
3984
|
+
reachedUnits.add(unit);
|
|
3985
|
+
work.push(unit);
|
|
3986
|
+
};
|
|
3987
|
+
const visit = (root) => {
|
|
3988
|
+
ts.walkPreorder(root, (node) => {
|
|
3989
|
+
if (node !== root && stored.has(node)) {
|
|
3990
|
+
for (const part of immediate.get(node) ?? [])
|
|
3991
|
+
visit(part);
|
|
3992
|
+
return "skip";
|
|
3993
|
+
}
|
|
3994
|
+
if (ts.isImportDeclaration(node))
|
|
3995
|
+
return "skip";
|
|
3996
|
+
if (node.kind === ts.SyntaxKind.ThisKeyword) {
|
|
3997
|
+
// `this` in a static initializer or block names the class, so it
|
|
3998
|
+
// reaches the class's methods as naming the class does.
|
|
3999
|
+
const owner = staticThisClass7(node);
|
|
4000
|
+
if (owner !== undefined && stored.has(owner))
|
|
4001
|
+
reach(owner);
|
|
4002
|
+
return undefined;
|
|
4003
|
+
}
|
|
4004
|
+
if (!ts.isIdentifier(node) || !names.has(node.text))
|
|
4005
|
+
return undefined;
|
|
4006
|
+
if (inTypePosition7(node))
|
|
4007
|
+
return undefined;
|
|
4008
|
+
const parent = node.parent;
|
|
4009
|
+
if (parent !== undefined && ts.isExportSpecifier(parent))
|
|
4010
|
+
return undefined;
|
|
4011
|
+
if (parent !== undefined && declaredName7(parent) === node)
|
|
4012
|
+
return undefined;
|
|
4013
|
+
const symbol = symbolOf(node);
|
|
4014
|
+
if (symbol === undefined)
|
|
4015
|
+
return undefined;
|
|
4016
|
+
if (isMemberNamespace(symbol)) {
|
|
4017
|
+
// `ns.member` resolves through the member's own identifier; any
|
|
4018
|
+
// other use can reach every export.
|
|
4019
|
+
if (!(parent !== undefined &&
|
|
4020
|
+
ts.isPropertyAccessExpression(parent) &&
|
|
4021
|
+
parent.expression === node))
|
|
4022
|
+
for (const unit of allUnits)
|
|
4023
|
+
reach(unit);
|
|
4024
|
+
return undefined;
|
|
4025
|
+
}
|
|
4026
|
+
const c = candidates.get(symbol);
|
|
4027
|
+
if (c !== undefined &&
|
|
4028
|
+
node !== c.name &&
|
|
4029
|
+
!declared.has(symbol) &&
|
|
4030
|
+
!out.has(symbol) &&
|
|
4031
|
+
inDeferredPosition7(node) &&
|
|
4032
|
+
!(c.kind === "class" &&
|
|
4033
|
+
ts.getSourceFileOfNode(node) === c.module &&
|
|
4034
|
+
ts.tokenStartOfNode(node) >= c.start &&
|
|
4035
|
+
node.end <= c.end))
|
|
4036
|
+
out.set(symbol, node);
|
|
4037
|
+
for (const unit of unitsBySymbol.get(symbol) ?? [])
|
|
4038
|
+
reach(unit);
|
|
4039
|
+
return undefined;
|
|
4040
|
+
});
|
|
4041
|
+
};
|
|
4042
|
+
const drain = () => {
|
|
4043
|
+
while (work.length > 0)
|
|
4044
|
+
visit(work.pop());
|
|
4045
|
+
};
|
|
4046
|
+
const declare = (name) => {
|
|
4047
|
+
for (const id of boundNames7(name)) {
|
|
4048
|
+
const symbol = checker.getSymbolAtLocation(id);
|
|
4049
|
+
if (symbol !== undefined)
|
|
4050
|
+
declared.add(symbol);
|
|
4051
|
+
}
|
|
4052
|
+
};
|
|
4053
|
+
for (const sf of evaluation) {
|
|
4054
|
+
for (const stmt of sf.statements.nodes) {
|
|
4055
|
+
if (ts.isClassDeclaration(stmt)) {
|
|
4056
|
+
for (const part of classSyncParts7(stmt))
|
|
4057
|
+
visit(part);
|
|
4058
|
+
drain();
|
|
4059
|
+
if (stmt.name !== undefined)
|
|
4060
|
+
declare(stmt.name);
|
|
4061
|
+
}
|
|
4062
|
+
else if (ts.isVariableStatement(stmt)) {
|
|
4063
|
+
for (const d of stmt.declarationList.declarations.nodes) {
|
|
4064
|
+
visit(d);
|
|
4065
|
+
drain();
|
|
4066
|
+
declare(d.name);
|
|
4067
|
+
}
|
|
4068
|
+
}
|
|
4069
|
+
else if (!ts.isFunctionDeclaration(stmt))
|
|
4070
|
+
visit(stmt);
|
|
4071
|
+
drain();
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
return out;
|
|
4075
|
+
}
|
|
3475
4076
|
/** Top-level let/const and class bindings, in modules outside the
|
|
3476
4077
|
* exactly-initialized cycles, that code running before their declaration
|
|
3477
4078
|
* completes can read.
|
|
@@ -3523,55 +4124,7 @@ function moduleEarlyBindingsOf7(program, sf, order) {
|
|
|
3523
4124
|
storedBy.set(name.text, list);
|
|
3524
4125
|
};
|
|
3525
4126
|
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
|
-
};
|
|
4127
|
+
const storedIn = (e, units) => storedCallables7(checker, e, units, immediate);
|
|
3575
4128
|
sf.statements.nodes.forEach((stmt, index) => {
|
|
3576
4129
|
if (ambient(stmt))
|
|
3577
4130
|
return;
|
|
@@ -3853,6 +4406,41 @@ function returnsOnlyClosuresOver7(checker, callee, index) {
|
|
|
3853
4406
|
* expressions, decorators, computed member keys, static field
|
|
3854
4407
|
* initializers and static blocks. Methods and instance fields wait for a
|
|
3855
4408
|
* call or a construction. */
|
|
4409
|
+
/** The class whose static field initializer or static block evaluates `this`
|
|
4410
|
+
* (through arrow functions, which keep the enclosing `this`), or undefined
|
|
4411
|
+
* when another function or a class's instance side binds it. */
|
|
4412
|
+
function staticThisClass7(node) {
|
|
4413
|
+
let child = node;
|
|
4414
|
+
for (let n = node.parent; n !== undefined; child = n, n = n.parent) {
|
|
4415
|
+
if (ts.isArrowFunction(n))
|
|
4416
|
+
continue;
|
|
4417
|
+
if (ts.isClassStaticBlockDeclaration(n))
|
|
4418
|
+
return n.parent;
|
|
4419
|
+
if (ts.isPropertyDeclaration(n)) {
|
|
4420
|
+
if (n.initializer !== child)
|
|
4421
|
+
return undefined;
|
|
4422
|
+
return (ts.getCombinedModifierFlags(n) & ts.ModifierFlags.Static) !== 0
|
|
4423
|
+
? n.parent
|
|
4424
|
+
: undefined;
|
|
4425
|
+
}
|
|
4426
|
+
if (ts.isComputedPropertyName(n)) {
|
|
4427
|
+
// A computed key evaluates in the scope around the class.
|
|
4428
|
+
const member = n.parent;
|
|
4429
|
+
const cls = member?.parent;
|
|
4430
|
+
if (cls === undefined)
|
|
4431
|
+
return undefined;
|
|
4432
|
+
child = cls;
|
|
4433
|
+
n = cls;
|
|
4434
|
+
continue;
|
|
4435
|
+
}
|
|
4436
|
+
if (ts.isFunctionLike(n) ||
|
|
4437
|
+
ts.isClassDeclaration(n) ||
|
|
4438
|
+
ts.isClassExpression(n) ||
|
|
4439
|
+
ts.isSourceFile(n))
|
|
4440
|
+
return undefined;
|
|
4441
|
+
}
|
|
4442
|
+
return undefined;
|
|
4443
|
+
}
|
|
3856
4444
|
function classSyncParts7(c) {
|
|
3857
4445
|
const decorators = (n) => (n.modifiers?.nodes ?? []).filter((m) => m.kind === ts.SyntaxKind.Decorator);
|
|
3858
4446
|
const parts = [...decorators(c), ...(c.heritageClauses?.nodes ?? [])];
|
|
@@ -4356,7 +4944,9 @@ function preflight7(load) {
|
|
|
4356
4944
|
const tscWorld = load.tscWorld;
|
|
4357
4945
|
const tscErrors = tscWorld === undefined ? errorsOf(program) : keptErrors(tscWorld.program, tscWorld.diagnostics);
|
|
4358
4946
|
if (tscErrors.length > 0) {
|
|
4359
|
-
const world = tscWorld === undefined
|
|
4947
|
+
const world = tscWorld === undefined || tscWorld.declWorldFallback === true
|
|
4948
|
+
? load.projectWorld()
|
|
4949
|
+
: (tscWorld.projectWorld ?? tscWorld.program);
|
|
4360
4950
|
for (const d of errorsOf(world)) {
|
|
4361
4951
|
const diag = toPassthrough(d);
|
|
4362
4952
|
const lowered = tscWorld === undefined ? undefined : load.jsxSources?.get(diag.loc.file);
|
|
@@ -4806,17 +5396,20 @@ function preflight7(load) {
|
|
|
4806
5396
|
const early = req.decl !== null ? requireEarlyReference7(program, req.decl) : null;
|
|
4807
5397
|
if (early === null ||
|
|
4808
5398
|
(bindingKind !== "createRequire" &&
|
|
5399
|
+
req.split === undefined &&
|
|
4809
5400
|
((req.decl.parent?.flags ?? 0) & (ts.NodeFlags.Const | ts.NodeFlags.Let)) !== 0)) {
|
|
4810
5401
|
return false;
|
|
4811
5402
|
}
|
|
4812
5403
|
diags.push(unsupportedDiag("SC1013", loc, bindingKind === "createRequire"
|
|
4813
5404
|
? `createRequire() binding '${early.text}' below code that can reach it (Node throws ReferenceError on any earlier access, which is not modeled — move the require above the code that can run first)`
|
|
4814
|
-
:
|
|
5405
|
+
: req.split !== undefined
|
|
5406
|
+
? `require() binding '${early.text}' assigned below code that can reach it (Node reads undefined before the assignment runs, which is not modeled — move the assignment above the code that can run first)`
|
|
5407
|
+
: `var require() binding '${early.text}' below code that can reach it (Node reads undefined before the require runs, which is not modeled — declare it with const or let, or move the require above the code that can run first)`));
|
|
4815
5408
|
return true;
|
|
4816
5409
|
};
|
|
4817
5410
|
for (let k = 0; k < stmts.length; k++) {
|
|
4818
5411
|
const stmt = stmts[k];
|
|
4819
|
-
for (const req of requiresOf7(stmt)) {
|
|
5412
|
+
for (const req of requiresOf7(stmt, program)) {
|
|
4820
5413
|
const loc = {
|
|
4821
5414
|
file: sf.fileName,
|
|
4822
5415
|
start: ts.tokenStartOfNode(req.node),
|
|
@@ -4845,8 +5438,8 @@ function preflight7(load) {
|
|
|
4845
5438
|
if (jsonDep !== null && jsonDep.fileName.endsWith(".json")) {
|
|
4846
5439
|
if (bindingKind === "createRequire")
|
|
4847
5440
|
continue;
|
|
4848
|
-
if (ts.isVariableStatement(stmt) && requiresOf7(stmt).length > 1) {
|
|
4849
|
-
const others = requiresOf7(stmt).some((r) => {
|
|
5441
|
+
if (ts.isVariableStatement(stmt) && requiresOf7(stmt, program).length > 1) {
|
|
5442
|
+
const others = requiresOf7(stmt, program).some((r) => {
|
|
4850
5443
|
const d = resolveImport7(program, sf, r.spec, "require");
|
|
4851
5444
|
return d === null || !d.fileName.endsWith(".json");
|
|
4852
5445
|
});
|
|
@@ -5008,9 +5601,14 @@ function preflight7(load) {
|
|
|
5008
5601
|
// counts, and targets outside the compiled graph add nothing here:
|
|
5009
5602
|
// their use sites keep their existing lowering fences.
|
|
5010
5603
|
if (jsRequireFile && !isNodeEsmFile7(sf, program)) {
|
|
5604
|
+
// A split require binding's assignment is a statement-level require
|
|
5605
|
+
// edge (requiresOf7 above), parenthesized or not.
|
|
5606
|
+
const splitCalls = new Set(splitRequireBindings7(program, sf).values());
|
|
5011
5607
|
for (const call of inlineRequiresOf7(sf)) {
|
|
5012
5608
|
if (requireCallBindingKind7(program, call) !== "ambient")
|
|
5013
5609
|
continue;
|
|
5610
|
+
if (splitCalls.has(call))
|
|
5611
|
+
continue;
|
|
5014
5612
|
const spec = requireSpecOf7(call);
|
|
5015
5613
|
if (load.externalTypes.has(spec) || canonicalBuiltinModule(spec) !== null)
|
|
5016
5614
|
continue;
|
|
@@ -5383,7 +5981,7 @@ function analyzeEsmNamedImportLinks(program, entry) {
|
|
|
5383
5981
|
const nextSeen = new Set(seenModules);
|
|
5384
5982
|
nextSeen.add(dep);
|
|
5385
5983
|
const module = checker.getSymbolAtLocation(dep);
|
|
5386
|
-
const exported = module?.getExports().get(name);
|
|
5984
|
+
const exported = module?.getExports().get(ts.escapedSymbolName(name));
|
|
5387
5985
|
if (exported !== undefined) {
|
|
5388
5986
|
let resolved = exported;
|
|
5389
5987
|
const seenSymbols = new Set();
|
|
@@ -5661,7 +6259,7 @@ const nodeBuiltinNames = new Set(builtinModules);
|
|
|
5661
6259
|
export { ambientDtsPath, fallbackDtsPath, isNodeTypesPath, overridesDtsPath } from "./dts-paths.js";
|
|
5662
6260
|
export { builtinDefaultImportModule, canonicalBuiltinModule, npmBuiltinAliasOf, SUPPORTED_BUILTIN_MODULES, } from "./builtin-modules.js";
|
|
5663
6261
|
export { npmPackageNameOf, workspacePackageOfPath } from "./workspace-registry.js";
|
|
5664
|
-
export { requireSpecOf7 as requireSpecOf, isRequireStatement7 as isRequireStatement, requiresOf7 as requiresOf, isNodeEsmFile7 as isNodeEsmFile, resolveImport7 as resolveImport, resolveNpmImport7 as resolveNpmImport, locOf7 as locOf, requireEarlyReference7 as requireEarlyReference, inDeferredPosition7 as inDeferredPosition, };
|
|
6262
|
+
export { requireSpecOf7 as requireSpecOf, isRequireStatement7 as isRequireStatement, requiresOf7 as requiresOf, splitRequireCallOf7 as splitRequireCallOf, isNodeEsmFile7 as isNodeEsmFile, resolveImport7 as resolveImport, resolveNpmImport7 as resolveNpmImport, locOf7 as locOf, requireEarlyReference7 as requireEarlyReference, inDeferredPosition7 as inDeferredPosition, };
|
|
5665
6263
|
/** True for JavaScript source files (.js/.mjs/.cjs) — the files whose
|
|
5666
6264
|
* types come entirely from inference (checkJs + JSDoc) and whose classes
|
|
5667
6265
|
* declare fields by constructor assignment. */
|