@scriptc/compiler 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +73 -25
- package/ambient/scriptc-overrides.d.ts +10 -6
- package/ambient/scriptc.d.ts +28 -5
- package/dist/backend/build-cache.d.ts +1 -3
- package/dist/backend/build-cache.js +3 -22
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/cache-root.d.ts +3 -0
- package/dist/backend/cache-root.js +23 -0
- package/dist/backend/cache-root.js.map +1 -0
- package/dist/backend/cycle-analysis.d.ts +15 -0
- package/dist/backend/cycle-analysis.js +107 -0
- package/dist/backend/cycle-analysis.js.map +1 -0
- package/dist/backend/cycle-analysis.test.js +124 -0
- package/dist/backend/cycle-analysis.test.js.map +1 -0
- package/dist/backend/debug-symbols.d.ts +8 -0
- package/dist/backend/debug-symbols.js +52 -0
- package/dist/backend/debug-symbols.js.map +1 -0
- package/dist/backend/executable-features.d.ts +4 -0
- package/dist/backend/executable-features.js +42 -0
- package/dist/backend/executable-features.js.map +1 -0
- package/dist/backend/external-c.d.ts +5 -27
- package/dist/backend/external-c.js +5 -40
- package/dist/backend/external-c.js.map +1 -1
- package/dist/backend/ffi-callbacks.d.ts +2 -3
- package/dist/backend/ffi-callbacks.js +2 -3
- package/dist/backend/ffi-callbacks.js.map +1 -1
- package/dist/backend/library-identity-markers.d.ts +4 -9
- package/dist/backend/library-identity-markers.js +11 -49
- package/dist/backend/library-identity-markers.js.map +1 -1
- package/dist/backend/library-pack.d.ts +5 -0
- package/dist/backend/library-pack.js +123 -0
- package/dist/backend/library-pack.js.map +1 -0
- package/dist/backend/link-plan-core.d.ts +20 -0
- package/dist/backend/link-plan-core.js +18 -0
- package/dist/backend/link-plan-core.js.map +1 -0
- package/dist/backend/link-plan.d.ts +2 -1
- package/dist/backend/link-plan.js +18 -17
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/link-trace.d.ts +2 -0
- package/dist/backend/link-trace.js +24 -0
- package/dist/backend/link-trace.js.map +1 -0
- package/dist/backend/linker.js +9 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/literals.d.ts +9 -0
- package/dist/backend/literals.js +35 -0
- package/dist/backend/literals.js.map +1 -0
- package/dist/backend/literals.test.d.ts +1 -0
- package/dist/backend/literals.test.js +53 -0
- package/dist/backend/literals.test.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +4 -0
- package/dist/backend/llvm/blocks.js +25 -4
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/blocks.test.d.ts +1 -0
- package/dist/backend/llvm/blocks.test.js +91 -0
- package/dist/backend/llvm/blocks.test.js.map +1 -0
- package/dist/backend/llvm/classes.d.ts +14 -8
- package/dist/backend/llvm/classes.js +70 -28
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +5 -1
- package/dist/backend/llvm/common.js +45 -4
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/debug-info.d.ts +32 -0
- package/dist/backend/llvm/debug-info.js +198 -0
- package/dist/backend/llvm/debug-info.js.map +1 -0
- package/dist/backend/llvm/debug-info.test.d.ts +1 -0
- package/dist/backend/llvm/debug-info.test.js +110 -0
- package/dist/backend/llvm/debug-info.test.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +16 -2
- package/dist/backend/llvm/dyn.js +498 -175
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +598 -1
- package/dist/backend/llvm/emitter.js +739 -409
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.d.ts +1 -0
- package/dist/backend/llvm/emitter.test.js +179 -0
- package/dist/backend/llvm/emitter.test.js.map +1 -0
- package/dist/backend/llvm/expr-async.js +23 -14
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +1 -1
- package/dist/backend/llvm/expr-bytes.js +32 -14
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +1 -1
- package/dist/backend/llvm/expr-callbacks.js +25 -22
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +136 -35
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +1 -1
- package/dist/backend/llvm/expr-containers.js +43 -14
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +5 -260
- package/dist/backend/llvm/expr-control.js +9 -5
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.d.ts +1 -1
- package/dist/backend/llvm/expr-dispatch.js +2 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +72 -74
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-island.d.ts +1 -1
- package/dist/backend/llvm/expr-island.js +11 -7
- package/dist/backend/llvm/expr-island.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +1 -1
- package/dist/backend/llvm/expr-primitives.js +51 -30
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +1 -1
- package/dist/backend/llvm/expr-records.d.ts +5 -1
- package/dist/backend/llvm/expr-records.js +43 -4
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +4 -4
- package/dist/backend/llvm/expr-stream-bridges.js +102 -121
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.d.ts +1 -0
- package/dist/backend/llvm/expr-stream-bridges.test.js +55 -0
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -0
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.js +12 -12
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/layouts.d.ts +19 -0
- package/dist/backend/llvm/layouts.js +12 -0
- package/dist/backend/llvm/layouts.js.map +1 -0
- package/dist/backend/llvm/lib-abi.d.ts +19 -0
- package/dist/backend/llvm/lib-abi.js +82 -0
- package/dist/backend/llvm/lib-abi.js.map +1 -0
- package/dist/backend/llvm/lib-connect.d.ts +2 -0
- package/dist/backend/llvm/lib-connect.js +51 -0
- package/dist/backend/llvm/lib-connect.js.map +1 -0
- package/dist/backend/llvm/lib-datagram.d.ts +2 -0
- package/dist/backend/llvm/lib-datagram.js +135 -0
- package/dist/backend/llvm/lib-datagram.js.map +1 -0
- package/dist/backend/llvm/lib-dispatch.js +50 -6
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +59 -18
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.d.ts +2 -0
- package/dist/backend/llvm/lib-http2.js +215 -0
- package/dist/backend/llvm/lib-http2.js.map +1 -0
- package/dist/backend/llvm/lib-lookup.d.ts +2 -0
- package/dist/backend/llvm/lib-lookup.js +39 -0
- package/dist/backend/llvm/lib-lookup.js.map +1 -0
- package/dist/backend/llvm/lib-network.js +25 -2
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +21 -16
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +125 -1
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +3 -2
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/lib-test.d.ts +2 -0
- package/dist/backend/llvm/lib-test.js +34 -0
- package/dist/backend/llvm/lib-test.js.map +1 -0
- package/dist/backend/llvm/lib-tls.d.ts +2 -0
- package/dist/backend/llvm/lib-tls.js +82 -0
- package/dist/backend/llvm/lib-tls.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +10 -9
- package/dist/backend/llvm/shapes.js +35 -130
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/split.js +4 -1
- package/dist/backend/llvm/split.js.map +1 -1
- package/dist/backend/llvm/split.test.js +26 -1
- package/dist/backend/llvm/split.test.js.map +1 -1
- package/dist/backend/llvm/unsupported.d.ts +1 -0
- package/dist/backend/llvm/unsupported.js +1 -2
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.js +1 -7
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/mangle.d.ts +2 -2
- package/dist/backend/mangle.js +16 -5
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/{c/may-throw.d.ts → may-throw.d.ts} +1 -1
- package/dist/backend/{c/may-throw.js → may-throw.js} +51 -46
- package/dist/backend/may-throw.js.map +1 -0
- package/dist/backend/may-throw.test.d.ts +1 -0
- package/dist/backend/may-throw.test.js +58 -0
- package/dist/backend/may-throw.test.js.map +1 -0
- package/dist/backend/native-codegen-core.d.ts +22 -0
- package/dist/backend/native-codegen-core.js +44 -0
- package/dist/backend/native-codegen-core.js.map +1 -0
- package/dist/backend/native-codegen.d.ts +3 -19
- package/dist/backend/native-codegen.js +5 -44
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +2 -2
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +94 -0
- package/dist/backend/native-link-info-core.js +62 -0
- package/dist/backend/native-link-info-core.js.map +1 -0
- package/dist/backend/native-link-info.d.ts +3 -88
- package/dist/backend/native-link-info.js +12 -243
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-link-info.test.js +41 -146
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +10 -25
- package/dist/backend/native-toolchain.js +89 -219
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +15 -5
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/native-tools.d.ts +24 -0
- package/dist/backend/native-tools.js +33 -0
- package/dist/backend/native-tools.js.map +1 -0
- package/dist/backend/object-localize.js +19 -8
- package/dist/backend/object-localize.js.map +1 -1
- package/dist/backend/object-localize.test.js +22 -0
- package/dist/backend/object-localize.test.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +101 -0
- package/dist/backend/runtime-pack-core.js +172 -0
- package/dist/backend/runtime-pack-core.js.map +1 -0
- package/dist/backend/runtime-pack-native.d.ts +21 -0
- package/dist/backend/runtime-pack-native.js +70 -0
- package/dist/backend/runtime-pack-native.js.map +1 -0
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack.d.ts +3 -83
- package/dist/backend/runtime-pack.js +8 -151
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +24 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/source-locations.d.ts +12 -0
- package/dist/backend/source-locations.js +32 -0
- package/dist/backend/source-locations.js.map +1 -0
- package/dist/backend/source-locations.test.d.ts +1 -0
- package/dist/backend/source-locations.test.js +16 -0
- package/dist/backend/source-locations.test.js.map +1 -0
- package/dist/backend/target-diagnostics.d.ts +22 -0
- package/dist/backend/target-diagnostics.js +108 -0
- package/dist/backend/target-diagnostics.js.map +1 -0
- package/dist/backend/target-platform.d.ts +15 -0
- package/dist/backend/target-platform.js +72 -0
- package/dist/backend/target-platform.js.map +1 -0
- package/dist/backend/targets.d.ts +13 -4
- package/dist/backend/targets.js +95 -30
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +65 -4
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/backend/toolchain-environment.d.ts +6 -0
- package/dist/backend/toolchain-environment.js +99 -0
- package/dist/backend/toolchain-environment.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +1 -9
- package/dist/backend/vendor-archives.js +2 -9
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +9 -0
- package/dist/backend/vendor-inputs.js +10 -0
- package/dist/backend/vendor-inputs.js.map +1 -0
- package/dist/backend/warm-cache.d.ts +3 -0
- package/dist/backend/warm-cache.js +41 -0
- package/dist/backend/warm-cache.js.map +1 -0
- package/dist/cli/command.d.ts +3 -0
- package/dist/cli/command.js +328 -0
- package/dist/cli/command.js.map +1 -0
- package/dist/cli/host.d.ts +24 -0
- package/dist/cli/host.js +2 -0
- package/dist/cli/host.js.map +1 -0
- package/dist/cli/output-options.d.ts +26 -0
- package/dist/cli/output-options.js +60 -0
- package/dist/cli/output-options.js.map +1 -0
- package/dist/cli/paths.d.ts +12 -0
- package/dist/cli/paths.js +42 -0
- package/dist/cli/paths.js.map +1 -0
- package/dist/cli/usage.d.ts +74 -0
- package/dist/cli/usage.js +86 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/cli/wasi-paths.d.ts +8 -0
- package/dist/cli/wasi-paths.js +41 -0
- package/dist/cli/wasi-paths.js.map +1 -0
- package/dist/cli/wasi-runner.d.ts +2 -0
- package/dist/cli/wasi-runner.js +28 -0
- package/dist/cli/wasi-runner.js.map +1 -0
- package/dist/compat/fetch-profile.js +3 -3
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +162 -0
- package/dist/compile-types.js +2 -0
- package/dist/compile-types.js.map +1 -0
- package/dist/coverage/report.js +11 -5
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +5 -2
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +4 -0
- package/dist/diagnostics/diagnostic.js +15 -3
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -4
- package/dist/executable/executable-cache.js +33 -10
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +38 -16
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +14 -0
- package/dist/executable/prepare.js +66 -0
- package/dist/executable/prepare.js.map +1 -0
- package/dist/ffi/ffi-manifest.d.ts +11 -4
- package/dist/ffi/ffi-manifest.js +170 -58
- package/dist/ffi/ffi-manifest.js.map +1 -1
- package/dist/ffi/ffi-manifest.test.d.ts +1 -0
- package/dist/ffi/ffi-manifest.test.js +111 -0
- package/dist/ffi/ffi-manifest.test.js.map +1 -0
- package/dist/format-integer.d.ts +3 -0
- package/dist/format-integer.js +14 -0
- package/dist/format-integer.js.map +1 -0
- package/dist/frontend/analysis.d.ts +5 -0
- package/dist/frontend/analysis.js +88 -0
- package/dist/frontend/analysis.js.map +1 -0
- package/dist/frontend/arguments-usage.d.ts +4 -0
- package/dist/frontend/arguments-usage.js +40 -0
- package/dist/frontend/arguments-usage.js.map +1 -0
- package/dist/frontend/binding-source.d.ts +4 -0
- package/dist/frontend/binding-source.js +18 -0
- package/dist/frontend/binding-source.js.map +1 -0
- package/dist/frontend/builtin-modules.d.ts +1 -1
- package/dist/frontend/builtin-modules.js +1 -1
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/cjs-lexer.d.ts +4 -25
- package/dist/frontend/cjs-lexer.js +6 -806
- package/dist/frontend/cjs-lexer.js.map +1 -1
- package/dist/frontend/cjs-resolve.d.ts +5 -0
- package/dist/frontend/cjs-resolve.js +429 -0
- package/dist/frontend/cjs-resolve.js.map +1 -0
- package/dist/frontend/cjs-syntax.d.ts +26 -0
- package/dist/frontend/cjs-syntax.js +806 -0
- package/dist/frontend/cjs-syntax.js.map +1 -0
- package/dist/frontend/comptime-node.d.ts +4 -0
- package/dist/frontend/comptime-node.js +16 -0
- package/dist/frontend/comptime-node.js.map +1 -0
- package/dist/frontend/comptime-node.test.d.ts +1 -0
- package/dist/frontend/comptime-node.test.js +37 -0
- package/dist/frontend/comptime-node.test.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +3 -4
- package/dist/frontend/dts-paths.js +15 -8
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/fork-target.js +2 -2
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/helper-tokens.d.ts +1 -0
- package/dist/frontend/helper-tokens.js +147 -0
- package/dist/frontend/helper-tokens.js.map +1 -0
- package/dist/frontend/helper-tokens.test.d.ts +1 -0
- package/dist/frontend/helper-tokens.test.js +35 -0
- package/dist/frontend/helper-tokens.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.d.ts +5 -0
- package/dist/frontend/inferred-js-diagnostics.js +69 -0
- package/dist/frontend/inferred-js-diagnostics.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.d.ts +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +58 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -0
- package/dist/frontend/input-tracker.d.ts +5 -2
- package/dist/frontend/input-tracker.js +24 -3
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +23 -0
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lib-contract.js +32 -24
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/literal-values.d.ts +4 -0
- package/dist/frontend/literal-values.js +21 -0
- package/dist/frontend/literal-values.js.map +1 -0
- package/dist/frontend/literal-values.test.d.ts +1 -0
- package/dist/frontend/literal-values.test.js +91 -0
- package/dist/frontend/literal-values.test.js.map +1 -0
- package/dist/frontend/lowering/abstract-equality.d.ts +1 -1
- package/dist/frontend/lowering/abstract-equality.js +3 -0
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.js +11 -6
- package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
- package/dist/frontend/lowering/array-values.d.ts +4 -1
- package/dist/frontend/lowering/array-values.js +43 -1
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/callback-arg.js +1 -0
- package/dist/frontend/lowering/callback-arg.js.map +1 -1
- package/dist/frontend/lowering/class-callbacks.d.ts +12 -0
- package/dist/frontend/lowering/class-callbacks.js +63 -0
- package/dist/frontend/lowering/class-callbacks.js.map +1 -0
- package/dist/frontend/lowering/class-descriptors.d.ts +9 -0
- package/dist/frontend/lowering/class-descriptors.js +73 -0
- package/dist/frontend/lowering/class-descriptors.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +41 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +803 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.d.ts +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +92 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -0
- package/dist/frontend/lowering/class-instance-constructor.d.ts +7 -0
- package/dist/frontend/lowering/class-instance-constructor.js +64 -0
- package/dist/frontend/lowering/class-instance-constructor.js.map +1 -0
- package/dist/frontend/lowering/class-method-values.d.ts +10 -0
- package/dist/frontend/lowering/class-method-values.js +170 -0
- package/dist/frontend/lowering/class-method-values.js.map +1 -0
- package/dist/frontend/lowering/class-prototypes.d.ts +16 -0
- package/dist/frontend/lowering/class-prototypes.js +134 -0
- package/dist/frontend/lowering/class-prototypes.js.map +1 -0
- package/dist/frontend/lowering/class-static-data.d.ts +6 -0
- package/dist/frontend/lowering/class-static-data.js +56 -0
- package/dist/frontend/lowering/class-static-data.js.map +1 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.d.ts +4 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.js +26 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.js.map +1 -0
- package/dist/frontend/lowering/containers/bytes.d.ts +11 -7
- package/dist/frontend/lowering/containers/bytes.js +164 -155
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +2 -2
- package/dist/frontend/lowering/containers/string-and-regexp.js +39 -16
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.d.ts +7 -0
- package/dist/frontend/lowering/containers/string-replacement.js +217 -0
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -0
- package/dist/frontend/lowering/error-methods.d.ts +11 -0
- package/dist/frontend/lowering/error-methods.js +78 -0
- package/dist/frontend/lowering/error-methods.js.map +1 -0
- package/dist/frontend/lowering/expressions/global-symbols.d.ts +6 -0
- package/dist/frontend/lowering/expressions/global-symbols.js +11 -0
- package/dist/frontend/lowering/expressions/global-symbols.js.map +1 -0
- package/dist/frontend/lowering/expressions/native-proxy.d.ts +7 -0
- package/dist/frontend/lowering/expressions/native-proxy.js +49 -0
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.d.ts +6 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js +124 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -0
- package/dist/frontend/lowering/expressions/object-literals.d.ts +8 -8
- package/dist/frontend/lowering/expressions/object-literals.js +485 -185
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +5 -6
- package/dist/frontend/lowering/expressions/optional-chains.js +27 -14
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/try-lower-expression.js +1 -0
- package/dist/frontend/lowering/expressions/try-lower-expression.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-field-write.d.ts +8 -0
- package/dist/frontend/lowering/expressions/union-field-write.js +71 -0
- package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -0
- package/dist/frontend/lowering/function-context.d.ts +93 -0
- package/dist/frontend/lowering/function-context.js +103 -0
- package/dist/frontend/lowering/function-context.js.map +1 -0
- package/dist/frontend/lowering/generator-delegation.d.ts +7 -0
- package/dist/frontend/lowering/generator-delegation.js +85 -0
- package/dist/frontend/lowering/generator-delegation.js.map +1 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +10 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +105 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.d.ts +2 -1
- package/dist/frontend/lowering/lib-boundary.js +59 -20
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.test.d.ts +1 -0
- package/dist/frontend/lowering/lib-boundary.test.js +45 -0
- package/dist/frontend/lowering/lib-boundary.test.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +1 -1
- package/dist/frontend/lowering/lower-assert.d.ts +1 -1
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +12 -0
- package/dist/frontend/lowering/lower-builtin-values.js +139 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -0
- package/dist/frontend/lowering/lower-builtins.d.ts +27 -41
- package/dist/frontend/lowering/lower-builtins.js +553 -346
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +22 -26
- package/dist/frontend/lowering/lower-calls.js +1373 -380
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +83 -45
- package/dist/frontend/lowering/lower-classes.js +952 -339
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
- package/dist/frontend/lowering/lower-comptime.js +23 -32
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +27 -32
- package/dist/frontend/lowering/lower-containers.js +796 -151
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.d.ts +1 -1
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.d.ts +1 -1
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +30 -1
- package/dist/frontend/lowering/lower-event-emitter.js +58 -26
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.d.ts +7 -1
- package/dist/frontend/lowering/lower-expando.js +14 -6
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +35 -11
- package/dist/frontend/lowering/lower-exprs.js +1785 -790
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +2 -5
- package/dist/frontend/lowering/lower-generators.js +77 -46
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +7 -0
- package/dist/frontend/lowering/lower-global-value.js +17 -0
- package/dist/frontend/lowering/lower-global-value.js.map +1 -0
- package/dist/frontend/lowering/lower-inspect.d.ts +1 -1
- package/dist/frontend/lowering/lower-inspect.js +17 -8
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +5 -8
- package/dist/frontend/lowering/lower-island.js +34 -23
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.d.ts +2 -2
- package/dist/frontend/lowering/lower-mixins.js +5 -3
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +1 -1
- package/dist/frontend/lowering/lower-modules.js +252 -38
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +1 -1
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-module.d.ts +1 -1
- package/dist/frontend/lowering/lower-node-module.js +13 -10
- package/dist/frontend/lowering/lower-node-module.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +1 -1
- package/dist/frontend/lowering/lower-server.js +6 -10
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +10 -14
- package/dist/frontend/lowering/lower-stmts.js +731 -532
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +1 -1
- package/dist/frontend/lowering/lower-stream.js +19 -10
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.d.ts +1 -1
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lower-url.d.ts +6 -0
- package/dist/frontend/lowering/lower-url.js +77 -0
- package/dist/frontend/lowering/lower-url.js.map +1 -0
- package/dist/frontend/lowering/lowerer.d.ts +113 -189
- package/dist/frontend/lowering/lowerer.js +1033 -663
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.d.ts +1 -0
- package/dist/frontend/lowering/lowerer.test.js +26 -0
- package/dist/frontend/lowering/lowerer.test.js.map +1 -0
- package/dist/frontend/lowering/native-ffi.d.ts +5 -0
- package/dist/frontend/lowering/native-ffi.js +40 -0
- package/dist/frontend/lowering/native-ffi.js.map +1 -0
- package/dist/frontend/lowering/object-enumeration-receiver.d.ts +7 -0
- package/dist/frontend/lowering/object-enumeration-receiver.js +33 -0
- package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -0
- package/dist/frontend/lowering/object-factory-new.d.ts +8 -0
- package/dist/frontend/lowering/object-factory-new.js +68 -0
- package/dist/frontend/lowering/object-factory-new.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.js +6 -1
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/pairs-snapshot.js +2 -1
- package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-locals.d.ts +14 -0
- package/dist/frontend/lowering/runtime-optional-locals.js +41 -0
- package/dist/frontend/lowering/runtime-optional-locals.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.d.ts +1 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.js +85 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.js.map +1 -0
- package/dist/frontend/lowering/sanitize-class-types.d.ts +8 -0
- package/dist/frontend/lowering/sanitize-class-types.js +79 -0
- package/dist/frontend/lowering/sanitize-class-types.js.map +1 -0
- package/dist/frontend/lowering/sanitize-class-types.test.d.ts +1 -0
- package/dist/frontend/lowering/sanitize-class-types.test.js +60 -0
- package/dist/frontend/lowering/sanitize-class-types.test.js.map +1 -0
- package/dist/frontend/lowering/static-this.d.ts +5 -1
- package/dist/frontend/lowering/static-this.js +28 -2
- package/dist/frontend/lowering/static-this.js.map +1 -1
- package/dist/frontend/lowering/string-index.d.ts +7 -0
- package/dist/frontend/lowering/string-index.js +39 -0
- package/dist/frontend/lowering/string-index.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +9 -4
- package/dist/frontend/lowering/surfaces.js +98 -35
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/symbol-fields.d.ts +22 -0
- package/dist/frontend/lowering/symbol-fields.js +183 -0
- package/dist/frontend/lowering/symbol-fields.js.map +1 -0
- package/dist/frontend/lowering/symbol-methods.d.ts +7 -0
- package/dist/frontend/lowering/symbol-methods.js +30 -0
- package/dist/frontend/lowering/symbol-methods.js.map +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.d.ts +10 -0
- package/dist/frontend/lowering/text-decoder-encoding.js +77 -0
- package/dist/frontend/lowering/text-decoder-encoding.js.map +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.d.ts +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.js +38 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.js.map +1 -0
- package/dist/frontend/lowering/union-narrow.d.ts +9 -0
- package/dist/frontend/lowering/union-narrow.js +59 -0
- package/dist/frontend/lowering/union-narrow.js.map +1 -0
- package/dist/frontend/lowering/union-narrow.test.d.ts +1 -0
- package/dist/frontend/lowering/union-narrow.test.js +72 -0
- package/dist/frontend/lowering/union-narrow.test.js.map +1 -0
- package/dist/frontend/lowering/union-retag.d.ts +43 -0
- package/dist/frontend/lowering/union-retag.js +259 -0
- package/dist/frontend/lowering/union-retag.js.map +1 -0
- package/dist/frontend/lowering/union-retag.test.d.ts +1 -0
- package/dist/frontend/lowering/union-retag.test.js +405 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -0
- package/dist/frontend/lowering/unregistered-class-types.d.ts +14 -0
- package/dist/frontend/lowering/unregistered-class-types.js +94 -0
- package/dist/frontend/lowering/unregistered-class-types.js.map +1 -0
- package/dist/frontend/lowering/unregistered-class-types.test.d.ts +1 -0
- package/dist/frontend/lowering/unregistered-class-types.test.js +65 -0
- package/dist/frontend/lowering/unregistered-class-types.test.js.map +1 -0
- package/dist/frontend/lowering/width-lift.d.ts +40 -0
- package/dist/frontend/lowering/width-lift.js +2 -0
- package/dist/frontend/lowering/width-lift.js.map +1 -0
- package/dist/frontend/module-syntax.d.ts +58 -0
- package/dist/frontend/module-syntax.js +123 -0
- package/dist/frontend/module-syntax.js.map +1 -0
- package/dist/frontend/module-syntax.test.d.ts +1 -0
- package/dist/frontend/module-syntax.test.js +78 -0
- package/dist/frontend/module-syntax.test.js.map +1 -0
- package/dist/frontend/npm-fetch-analysis.d.ts +17 -0
- package/dist/frontend/npm-fetch-analysis.js +100 -0
- package/dist/frontend/npm-fetch-analysis.js.map +1 -0
- package/dist/frontend/npm-fetch-analysis.test.d.ts +1 -0
- package/dist/frontend/npm-fetch-analysis.test.js +107 -0
- package/dist/frontend/npm-fetch-analysis.test.js.map +1 -0
- package/dist/frontend/npm-fetch-node.d.ts +2 -0
- package/dist/frontend/npm-fetch-node.js +12 -0
- package/dist/frontend/npm-fetch-node.js.map +1 -0
- package/dist/frontend/npm-fetch-syntax.d.ts +6 -0
- package/dist/frontend/npm-fetch-syntax.js +207 -0
- package/dist/frontend/npm-fetch-syntax.js.map +1 -0
- package/dist/frontend/npm-node.d.ts +10 -0
- package/dist/frontend/npm-node.js +14 -0
- package/dist/frontend/npm-node.js.map +1 -0
- package/dist/frontend/npm-static-bundled-cjs.d.ts +8 -0
- package/dist/frontend/npm-static-bundled-cjs.js +236 -0
- package/dist/frontend/npm-static-bundled-cjs.js.map +1 -0
- package/dist/frontend/npm-static-bundled-cjs.test.d.ts +1 -0
- package/dist/frontend/npm-static-bundled-cjs.test.js +69 -0
- package/dist/frontend/npm-static-bundled-cjs.test.js.map +1 -0
- package/dist/frontend/npm-static-declaration-syntax.d.ts +57 -0
- package/dist/frontend/npm-static-declaration-syntax.js +944 -0
- package/dist/frontend/npm-static-declaration-syntax.js.map +1 -0
- package/dist/frontend/npm-static-declarations.d.ts +11 -39
- package/dist/frontend/npm-static-declarations.js +22 -561
- package/dist/frontend/npm-static-declarations.js.map +1 -1
- package/dist/frontend/npm-static-declarations.test.js +245 -6
- package/dist/frontend/npm-static-declarations.test.js.map +1 -1
- package/dist/frontend/npm-static-prune.d.ts +1 -1
- package/dist/frontend/npm-static-prune.js +5 -4
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-prune.test.js +1 -1
- package/dist/frontend/npm-static-prune.test.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-host.d.ts +4 -0
- package/dist/frontend/npm-static-rewrite-host.js +179 -0
- package/dist/frontend/npm-static-rewrite-host.js.map +1 -0
- package/dist/frontend/npm-static-rewrite-syntax.d.ts +16 -0
- package/dist/frontend/npm-static-rewrite-syntax.js +905 -0
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -0
- package/dist/frontend/npm-static-rewrite.d.ts +0 -5
- package/dist/frontend/npm-static-rewrite.js +2 -1079
- package/dist/frontend/npm-static-rewrite.js.map +1 -1
- package/dist/frontend/npm-static-subtyping.d.ts +5 -0
- package/dist/frontend/npm-static-subtyping.js +55 -0
- package/dist/frontend/npm-static-subtyping.js.map +1 -0
- package/dist/frontend/npm-static-subtyping.test.d.ts +1 -0
- package/dist/frontend/npm-static-subtyping.test.js +58 -0
- package/dist/frontend/npm-static-subtyping.test.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +7 -15
- package/dist/frontend/npm-static.js +19 -28
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +8 -69
- package/dist/frontend/npm.js +21 -361
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +2 -2
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.d.ts +6 -0
- package/dist/frontend/pipeline-native.js +32 -0
- package/dist/frontend/pipeline-native.js.map +1 -0
- package/dist/frontend/pipeline.d.ts +54 -0
- package/dist/frontend/pipeline.js +382 -0
- package/dist/frontend/pipeline.js.map +1 -0
- package/dist/frontend/pipeline.test.d.ts +1 -0
- package/dist/frontend/pipeline.test.js +77 -0
- package/dist/frontend/pipeline.test.js.map +1 -0
- package/dist/frontend/program-analysis.d.ts +10 -0
- package/dist/frontend/program-analysis.js +14 -0
- package/dist/frontend/program-analysis.js.map +1 -0
- package/dist/frontend/program-node.d.ts +9 -0
- package/dist/frontend/program-node.js +48 -0
- package/dist/frontend/program-node.js.map +1 -0
- package/dist/frontend/program.d.ts +43 -19
- package/dist/frontend/program.js +556 -197
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.d.ts +1 -0
- package/dist/frontend/program.test.js +202 -0
- package/dist/frontend/program.test.js.map +1 -0
- package/dist/frontend/provenance-core.d.ts +9 -0
- package/dist/frontend/provenance-core.js +435 -0
- package/dist/frontend/provenance-core.js.map +1 -0
- package/dist/frontend/provenance.d.ts +0 -4
- package/dist/frontend/provenance.js +4 -459
- package/dist/frontend/provenance.js.map +1 -1
- package/dist/frontend/resolve.d.ts +3 -1
- package/dist/frontend/resolve.js +6 -3
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.d.ts +4 -3
- package/dist/frontend/runtime-resolve.js +22 -18
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.test.js +53 -0
- package/dist/frontend/runtime-resolve.test.js.map +1 -1
- package/dist/frontend/services-node.d.ts +5 -0
- package/dist/frontend/services-node.js +19 -0
- package/dist/frontend/services-node.js.map +1 -0
- package/dist/frontend/services-node.test.d.ts +1 -0
- package/dist/frontend/services-node.test.js +70 -0
- package/dist/frontend/services-node.test.js.map +1 -0
- package/dist/frontend/services.d.ts +44 -0
- package/dist/frontend/services.js +90 -0
- package/dist/frontend/services.js.map +1 -0
- package/dist/frontend/services.test.d.ts +1 -0
- package/dist/frontend/services.test.js +174 -0
- package/dist/frontend/services.test.js.map +1 -0
- package/dist/frontend/ts7/adapter.d.ts +3 -3
- package/dist/frontend/ts7/adapter.js +14 -31
- package/dist/frontend/ts7/adapter.js.map +1 -1
- package/dist/frontend/ts7/api.d.ts +16 -0
- package/dist/frontend/ts7/api.js +24 -0
- package/dist/frontend/ts7/api.js.map +1 -0
- package/dist/frontend/ts7/ast-bytes.d.ts +31 -0
- package/dist/frontend/ts7/ast-bytes.js +137 -0
- package/dist/frontend/ts7/ast-bytes.js.map +1 -0
- package/dist/frontend/ts7/ast-bytes.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-bytes.test.js +73 -0
- package/dist/frontend/ts7/ast-bytes.test.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.generated.d.ts +353 -0
- package/dist/frontend/ts7/ast-guards.generated.js +1951 -0
- package/dist/frontend/ts7/ast-guards.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-guards.test.js +43 -0
- package/dist/frontend/ts7/ast-guards.test.js.map +1 -0
- package/dist/frontend/ts7/ast-node.d.ts +194 -0
- package/dist/frontend/ts7/ast-node.js +448 -0
- package/dist/frontend/ts7/ast-node.js.map +1 -0
- package/dist/frontend/ts7/ast-node.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-node.test.js +266 -0
- package/dist/frontend/ts7/ast-node.test.js.map +1 -0
- package/dist/frontend/ts7/ast-schema.generated.d.ts +503 -0
- package/dist/frontend/ts7/ast-schema.generated.js +1446 -0
- package/dist/frontend/ts7/ast-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-text.d.ts +6 -0
- package/dist/frontend/ts7/ast-text.js +124 -0
- package/dist/frontend/ts7/ast-text.js.map +1 -0
- package/dist/frontend/ts7/ast-text.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-text.test.js +38 -0
- package/dist/frontend/ts7/ast-text.test.js.map +1 -0
- package/dist/frontend/ts7/ast-tokens.generated.d.ts +2 -0
- package/dist/frontend/ts7/ast-tokens.generated.js +155 -0
- package/dist/frontend/ts7/ast-tokens.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-types.d.ts +42 -0
- package/dist/frontend/ts7/ast-types.generated.d.ts +1615 -0
- package/dist/frontend/ts7/ast-types.generated.js +5 -0
- package/dist/frontend/ts7/ast-types.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-types.js +3 -0
- package/dist/frontend/ts7/ast-types.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.d.ts +58 -0
- package/dist/frontend/ts7/ast-wire.js +267 -0
- package/dist/frontend/ts7/ast-wire.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-wire.test.js +151 -0
- package/dist/frontend/ts7/ast-wire.test.js.map +1 -0
- package/dist/frontend/ts7/ast.d.ts +14 -14
- package/dist/frontend/ts7/ast.js +21 -15
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/census-check.js +1 -0
- package/dist/frontend/ts7/census-check.js.map +1 -1
- package/dist/frontend/ts7/checker-cache.d.ts +48 -0
- package/dist/frontend/ts7/checker-cache.js +92 -0
- package/dist/frontend/ts7/checker-cache.js.map +1 -0
- package/dist/frontend/ts7/checker.d.ts +19 -46
- package/dist/frontend/ts7/checker.js +231 -161
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.d.ts +1 -0
- package/dist/frontend/ts7/checker.test.js +335 -0
- package/dist/frontend/ts7/checker.test.js.map +1 -0
- package/dist/frontend/ts7/enums.d.ts +4 -27
- package/dist/frontend/ts7/enums.generated.d.ts +878 -0
- package/dist/frontend/ts7/enums.generated.js +1313 -0
- package/dist/frontend/ts7/enums.generated.js.map +1 -0
- package/dist/frontend/ts7/enums.js +4 -45
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/enums.test.d.ts +1 -0
- package/dist/frontend/ts7/enums.test.js +48 -0
- package/dist/frontend/ts7/enums.test.js.map +1 -0
- package/dist/frontend/ts7/native-api.d.ts +10 -0
- package/dist/frontend/ts7/native-api.js +10 -0
- package/dist/frontend/ts7/native-api.js.map +1 -0
- package/dist/frontend/ts7/native-host.d.ts +2 -0
- package/dist/frontend/ts7/native-host.js +11 -0
- package/dist/frontend/ts7/native-host.js.map +1 -0
- package/dist/frontend/ts7/native-process.d.ts +14 -0
- package/dist/frontend/ts7/native-process.js +62 -0
- package/dist/frontend/ts7/native-process.js.map +1 -0
- package/dist/frontend/ts7/program-adapter.d.ts +10 -98
- package/dist/frontend/ts7/program-adapter.js +16 -310
- package/dist/frontend/ts7/program-adapter.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +115 -0
- package/dist/frontend/ts7/program-host.js +347 -0
- package/dist/frontend/ts7/program-host.js.map +1 -0
- package/dist/frontend/ts7/program-host.test.d.ts +1 -0
- package/dist/frontend/ts7/program-host.test.js +207 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-api.d.ts +12 -0
- package/dist/frontend/ts7/rpc-api.js +23 -0
- package/dist/frontend/ts7/rpc-api.js.map +1 -0
- package/dist/frontend/ts7/rpc-client.d.ts +27 -0
- package/dist/frontend/ts7/rpc-client.js +102 -0
- package/dist/frontend/ts7/rpc-client.js.map +1 -0
- package/dist/frontend/ts7/rpc-client.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-client.test.js +133 -0
- package/dist/frontend/ts7/rpc-client.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-filesystem.d.ts +16 -0
- package/dist/frontend/ts7/rpc-filesystem.js +42 -0
- package/dist/frontend/ts7/rpc-filesystem.js.map +1 -0
- package/dist/frontend/ts7/rpc-filesystem.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-filesystem.test.js +89 -0
- package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-process.d.ts +2 -0
- package/dist/frontend/ts7/rpc-process.js +148 -0
- package/dist/frontend/ts7/rpc-process.js.map +1 -0
- package/dist/frontend/ts7/rpc-process.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-process.test.js +29 -0
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-wire.d.ts +46 -0
- package/dist/frontend/ts7/rpc-wire.js +195 -0
- package/dist/frontend/ts7/rpc-wire.js.map +1 -0
- package/dist/frontend/ts7/rpc-wire.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-wire.test.js +168 -0
- package/dist/frontend/ts7/rpc-wire.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-checker.d.ts +137 -0
- package/dist/frontend/ts7/semantic-checker.js +221 -0
- package/dist/frontend/ts7/semantic-checker.js.map +1 -0
- package/dist/frontend/ts7/semantic-checker.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-checker.test.js +119 -0
- package/dist/frontend/ts7/semantic-checker.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-json.d.ts +5 -0
- package/dist/frontend/ts7/semantic-json.js +52 -0
- package/dist/frontend/ts7/semantic-json.js.map +1 -0
- package/dist/frontend/ts7/semantic-json.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-json.test.js +42 -0
- package/dist/frontend/ts7/semantic-json.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-model.d.ts +222 -0
- package/dist/frontend/ts7/semantic-model.js +423 -0
- package/dist/frontend/ts7/semantic-model.js.map +1 -0
- package/dist/frontend/ts7/semantic-model.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-model.test.js +322 -0
- package/dist/frontend/ts7/semantic-model.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-schema.generated.d.ts +283 -0
- package/dist/frontend/ts7/semantic-schema.generated.js +222 -0
- package/dist/frontend/ts7/semantic-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/semantic-types.d.ts +5 -0
- package/dist/frontend/ts7/semantic-types.js +2 -0
- package/dist/frontend/ts7/semantic-types.js.map +1 -0
- package/dist/frontend/ts7/session-cache.d.ts +17 -0
- package/dist/frontend/ts7/session-cache.js +97 -0
- package/dist/frontend/ts7/session-cache.js.map +1 -0
- package/dist/frontend/ts7/session-cache.test.d.ts +1 -0
- package/dist/frontend/ts7/session-cache.test.js +87 -0
- package/dist/frontend/ts7/session-cache.test.js.map +1 -0
- package/dist/frontend/ts7/session-path.d.ts +18 -0
- package/dist/frontend/ts7/session-path.js +203 -0
- package/dist/frontend/ts7/session-path.js.map +1 -0
- package/dist/frontend/ts7/session-path.test.d.ts +1 -0
- package/dist/frontend/ts7/session-path.test.js +34 -0
- package/dist/frontend/ts7/session-path.test.js.map +1 -0
- package/dist/frontend/ts7/session-schema.generated.d.ts +167 -0
- package/dist/frontend/ts7/session-schema.generated.js +5 -0
- package/dist/frontend/ts7/session-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/session-timing.d.ts +50 -0
- package/dist/frontend/ts7/session-timing.js +61 -0
- package/dist/frontend/ts7/session-timing.js.map +1 -0
- package/dist/frontend/ts7/session-timing.test.d.ts +1 -0
- package/dist/frontend/ts7/session-timing.test.js +52 -0
- package/dist/frontend/ts7/session-timing.test.js.map +1 -0
- package/dist/frontend/ts7/session.d.ts +105 -0
- package/dist/frontend/ts7/session.js +233 -0
- package/dist/frontend/ts7/session.js.map +1 -0
- package/dist/frontend/ts7/session.test.d.ts +1 -0
- package/dist/frontend/ts7/session.test.js +215 -0
- package/dist/frontend/ts7/session.test.js.map +1 -0
- package/dist/frontend/ts7/source-parser-node.d.ts +6 -0
- package/dist/frontend/ts7/source-parser-node.js +15 -0
- package/dist/frontend/ts7/source-parser-node.js.map +1 -0
- package/dist/frontend/ts7/source-parser.d.ts +25 -0
- package/dist/frontend/ts7/source-parser.js +96 -0
- package/dist/frontend/ts7/source-parser.js.map +1 -0
- package/dist/frontend/ts7/source-parser.test.d.ts +1 -0
- package/dist/frontend/ts7/source-parser.test.js +151 -0
- package/dist/frontend/ts7/source-parser.test.js.map +1 -0
- package/dist/frontend/ts7/syntax.d.ts +3 -0
- package/dist/frontend/ts7/syntax.js +4 -0
- package/dist/frontend/ts7/syntax.js.map +1 -0
- package/dist/frontend/tsc-codes.js +3 -0
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +29 -19
- package/dist/frontend/type-mapper.js +713 -306
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.d.ts +1 -0
- package/dist/frontend/type-mapper.test.js +207 -0
- package/dist/frontend/type-mapper.test.js.map +1 -0
- package/dist/frontend/union-discriminants.d.ts +16 -0
- package/dist/frontend/union-discriminants.js +98 -0
- package/dist/frontend/union-discriminants.js.map +1 -0
- package/dist/frontend/union-discriminants.test.d.ts +1 -0
- package/dist/frontend/union-discriminants.test.js +182 -0
- package/dist/frontend/union-discriminants.test.js.map +1 -0
- package/dist/index.d.ts +7 -197
- package/dist/index.js +369 -1567
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +16 -4
- package/dist/ir/analysis.js +25 -6
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +15 -2
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/constant-tables.js +67 -49
- package/dist/ir/constant-tables.js.map +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/control-flow.d.ts +6 -0
- package/dist/ir/control-flow.js +142 -0
- package/dist/ir/control-flow.js.map +1 -0
- package/dist/ir/control-flow.test.d.ts +1 -0
- package/dist/ir/control-flow.test.js +113 -0
- package/dist/ir/control-flow.test.js.map +1 -0
- package/dist/ir/integer-loops.js +7 -18
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-ranges.js +53 -27
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +309 -164
- package/dist/ir/ir.js +588 -879
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +127 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/scalar-records.js +165 -134
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +4 -2
- package/dist/ir/serialize.js +19 -12
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.d.ts +1 -0
- package/dist/ir/serialize.test.js +53 -0
- package/dist/ir/serialize.test.js.map +1 -0
- package/dist/ir/traverse.d.ts +41 -0
- package/dist/ir/traverse.js +660 -0
- package/dist/ir/traverse.js.map +1 -0
- package/dist/ir/traverse.test.d.ts +1 -0
- package/dist/ir/traverse.test.js +242 -0
- package/dist/ir/traverse.test.js.map +1 -0
- package/dist/ir/validate.js +1956 -1496
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +476 -2
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/cache-primitives.d.ts +2 -3
- package/dist/library/cache-primitives.js +4 -6
- package/dist/library/cache-primitives.js.map +1 -1
- package/dist/library/compiler-self-identity.d.ts +1 -1
- package/dist/library/compiler-self-identity.js +31 -15
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.d.ts +1 -0
- package/dist/library/compiler-self-identity.test.js +93 -0
- package/dist/library/compiler-self-identity.test.js.map +1 -0
- package/dist/library/fence-eval.js +2 -2
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.js +7 -6
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/library-cache.d.ts +3 -2
- package/dist/library/library-cache.js +5 -17
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +54 -41
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/library-profile.d.ts +3 -1
- package/dist/library/library-profile.js +15 -6
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/prepare.d.ts +15 -0
- package/dist/library/prepare.js +584 -0
- package/dist/library/prepare.js.map +1 -0
- package/dist/library/semantic-source.d.ts +1 -1
- package/dist/library/semantic-source.js +8 -6
- package/dist/library/semantic-source.js.map +1 -1
- package/dist/library/sidecar-validate.js +4 -4
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.d.ts +2 -0
- package/dist/library/sidecar.js +10 -3
- package/dist/library/sidecar.js.map +1 -1
- package/dist/native/cache.d.ts +11 -0
- package/dist/native/cache.js +113 -0
- package/dist/native/cache.js.map +1 -0
- package/dist/native/cache.test.d.ts +1 -0
- package/dist/native/cache.test.js +66 -0
- package/dist/native/cache.test.js.map +1 -0
- package/dist/native/cli.d.ts +1 -0
- package/dist/native/cli.js +112 -0
- package/dist/native/cli.js.map +1 -0
- package/dist/native/compiler.d.ts +15 -0
- package/dist/native/compiler.js +336 -0
- package/dist/native/compiler.js.map +1 -0
- package/dist/native/compiler.test.d.ts +1 -0
- package/dist/native/compiler.test.js +174 -0
- package/dist/native/compiler.test.js.map +1 -0
- package/dist/native/comptime.d.ts +5 -0
- package/dist/native/comptime.js +73 -0
- package/dist/native/comptime.js.map +1 -0
- package/dist/native/comptime.test.d.ts +1 -0
- package/dist/native/comptime.test.js +65 -0
- package/dist/native/comptime.test.js.map +1 -0
- package/dist/native/executable-cache.d.ts +26 -0
- package/dist/native/executable-cache.js +228 -0
- package/dist/native/executable-cache.js.map +1 -0
- package/dist/native/executable-cache.test.d.ts +1 -0
- package/dist/native/executable-cache.test.js +151 -0
- package/dist/native/executable-cache.test.js.map +1 -0
- package/dist/native/file-identity.d.ts +4 -0
- package/dist/native/file-identity.js +14 -0
- package/dist/native/file-identity.js.map +1 -0
- package/dist/native/file-identity.test.d.ts +1 -0
- package/dist/native/file-identity.test.js +43 -0
- package/dist/native/file-identity.test.js.map +1 -0
- package/dist/native/library.d.ts +22 -0
- package/dist/native/library.js +83 -0
- package/dist/native/library.js.map +1 -0
- package/dist/native/prepare.d.ts +21 -0
- package/dist/native/prepare.js +174 -0
- package/dist/native/prepare.js.map +1 -0
- package/dist/native/prepare.test.d.ts +1 -0
- package/dist/native/prepare.test.js +70 -0
- package/dist/native/prepare.test.js.map +1 -0
- package/dist/native/sanitizer.d.ts +11 -0
- package/dist/native/sanitizer.js +135 -0
- package/dist/native/sanitizer.js.map +1 -0
- package/dist/native/sanitizer.test.d.ts +1 -0
- package/dist/native/sanitizer.test.js +58 -0
- package/dist/native/sanitizer.test.js.map +1 -0
- package/dist/native/task.d.ts +4 -0
- package/dist/native/task.js +16 -0
- package/dist/native/task.js.map +1 -0
- package/dist/native/task.test.d.ts +1 -0
- package/dist/native/task.test.js +17 -0
- package/dist/native/task.test.js.map +1 -0
- package/dist/native/toolchain.d.ts +45 -0
- package/dist/native/toolchain.js +74 -0
- package/dist/native/toolchain.js.map +1 -0
- package/dist/native/toolchain.test.d.ts +1 -0
- package/dist/native/toolchain.test.js +33 -0
- package/dist/native/toolchain.test.js.map +1 -0
- package/dist/startup-cache.d.ts +1 -1
- package/dist/startup-cache.js +2 -5
- package/dist/startup-cache.js.map +1 -1
- package/dist/timing.d.ts +4 -0
- package/dist/timing.js +19 -0
- package/dist/timing.js.map +1 -0
- package/dist/wasi-paths.js +10 -7
- package/dist/wasi-paths.js.map +1 -1
- package/package.json +28 -19
- package/surface-manifest.json +171 -18
- package/dist/backend/c/async.d.ts +0 -171
- package/dist/backend/c/async.js +0 -1317
- package/dist/backend/c/async.js.map +0 -1
- package/dist/backend/c/c-emitter.d.ts +0 -531
- package/dist/backend/c/c-emitter.js +0 -1917
- package/dist/backend/c/c-emitter.js.map +0 -1
- package/dist/backend/c/exprs.d.ts +0 -15
- package/dist/backend/c/exprs.js +0 -8803
- package/dist/backend/c/exprs.js.map +0 -1
- package/dist/backend/c/island.d.ts +0 -45
- package/dist/backend/c/island.js +0 -281
- package/dist/backend/c/island.js.map +0 -1
- package/dist/backend/c/may-throw.js.map +0 -1
- package/dist/backend/c/shapes.d.ts +0 -142
- package/dist/backend/c/shapes.js +0 -603
- package/dist/backend/c/shapes.js.map +0 -1
- package/dist/backend/c/stmts.d.ts +0 -76
- package/dist/backend/c/stmts.js +0 -1084
- package/dist/backend/c/stmts.js.map +0 -1
- package/dist/backend/c/types.d.ts +0 -71
- package/dist/backend/c/types.js +0 -459
- package/dist/backend/c/types.js.map +0 -1
- package/dist/backend/c/types.test.js +0 -32
- package/dist/backend/c/types.test.js.map +0 -1
- package/dist/backend/c/walkers.d.ts +0 -134
- package/dist/backend/c/walkers.js +0 -1773
- package/dist/backend/c/walkers.js.map +0 -1
- /package/dist/backend/{c/types.test.d.ts → cycle-analysis.test.d.ts} +0 -0
package/dist/frontend/program.js
CHANGED
|
@@ -46,15 +46,17 @@ import { isNodeModulesPath, nearestInvalidPackageJsonPath, nearestPackageType, n
|
|
|
46
46
|
import { probeNodeImportRefusal, probeNodeRequireRefusal } from "./npm.js";
|
|
47
47
|
import { isNpmStaticPackage, npmStaticActive, npmStaticFsShadow, npmStaticPackageOfPath, reportNpmStaticOffender, setNpmStaticDeclarationOverloads, setNpmStaticPackages } from "./npm-static.js";
|
|
48
48
|
import { isPrunedNpmReexport, planNpmStaticReexports } from "./npm-static-prune.js";
|
|
49
|
-
import {
|
|
49
|
+
import { isNpmStaticSubclassArgument } from "./npm-static-subtyping.js";
|
|
50
|
+
import { npmStaticDeclarationReexports, npmStaticRuntimeClassTargets, parseNpmStaticDeclarationOverloads, parseNpmStaticDeclarationProperties } from "./npm-static-declaration-syntax.js";
|
|
50
51
|
import { provenanceEntryFor, provenancePaths } from "./provenance-registry.js";
|
|
51
|
-
import {
|
|
52
|
+
import { cjsLexedExportsOfFile, cjsVisibleNames } from "./cjs-syntax.js";
|
|
52
53
|
import { ambientDtsPath, fallbackDtsPath, isNodeTypesPath, overridesDtsPath, tsgoPath, } from "./dts-paths.js";
|
|
53
54
|
import { builtinDefaultImportModule, canonicalBuiltinModule, SUPPORTED_NODE_MODULES, unsupportedModuleFeatureOf, } from "./builtin-modules.js";
|
|
54
55
|
import { clearWorkspacePackages, isRelativeSpecifier, isWorkspacePackageName, npmPackageNameOf, registerWorkspacePackage, workspacePackageOfPath, } from "./workspace-registry.js";
|
|
55
56
|
import { ADOPTED_OPTIONS, isJsSourceFileName, JS_ANY_OPERATOR_CODES, JS_RELAXED_TSC_CODES, } from "./tsc-codes.js";
|
|
56
57
|
import { trackedFileExists, trackedReadFile, trackedRealpath } from "./input-tracker.js";
|
|
57
58
|
import { forkTargetPaths } from "./fork-target.js";
|
|
59
|
+
import { inferredJsDiagnosticSuppressed } from "./inferred-js-diagnostics.js";
|
|
58
60
|
const BASE_OPTIONS = {
|
|
59
61
|
strict: true,
|
|
60
62
|
};
|
|
@@ -127,6 +129,25 @@ function jsoncSyntaxError(text) {
|
|
|
127
129
|
return e instanceof Error ? e.message : String(e);
|
|
128
130
|
}
|
|
129
131
|
}
|
|
132
|
+
/** Preserve TypeScript 5.9's computed synthetic-default permission from the
|
|
133
|
+
* project's own module settings. Preflight later forces ESNext/Bundler for
|
|
134
|
+
* scriptc's checker, so those forced options must not decide which source
|
|
135
|
+
* import forms were legal in the original project. */
|
|
136
|
+
function projectAllowsSyntheticDefaultImports(options) {
|
|
137
|
+
const explicitSyntheticDefaultImports = options["allowSyntheticDefaultImports"];
|
|
138
|
+
if (explicitSyntheticDefaultImports !== undefined)
|
|
139
|
+
return explicitSyntheticDefaultImports === true;
|
|
140
|
+
const moduleKind = options["module"];
|
|
141
|
+
const explicitEsModuleInterop = options["esModuleInterop"];
|
|
142
|
+
const esModuleInterop = explicitEsModuleInterop !== undefined
|
|
143
|
+
? explicitEsModuleInterop === true
|
|
144
|
+
: moduleKind === ts.ModuleKind.Node16 ||
|
|
145
|
+
moduleKind === ts.ModuleKind.Node18 ||
|
|
146
|
+
moduleKind === ts.ModuleKind.Node20 ||
|
|
147
|
+
moduleKind === ts.ModuleKind.NodeNext ||
|
|
148
|
+
moduleKind === ts.ModuleKind.Preserve;
|
|
149
|
+
return esModuleInterop || moduleKind === ts.ModuleKind.System || options["moduleResolution"] === ts.ModuleResolutionKind.Bundler;
|
|
150
|
+
}
|
|
130
151
|
/** The project's tsconfig adoption in the 7 world: tsgo's own config parser
|
|
131
152
|
* (extends chains resolved server-side), the ADOPTED_OPTIONS subset taken,
|
|
132
153
|
* the rest forced, the strictNullChecks floor enforced. */
|
|
@@ -148,6 +169,9 @@ function adoptProjectConfig7(host, entryPath) {
|
|
|
148
169
|
if (value !== undefined)
|
|
149
170
|
adopted[key] = value;
|
|
150
171
|
}
|
|
172
|
+
if (projectAllowsSyntheticDefaultImports(parsed.options)) {
|
|
173
|
+
adopted["allowSyntheticDefaultImports"] = true;
|
|
174
|
+
}
|
|
151
175
|
// TS 7 accepts `paths`, but no longer accepts `baseUrl` as a compiler
|
|
152
176
|
// option. Translate the established baseUrl+paths spelling into absolute
|
|
153
177
|
// targets: the synthesized config lives beside the entry rather than the
|
|
@@ -220,7 +244,7 @@ function runtimeReexportTarget(fromFile, specifier) {
|
|
|
220
244
|
/** Visits an opted package's own declaration entry and relative barrel
|
|
221
245
|
* closure. This is intentionally narrower than TypeScript module
|
|
222
246
|
* resolution: bare edges name other packages and never inherit trust. */
|
|
223
|
-
function visitNpmStaticDeclarationClosure(entryPath, onSource) {
|
|
247
|
+
function visitNpmStaticDeclarationClosure(services, entryPath, onSource) {
|
|
224
248
|
const seen = new Set();
|
|
225
249
|
const packageJson = nearestPkgJsonPath(entryPath);
|
|
226
250
|
const packageRoot = (packageJson === null ? dirname(entryPath) : dirname(packageJson)).split("\\").join("/");
|
|
@@ -236,7 +260,7 @@ function visitNpmStaticDeclarationClosure(entryPath, onSource) {
|
|
|
236
260
|
if (source === null)
|
|
237
261
|
return;
|
|
238
262
|
onSource(path, source);
|
|
239
|
-
for (const specifier of npmStaticDeclarationReexports(path, source)) {
|
|
263
|
+
for (const specifier of npmStaticDeclarationReexports(services.parse(path, source, "ts"))) {
|
|
240
264
|
const target = declarationReexportTarget(path, specifier);
|
|
241
265
|
if (target !== null)
|
|
242
266
|
visit(target);
|
|
@@ -244,10 +268,10 @@ function visitNpmStaticDeclarationClosure(entryPath, onSource) {
|
|
|
244
268
|
};
|
|
245
269
|
visit(entryPath);
|
|
246
270
|
}
|
|
247
|
-
function npmStaticDeclarationOverloadsOf(entryPath) {
|
|
271
|
+
function npmStaticDeclarationOverloadsOf(services, entryPath) {
|
|
248
272
|
const classes = new Map();
|
|
249
|
-
visitNpmStaticDeclarationClosure(entryPath, (path, source) => {
|
|
250
|
-
for (const [className, methods] of parseNpmStaticDeclarationOverloads(path, source)) {
|
|
273
|
+
visitNpmStaticDeclarationClosure(services, entryPath, (path, source) => {
|
|
274
|
+
for (const [className, methods] of parseNpmStaticDeclarationOverloads(services.parse(path, source, "ts"))) {
|
|
251
275
|
const target = classes.get(className) ?? new Map();
|
|
252
276
|
classes.set(className, target);
|
|
253
277
|
for (const [methodName, signatures] of methods) {
|
|
@@ -258,10 +282,10 @@ function npmStaticDeclarationOverloadsOf(entryPath) {
|
|
|
258
282
|
});
|
|
259
283
|
return classes;
|
|
260
284
|
}
|
|
261
|
-
function npmStaticDeclarationPropertiesOf(entryPath) {
|
|
285
|
+
function npmStaticDeclarationPropertiesOf(services, entryPath) {
|
|
262
286
|
const classes = new Map();
|
|
263
|
-
visitNpmStaticDeclarationClosure(entryPath, (path, source) => {
|
|
264
|
-
for (const [className, properties] of parseNpmStaticDeclarationProperties(path, source)) {
|
|
287
|
+
visitNpmStaticDeclarationClosure(services, entryPath, (path, source) => {
|
|
288
|
+
for (const [className, properties] of parseNpmStaticDeclarationProperties(services.parse(path, source, "ts"))) {
|
|
265
289
|
const target = classes.get(className) ?? new Map();
|
|
266
290
|
classes.set(className, target);
|
|
267
291
|
for (const [propertyName, type] of properties) {
|
|
@@ -369,12 +393,15 @@ function createRequireProgramRoots7(program) {
|
|
|
369
393
|
return "skip";
|
|
370
394
|
let target = resolveProjectModule(sf.fileName, spec);
|
|
371
395
|
if (target === null && !spec.startsWith("#")) {
|
|
372
|
-
const npm = resolveNpmImport7(sf.fileName, spec);
|
|
396
|
+
const npm = resolveNpmImport7(sf.fileName, spec, "require");
|
|
373
397
|
if (npm !== null && isNpmStaticPackage(npm.packageName) && isJsSourceFileName(npm.typesFile)) {
|
|
374
398
|
target = npm.typesFile;
|
|
375
399
|
}
|
|
376
400
|
}
|
|
377
|
-
|
|
401
|
+
// A directory's package.json may point at a native addon. Keep it
|
|
402
|
+
// out of TypeScript's source roots so the require call can report
|
|
403
|
+
// the native-addon boundary instead of an unsupported-file error.
|
|
404
|
+
if (target === null || target.endsWith(".json") || target.endsWith(".node"))
|
|
378
405
|
return "skip";
|
|
379
406
|
const normalized = tsgoPath(resolve(target));
|
|
380
407
|
if (!known.has(normalized))
|
|
@@ -384,6 +411,41 @@ function createRequireProgramRoots7(program) {
|
|
|
384
411
|
}
|
|
385
412
|
return [...roots].sort();
|
|
386
413
|
}
|
|
414
|
+
/** Classify the explicitly selected installed package's own sources. */
|
|
415
|
+
export function entryPackageFilePredicate(entryPath) {
|
|
416
|
+
const entryFile = tsgoPath(entryPath);
|
|
417
|
+
const installedAt = entryFile.lastIndexOf("/node_modules/");
|
|
418
|
+
const prefix = installedAt < 0
|
|
419
|
+
? null
|
|
420
|
+
: entryFile.slice(0, installedAt) + "/node_modules/" + npmPackageNameOf(entryFile) + "/";
|
|
421
|
+
return (file) => {
|
|
422
|
+
const normalized = tsgoPath(file);
|
|
423
|
+
return normalized === entryFile || (prefix !== null && normalized.startsWith(prefix) &&
|
|
424
|
+
!normalized.slice(prefix.length).split("/").includes("node_modules"));
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
/** maxNodeModuleJsDepth omits even relative JS imports within an installed
|
|
428
|
+
* entry's own package. Add those sources as roots to the existing discovery
|
|
429
|
+
* fixpoint without raising the checker depth for other packages. */
|
|
430
|
+
function entryPackageProgramRoots7(program, entryPath) {
|
|
431
|
+
if (!isNodeModulesPath(entryPath))
|
|
432
|
+
return [];
|
|
433
|
+
const belongsToEntry = entryPackageFilePredicate(entryPath);
|
|
434
|
+
const roots = new Set();
|
|
435
|
+
for (const sf of program.getSourceFiles()) {
|
|
436
|
+
if (sf.isDeclarationFile || !belongsToEntry(sf.fileName))
|
|
437
|
+
continue;
|
|
438
|
+
for (const specifier of sf.imports) {
|
|
439
|
+
if (!ts.isStringLiteralLike(specifier))
|
|
440
|
+
continue;
|
|
441
|
+
const target = resolveProjectModule(sf.fileName, specifier.text);
|
|
442
|
+
if (target !== null && belongsToEntry(target) && isJsSourceFileName(target) &&
|
|
443
|
+
program.getSourceFile(target) === undefined)
|
|
444
|
+
roots.add(target);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return [...roots].sort();
|
|
448
|
+
}
|
|
387
449
|
function loadProgram7(host, entryPath, externalTypes = new Map()) {
|
|
388
450
|
const config = adoptProjectConfig7(host, entryPath);
|
|
389
451
|
const configuredPaths = config.options["paths"];
|
|
@@ -422,51 +484,54 @@ function loadProgram7(host, entryPath, externalTypes = new Map()) {
|
|
|
422
484
|
}
|
|
423
485
|
const coreRoots = [entryPath, ambientDtsPath(), nodeTypes ?? fallbackDtsPath()];
|
|
424
486
|
const programRoots = [...coreRoots];
|
|
425
|
-
let program =
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
program = ts.createProgram([...programRoots, overridesDtsPath()], options, host);
|
|
437
|
-
if (pass === 31)
|
|
438
|
-
throw new Error("static program-root discovery did not converge");
|
|
439
|
-
}
|
|
440
|
-
const entry = program.getSourceFile(entryPath);
|
|
441
|
-
if (!entry)
|
|
442
|
-
throw new Error(`could not load ${entryPath}`);
|
|
443
|
-
const externalTypeSpecifiersByFile = externalTypeFileClosure7(program, externalTypes);
|
|
444
|
-
let projectWorld = null;
|
|
445
|
-
return {
|
|
446
|
-
program,
|
|
447
|
-
entry,
|
|
448
|
-
moduleOrder: [],
|
|
449
|
-
configDiags: config.diags,
|
|
450
|
-
externalTypes,
|
|
451
|
-
externalTypeSpecifiersByFile,
|
|
452
|
-
projectWorld: () => (projectWorld ??= ts.createProgram(programRoots, options, host)),
|
|
453
|
-
disposeAll: () => {
|
|
454
|
-
projectWorld?.dispose();
|
|
487
|
+
let program = host.createProgram([...programRoots, overridesDtsPath()], options);
|
|
488
|
+
try {
|
|
489
|
+
for (let pass = 0; pass < 32; pass++) {
|
|
490
|
+
const candidates = [
|
|
491
|
+
...entryPackageProgramRoots7(program, entryPath),
|
|
492
|
+
...createRequireProgramRoots7(program),
|
|
493
|
+
...forkTargetPaths(program, program.getSourceFiles()),
|
|
494
|
+
];
|
|
495
|
+
const extraRoots = candidates.filter((root, index) => !programRoots.includes(root) && candidates.indexOf(root) === index);
|
|
496
|
+
if (extraRoots.length === 0)
|
|
497
|
+
break;
|
|
455
498
|
program.dispose();
|
|
456
|
-
|
|
457
|
-
|
|
499
|
+
programRoots.push(...extraRoots);
|
|
500
|
+
program = host.createProgram([...programRoots, overridesDtsPath()], options);
|
|
501
|
+
if (pass === 31)
|
|
502
|
+
throw new Error("static program-root discovery did not converge");
|
|
503
|
+
}
|
|
504
|
+
const entry = program.getSourceFile(entryPath);
|
|
505
|
+
if (!entry)
|
|
506
|
+
throw new Error(`could not load ${entryPath}`);
|
|
507
|
+
const externalTypeSpecifiersByFile = externalTypeFileClosure7(program, externalTypes);
|
|
508
|
+
let projectWorld = null;
|
|
509
|
+
return {
|
|
510
|
+
program,
|
|
511
|
+
entry,
|
|
512
|
+
moduleOrder: [],
|
|
513
|
+
configDiags: config.diags,
|
|
514
|
+
externalTypes,
|
|
515
|
+
externalTypeSpecifiersByFile,
|
|
516
|
+
projectWorld: () => (projectWorld ??= host.createProgram(programRoots, options)),
|
|
517
|
+
disposeAll: () => {
|
|
518
|
+
try {
|
|
519
|
+
projectWorld?.dispose();
|
|
520
|
+
}
|
|
521
|
+
finally {
|
|
522
|
+
program.dispose();
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
catch (error) {
|
|
528
|
+
program.dispose();
|
|
529
|
+
throw error;
|
|
530
|
+
}
|
|
458
531
|
}
|
|
459
|
-
|
|
460
|
-
* lowering. The caller runs checkPreflight, hands program/entry/
|
|
461
|
-
* moduleOrder straight to lowerToIr, and MUST dispose() when done — the
|
|
462
|
-
* spawned tsgo server must not outlive the compile. */
|
|
463
|
-
export function loadProgram(entryPath, opts) {
|
|
464
|
-
// Absolute from the start: tsgo's world is absolute-path-keyed (the CLI
|
|
465
|
-
// resolves before calling; this covers direct API callers too).
|
|
532
|
+
export function loadProgram(entryPath, services, opts) {
|
|
466
533
|
entryPath = resolve(entryPath);
|
|
467
|
-
const externalTypeEntries = opts?.externalTypes
|
|
468
|
-
? [...opts.externalTypes]
|
|
469
|
-
: Object.entries(opts?.externalTypes ?? {});
|
|
534
|
+
const externalTypeEntries = opts?.externalTypes ?? [];
|
|
470
535
|
const externalTypes = new Map();
|
|
471
536
|
for (const [specifier, file] of externalTypeEntries) {
|
|
472
537
|
if (!isExactExternalTypeSpecifier(specifier)) {
|
|
@@ -488,6 +553,7 @@ export function loadProgram(entryPath, opts) {
|
|
|
488
553
|
// or executable module edges.
|
|
489
554
|
const declarationOverloads = new Map();
|
|
490
555
|
const declarationProperties = new Map();
|
|
556
|
+
const projectionOwners = new Map();
|
|
491
557
|
for (const pkg of npmStaticPackages) {
|
|
492
558
|
const resolved = resolveBareModule(entryPath, pkg, "types-only");
|
|
493
559
|
if (resolved === null ||
|
|
@@ -495,8 +561,8 @@ export function loadProgram(entryPath, opts) {
|
|
|
495
561
|
!/\.d\.(?:ts|mts|cts)$/.test(resolved.typesFile)) {
|
|
496
562
|
continue;
|
|
497
563
|
}
|
|
498
|
-
const overloads = npmStaticDeclarationOverloadsOf(resolved.typesFile);
|
|
499
|
-
const properties = npmStaticDeclarationPropertiesOf(resolved.typesFile);
|
|
564
|
+
const overloads = npmStaticDeclarationOverloadsOf(services, resolved.typesFile);
|
|
565
|
+
const properties = npmStaticDeclarationPropertiesOf(services, resolved.typesFile);
|
|
500
566
|
const classNames = new Set([...overloads.keys(), ...properties.keys()]);
|
|
501
567
|
if (classNames.size === 0)
|
|
502
568
|
continue;
|
|
@@ -506,8 +572,8 @@ export function loadProgram(entryPath, opts) {
|
|
|
506
572
|
const runtimeSource = trackedReadFile(runtime.typesFile);
|
|
507
573
|
if (runtimeSource === null)
|
|
508
574
|
continue;
|
|
509
|
-
const targets = npmStaticRuntimeClassTargets(runtime.typesFile, runtimeSource, classNames);
|
|
510
|
-
for (const [className, specifier] of targets) {
|
|
575
|
+
const targets = npmStaticRuntimeClassTargets(services.parse(runtime.typesFile, runtimeSource, "js"), runtimeSource, classNames);
|
|
576
|
+
for (const [className, { specifier, localName }] of targets) {
|
|
511
577
|
const methods = overloads.get(className);
|
|
512
578
|
const fields = properties.get(className);
|
|
513
579
|
if (methods === undefined && fields === undefined)
|
|
@@ -521,14 +587,39 @@ export function loadProgram(entryPath, opts) {
|
|
|
521
587
|
targetNorm.startsWith(runtime.workspaceDir.split("\\").join("/") + "/");
|
|
522
588
|
if (targetPackage !== pkg && !insideWorkspace)
|
|
523
589
|
continue;
|
|
590
|
+
const projectionKey = JSON.stringify([targetNorm, localName]);
|
|
591
|
+
const previousOwner = projectionOwners.get(projectionKey);
|
|
592
|
+
if (previousOwner !== undefined && previousOwner !== className) {
|
|
593
|
+
// Two public class declarations naming one runtime class are
|
|
594
|
+
// ambiguous. Keep inference instead of choosing one alias's ABI.
|
|
595
|
+
projectionOwners.set(projectionKey, null);
|
|
596
|
+
const priorMethods = new Map(declarationOverloads.get(targetNorm) ?? []);
|
|
597
|
+
priorMethods.delete(localName);
|
|
598
|
+
declarationOverloads.set(targetNorm, priorMethods);
|
|
599
|
+
const priorFields = new Map(declarationProperties.get(targetNorm) ?? []);
|
|
600
|
+
priorFields.delete(localName);
|
|
601
|
+
declarationProperties.set(targetNorm, priorFields);
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
projectionOwners.set(projectionKey, className);
|
|
605
|
+
// The safe declaration grammar can name only its own class. Bind
|
|
606
|
+
// that type to the actual runtime class after a named ESM alias.
|
|
607
|
+
const renameSelf = (type) => type.split(/([\s[\]<>()|,]+)/).map((name) => name === className ? localName : name).join("");
|
|
524
608
|
if (methods !== undefined) {
|
|
525
609
|
const byClass = new Map(declarationOverloads.get(targetNorm) ?? []);
|
|
526
|
-
byClass.set(
|
|
610
|
+
byClass.set(localName, new Map([...methods].map(([name, signatures]) => [name, signatures.map((signature) => ({
|
|
611
|
+
parameters: signature.parameters.map((parameter) => ({
|
|
612
|
+
name: parameter.name,
|
|
613
|
+
type: renameSelf(parameter.type),
|
|
614
|
+
optional: parameter.optional,
|
|
615
|
+
})),
|
|
616
|
+
returnType: renameSelf(signature.returnType),
|
|
617
|
+
}))])));
|
|
527
618
|
declarationOverloads.set(targetNorm, byClass);
|
|
528
619
|
}
|
|
529
620
|
if (fields !== undefined) {
|
|
530
621
|
const byClass = new Map(declarationProperties.get(targetNorm) ?? []);
|
|
531
|
-
byClass.set(
|
|
622
|
+
byClass.set(localName, new Map([...fields].map(([name, type]) => [name, renameSelf(type)])));
|
|
532
623
|
declarationProperties.set(targetNorm, byClass);
|
|
533
624
|
}
|
|
534
625
|
}
|
|
@@ -558,25 +649,37 @@ export function loadProgram(entryPath, opts) {
|
|
|
558
649
|
// outside node_modules — the classic typed-JS-library entry — must not exist for
|
|
559
650
|
// the checker, so its resolution lands on the JS Node actually loads;
|
|
560
651
|
// resolve.ts answers the same sibling for scriptc's own edges).
|
|
561
|
-
const npmShadow = npmStaticFsShadow();
|
|
652
|
+
const npmShadow = npmStaticFsShadow(services);
|
|
562
653
|
const fsShadow = {
|
|
563
654
|
readFile: (path) => npmShadow?.readFile(path),
|
|
564
655
|
hideFile: (path) => (npmShadow?.hideFile(path) ?? false) || projectDtsRuntimeSibling(path) !== null,
|
|
565
656
|
};
|
|
566
|
-
const host =
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
657
|
+
const host = services.createProgramHost({ cwd: dirname(entryPath), fsShadow });
|
|
658
|
+
try {
|
|
659
|
+
const load = loadProgram7(host, entryPath, externalTypes);
|
|
660
|
+
return {
|
|
661
|
+
...load,
|
|
662
|
+
services,
|
|
663
|
+
dispose: () => {
|
|
664
|
+
try {
|
|
665
|
+
load.disposeAll();
|
|
666
|
+
}
|
|
667
|
+
finally {
|
|
668
|
+
host.close();
|
|
669
|
+
}
|
|
670
|
+
},
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
catch (error) {
|
|
674
|
+
host.close();
|
|
675
|
+
throw error;
|
|
676
|
+
}
|
|
575
677
|
}
|
|
576
678
|
/** tsc diagnostics (syntax + types), the supported-import fence, and the
|
|
577
679
|
* module evaluation order: fills load.moduleOrder (the SourceFiles
|
|
578
680
|
* themselves — the lowering consumes them directly) and returns the
|
|
579
|
-
* preflight diagnostics.
|
|
681
|
+
* preflight diagnostics. Preserve the caller's complete load shape when
|
|
682
|
+
* mutating it, including its owned services and disposal callback. */
|
|
580
683
|
export function checkPreflight(load) {
|
|
581
684
|
const { diags, moduleOrder, startupCrash } = preflight7(load);
|
|
582
685
|
load.moduleOrder = moduleOrder;
|
|
@@ -663,33 +766,141 @@ function requiresOf7(stmt) {
|
|
|
663
766
|
}
|
|
664
767
|
return out;
|
|
665
768
|
}
|
|
769
|
+
/** The exact `Object.defineProperty(exports|module.exports, "__esModule",
|
|
770
|
+
* { value: true })` interop stamp (shared by preflight and the no-op lowering). */
|
|
771
|
+
export function isEsModuleStamp(expr) {
|
|
772
|
+
if (!ts.isCallExpression(expr) || expr.questionDotToken !== undefined)
|
|
773
|
+
return false;
|
|
774
|
+
const callee = expr.expression;
|
|
775
|
+
if (!ts.isPropertyAccessExpression(callee) ||
|
|
776
|
+
!ts.isIdentifier(callee.expression) ||
|
|
777
|
+
callee.expression.text !== "Object" ||
|
|
778
|
+
!ts.isIdentifier(callee.name) ||
|
|
779
|
+
callee.name.text !== "defineProperty") {
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
782
|
+
if (expr.arguments.length !== 3)
|
|
783
|
+
return false;
|
|
784
|
+
const [recv, nameArg, desc] = expr.arguments;
|
|
785
|
+
const isExports = (ts.isIdentifier(recv) && recv.text === "exports") ||
|
|
786
|
+
(ts.isPropertyAccessExpression(recv) &&
|
|
787
|
+
ts.isIdentifier(recv.expression) &&
|
|
788
|
+
recv.expression.text === "module" &&
|
|
789
|
+
ts.isIdentifier(recv.name) &&
|
|
790
|
+
recv.name.text === "exports");
|
|
791
|
+
if (!isExports)
|
|
792
|
+
return false;
|
|
793
|
+
if (!ts.isStringLiteral(nameArg) || nameArg.text !== "__esModule")
|
|
794
|
+
return false;
|
|
795
|
+
if (!ts.isObjectLiteralExpression(desc) || desc.properties.length !== 1)
|
|
796
|
+
return false;
|
|
797
|
+
const p = desc.properties[0];
|
|
798
|
+
return (ts.isPropertyAssignment(p) &&
|
|
799
|
+
ts.isIdentifier(p.name) &&
|
|
800
|
+
p.name.text === "value" &&
|
|
801
|
+
p.initializer.kind === ts.SyntaxKind.TrueKeyword);
|
|
802
|
+
}
|
|
803
|
+
/** Plain CommonJS prologue writes only publish values; in particular,
|
|
804
|
+
* publishing a hoisted function does not invoke its body. Later runnable
|
|
805
|
+
* statements may call the export or mutate its receiver, and still need
|
|
806
|
+
* the conservative TDZ scan over the whole prefix. */
|
|
807
|
+
function pureCjsExport7(program, stmt) {
|
|
808
|
+
const cjs = cjsExportAssignmentOf(stmt);
|
|
809
|
+
if (cjs === null)
|
|
810
|
+
return false;
|
|
811
|
+
const sf = stmt.getSourceFile();
|
|
812
|
+
const plainMember = (left) => {
|
|
813
|
+
if (!ts.isPropertyAccessExpression(left) || left.questionDotToken)
|
|
814
|
+
return false;
|
|
815
|
+
// A replacement export can have setters or non-writable function
|
|
816
|
+
// properties. Only the wrapper's original object gets this exception.
|
|
817
|
+
if (sf.statements.some((s) => cjsExportAssignmentOf(s)?.kind === "table"))
|
|
818
|
+
return false;
|
|
819
|
+
if (left.name.text === "__proto__" || left.name.text === "__esModule")
|
|
820
|
+
return false;
|
|
821
|
+
let receiver = left.expression;
|
|
822
|
+
if (isModuleExportsAccess(receiver)) {
|
|
823
|
+
receiver = receiver.expression;
|
|
824
|
+
return ts.isIdentifier(receiver) && !sourceBinding7(program, receiver);
|
|
825
|
+
}
|
|
826
|
+
return ts.isIdentifier(receiver) && receiver.text === "exports" && !sourceBinding7(program, receiver);
|
|
827
|
+
};
|
|
828
|
+
if (cjs.kind === "member") {
|
|
829
|
+
if (!plainMember(cjs.expr.left))
|
|
830
|
+
return false;
|
|
831
|
+
}
|
|
832
|
+
else {
|
|
833
|
+
const receiver = cjs.expr.left.expression;
|
|
834
|
+
if (sourceBinding7(program, receiver))
|
|
835
|
+
return false;
|
|
836
|
+
}
|
|
837
|
+
let value = cjs.expr.right;
|
|
838
|
+
// tsc emits chains such as exports.A = exports.B = void 0.
|
|
839
|
+
while (ts.isBinaryExpression(value) && value.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
|
|
840
|
+
if (!plainMember(value.left))
|
|
841
|
+
return false;
|
|
842
|
+
value = value.right;
|
|
843
|
+
}
|
|
844
|
+
if (ts.isVoidExpression(value) && ts.isNumericLiteral(value.expression))
|
|
845
|
+
return true;
|
|
846
|
+
if (ts.isStringLiteralLike(value) || ts.isNumericLiteral(value) ||
|
|
847
|
+
value.kind === ts.SyntaxKind.TrueKeyword || value.kind === ts.SyntaxKind.FalseKeyword ||
|
|
848
|
+
value.kind === ts.SyntaxKind.NullKeyword)
|
|
849
|
+
return true;
|
|
850
|
+
if (!ts.isIdentifier(value))
|
|
851
|
+
return false;
|
|
852
|
+
if (value.text === "undefined" && !sourceBinding7(program, value))
|
|
853
|
+
return true;
|
|
854
|
+
const checker = program.getTypeChecker();
|
|
855
|
+
const symbol = checker.getSymbolAtLocation(value);
|
|
856
|
+
return symbol !== undefined && checker.declarationsOf(symbol).some((decl) => ts.isFunctionDeclaration(decl) && decl.parent === stmt.parent);
|
|
857
|
+
}
|
|
858
|
+
function sourceBinding7(program, ident) {
|
|
859
|
+
const checker = program.getTypeChecker();
|
|
860
|
+
const symbol = checker.getSymbolAtLocation(ident);
|
|
861
|
+
return symbol !== undefined && checker.declarationsOf(symbol).some((decl) => !decl.getSourceFile().isDeclarationFile && !ts.isSourceFile(decl));
|
|
862
|
+
}
|
|
863
|
+
function purePrefixDecl7(decl) {
|
|
864
|
+
const init = decl.initializer;
|
|
865
|
+
return init === undefined || requireSpecOf7(init) !== null ||
|
|
866
|
+
ts.isStringLiteralLike(init) || ts.isNumericLiteral(init) ||
|
|
867
|
+
init.kind === ts.SyntaxKind.TrueKeyword || init.kind === ts.SyntaxKind.FalseKeyword ||
|
|
868
|
+
init.kind === ts.SyntaxKind.NullKeyword;
|
|
869
|
+
}
|
|
666
870
|
/** True for top-level statements that cannot run user code: directives,
|
|
667
871
|
* empty statements, hoisted declarations, require statements themselves,
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
|
|
872
|
+
* literal-initialized variables, and CommonJS function-export prologues.
|
|
873
|
+
* A require preceded ONLY by these cannot observe its own bindings early;
|
|
874
|
+
* require cycles are checked separately by the module graph fences. */
|
|
875
|
+
function purePrefixStmt7(program, s) {
|
|
671
876
|
if (ts.isEmptyStatement(s) || ts.isFunctionDeclaration(s))
|
|
672
877
|
return true;
|
|
673
878
|
if (ts.isExpressionStatement(s) && ts.isStringLiteral(s.expression))
|
|
674
879
|
return true; // directive
|
|
675
880
|
if (isRequireStatement7(s))
|
|
676
881
|
return true;
|
|
882
|
+
if (isCjsJsFile7(s.getSourceFile(), program)) {
|
|
883
|
+
if (ts.isExpressionStatement(s) && isEsModuleStamp(s.expression)) {
|
|
884
|
+
const call = s.expression;
|
|
885
|
+
const object = call.expression.expression;
|
|
886
|
+
let receiver = call.arguments[0];
|
|
887
|
+
if (ts.isPropertyAccessExpression(receiver))
|
|
888
|
+
receiver = receiver.expression;
|
|
889
|
+
if (!sourceBinding7(program, object) && ts.isIdentifier(receiver) && !sourceBinding7(program, receiver))
|
|
890
|
+
return true;
|
|
891
|
+
}
|
|
892
|
+
if (pureCjsExport7(program, s))
|
|
893
|
+
return true;
|
|
894
|
+
}
|
|
677
895
|
if (ts.isVariableStatement(s)) {
|
|
678
|
-
return s.declarationList.declarations.every(
|
|
679
|
-
requireSpecOf7(d.initializer) !== null ||
|
|
680
|
-
ts.isStringLiteralLike(d.initializer) ||
|
|
681
|
-
ts.isNumericLiteral(d.initializer) ||
|
|
682
|
-
d.initializer.kind === ts.SyntaxKind.TrueKeyword ||
|
|
683
|
-
d.initializer.kind === ts.SyntaxKind.FalseKeyword ||
|
|
684
|
-
d.initializer.kind === ts.SyntaxKind.NullKeyword);
|
|
896
|
+
return s.declarationList.declarations.every(purePrefixDecl7);
|
|
685
897
|
}
|
|
686
898
|
return false;
|
|
687
899
|
}
|
|
688
|
-
/** Can code that runs BEFORE the
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
* early read would silently diverge. Conservative reachability: earlier
|
|
900
|
+
/** Can code that runs BEFORE the declaration at index `k` reach one of
|
|
901
|
+
* its bindings? Static require aliases and symbol field keys bypass
|
|
902
|
+
* storage reads, so an early use could erase a TDZ error or a var's
|
|
903
|
+
* initial undefined value. Conservative reachability: earlier
|
|
693
904
|
* statements' whole subtrees (arrows and function expressions included)
|
|
694
905
|
* read the binding directly, or reference a hoisted function/class whose
|
|
695
906
|
* body (transitively through other hoisted declarations) reads it — a
|
|
@@ -700,7 +911,7 @@ function purePrefixStmt7(s) {
|
|
|
700
911
|
* (The CheckerFacade memoizes symbol queries, and 7's client dedupes
|
|
701
912
|
* symbol identity by server handle, so the Map-keyed-by-Symbol discipline
|
|
702
913
|
* carries over from the 5.9.3 original unchanged.) */
|
|
703
|
-
function
|
|
914
|
+
export function bindingEarlyUse7(program, sf, k, decl, precedingDecls) {
|
|
704
915
|
const checker = program.getTypeChecker();
|
|
705
916
|
const bound = [];
|
|
706
917
|
if (ts.isIdentifier(decl.name))
|
|
@@ -736,7 +947,9 @@ function requireTdzRisk7(program, sf, k, decl) {
|
|
|
736
947
|
// this scan must survive it so the nesting fence can answer later.
|
|
737
948
|
ts.walkPreorder(root, (n) => {
|
|
738
949
|
if (ts.isIdentifier(n)) {
|
|
739
|
-
const sym =
|
|
950
|
+
const sym = ts.isShorthandPropertyAssignment(n.parent)
|
|
951
|
+
? checker.getShorthandAssignmentValueSymbol(n.parent)
|
|
952
|
+
: checker.getSymbolAtLocation(n);
|
|
740
953
|
if (sym) {
|
|
741
954
|
const name = bindings.get(sym);
|
|
742
955
|
if (name !== undefined) {
|
|
@@ -756,12 +969,15 @@ function requireTdzRisk7(program, sf, k, decl) {
|
|
|
756
969
|
// These are the exact roots the TDZ analysis scans eagerly. Their files
|
|
757
970
|
// are phase-managed already, so warm their deferred identifiers as one
|
|
758
971
|
// symbol-only batch instead of paying one IPC query per occurrence.
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
972
|
+
const roots = [
|
|
973
|
+
...stmts.slice(0, k).filter((stmt) => !ts.isFunctionDeclaration(stmt)),
|
|
974
|
+
...precedingDecls,
|
|
975
|
+
];
|
|
976
|
+
checker.prefetchSymbolRoots(roots);
|
|
977
|
+
for (const root of roots) {
|
|
978
|
+
if (hit !== null)
|
|
979
|
+
break;
|
|
980
|
+
scan(root);
|
|
765
981
|
}
|
|
766
982
|
while (hit === null && work.length > 0) {
|
|
767
983
|
// A scanned reference can make a hoisted declaration's body reachable
|
|
@@ -809,7 +1025,7 @@ function isCreateRequireImport7(program, ident) {
|
|
|
809
1025
|
const decl = symbol ? checker.declarationsOf(symbol)[0] : undefined;
|
|
810
1026
|
if (decl === undefined || !ts.isImportSpecifier(decl))
|
|
811
1027
|
return false;
|
|
812
|
-
const importDecl = decl.parent
|
|
1028
|
+
const importDecl = decl.parent?.parent?.parent;
|
|
813
1029
|
if (ts.isImportDeclaration(importDecl) && ts.isStringLiteral(importDecl.moduleSpecifier)) {
|
|
814
1030
|
const module = canonicalBuiltinModule(importDecl.moduleSpecifier.text);
|
|
815
1031
|
const member = decl.propertyName?.text ?? decl.name.text;
|
|
@@ -829,11 +1045,10 @@ function isCreateRequireImport7(program, ident) {
|
|
|
829
1045
|
}
|
|
830
1046
|
return false;
|
|
831
1047
|
}
|
|
832
|
-
/** True only for
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
|
|
836
|
-
function isCreateRequireBinding7(program, callee) {
|
|
1048
|
+
/** True only for createRequire bindings the lowering can erase. Mutable
|
|
1049
|
+
* declaration syntax needs a whole-file proof: no writes or escapes, and
|
|
1050
|
+
* no code before initialization can reach the binding. */
|
|
1051
|
+
export function isCreateRequireBinding7(program, callee) {
|
|
837
1052
|
const checker = program.getTypeChecker();
|
|
838
1053
|
const symbol = checker.getSymbolAtLocation(callee);
|
|
839
1054
|
const decl = symbol
|
|
@@ -841,11 +1056,70 @@ function isCreateRequireBinding7(program, callee) {
|
|
|
841
1056
|
: undefined;
|
|
842
1057
|
if (decl === undefined ||
|
|
843
1058
|
decl.initializer === undefined ||
|
|
844
|
-
!ts.isVariableDeclarationList(decl.parent)
|
|
845
|
-
(decl.parent.flags & ts.NodeFlags.Const) === 0) {
|
|
1059
|
+
!ts.isVariableDeclarationList(decl.parent)) {
|
|
846
1060
|
return false;
|
|
847
1061
|
}
|
|
848
|
-
|
|
1062
|
+
return isCreateRequireBaseCall7(program, decl.initializer) && ((decl.parent.flags & ts.NodeFlags.Const) !== 0 ||
|
|
1063
|
+
stableCreateRequireBindingReason7(program, decl) === null);
|
|
1064
|
+
}
|
|
1065
|
+
/** Only literal calls and literal resolution queries can erase the loader
|
|
1066
|
+
* value. In particular, assignments, exported aliases, shorthand properties,
|
|
1067
|
+
* optional calls, and passing the loader to user code cannot pass this test. */
|
|
1068
|
+
function staticCreateRequireUse7(expr) {
|
|
1069
|
+
let use = expr;
|
|
1070
|
+
while (ts.isParenthesizedExpression(use.parent))
|
|
1071
|
+
use = use.parent;
|
|
1072
|
+
if (ts.isPropertyAccessExpression(use.parent) && use.parent.expression === use && use.parent.name.text === "resolve" && !use.parent.questionDotToken) {
|
|
1073
|
+
use = use.parent;
|
|
1074
|
+
if (ts.isPropertyAccessExpression(use.parent) && use.parent.expression === use && use.parent.name.text === "paths" && !use.parent.questionDotToken)
|
|
1075
|
+
use = use.parent;
|
|
1076
|
+
}
|
|
1077
|
+
const call = use.parent;
|
|
1078
|
+
return ts.isCallExpression(call) && call.expression === use && !call.questionDotToken &&
|
|
1079
|
+
call.arguments.length === 1 && ts.isStringLiteralLike(call.arguments[0]);
|
|
1080
|
+
}
|
|
1081
|
+
function stableCreateRequireBindingReason7(program, decl) {
|
|
1082
|
+
const cache = program.analysis.createRequireReasons;
|
|
1083
|
+
if (cache.has(decl))
|
|
1084
|
+
return cache.get(decl);
|
|
1085
|
+
const check = () => {
|
|
1086
|
+
const stmt = decl.parent?.parent;
|
|
1087
|
+
if (!ts.isIdentifier(decl.name) || !ts.isVariableStatement(stmt) || !ts.isSourceFile(stmt.parent)) {
|
|
1088
|
+
return "its mutable createRequire binding is outside the module's top level";
|
|
1089
|
+
}
|
|
1090
|
+
const checker = program.getTypeChecker();
|
|
1091
|
+
const symbol = checker.getSymbolAtLocation(decl.name);
|
|
1092
|
+
if (!symbol || checker.declarationsOf(symbol).length !== 1)
|
|
1093
|
+
return "its createRequire binding is redeclared";
|
|
1094
|
+
if ((ts.getCombinedModifierFlags(decl) & ts.ModifierFlags.Export) !== 0)
|
|
1095
|
+
return "its createRequire result escapes through an exported binding";
|
|
1096
|
+
const sf = decl.getSourceFile();
|
|
1097
|
+
const refs = identifierOccurrences7(sf, decl.name.text);
|
|
1098
|
+
checker.prefetchSymbolNodesExact(refs);
|
|
1099
|
+
for (const ref of refs) {
|
|
1100
|
+
if (ref === decl.name || inTypePosition7(ref))
|
|
1101
|
+
continue;
|
|
1102
|
+
let target = ts.isShorthandPropertyAssignment(ref.parent)
|
|
1103
|
+
? checker.getShorthandAssignmentValueSymbol(ref.parent)
|
|
1104
|
+
: checker.getSymbolAtLocation(ref);
|
|
1105
|
+
if (target && (target.flags & ts.SymbolFlags.Alias) !== 0)
|
|
1106
|
+
target = checker.getAliasedSymbol(target);
|
|
1107
|
+
if (target === symbol && !staticCreateRequireUse7(ref)) {
|
|
1108
|
+
return "its createRequire binding is reassigned, escapes, or uses a computed specifier";
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
const preceding = stmt.declarationList.declarations.slice(0, stmt.declarationList.declarations.indexOf(decl));
|
|
1112
|
+
if (bindingEarlyUse7(program, sf, sf.statements.indexOf(stmt), decl, preceding) !== null) {
|
|
1113
|
+
return "its createRequire binding can be used before initialization";
|
|
1114
|
+
}
|
|
1115
|
+
return null;
|
|
1116
|
+
};
|
|
1117
|
+
const reason = check();
|
|
1118
|
+
cache.set(decl, reason);
|
|
1119
|
+
return reason;
|
|
1120
|
+
}
|
|
1121
|
+
function isCreateRequireBaseCall7(program, expr) {
|
|
1122
|
+
const init = stripRequireCasts7(expr);
|
|
849
1123
|
if (!ts.isCallExpression(init) ||
|
|
850
1124
|
init.questionDotToken !== undefined ||
|
|
851
1125
|
!ts.isIdentifier(init.expression) ||
|
|
@@ -855,13 +1129,77 @@ function isCreateRequireBinding7(program, callee) {
|
|
|
855
1129
|
}
|
|
856
1130
|
const base = stripRequireCasts7(init.arguments[0]);
|
|
857
1131
|
if (ts.isIdentifier(base) && base.text === "__filename")
|
|
858
|
-
return
|
|
1132
|
+
return !sourceBinding7(program, base);
|
|
859
1133
|
return (ts.isPropertyAccessExpression(base) &&
|
|
860
1134
|
base.questionDotToken === undefined &&
|
|
861
1135
|
ts.isMetaProperty(base.expression) &&
|
|
862
1136
|
base.expression.keywordToken === ts.SyntaxKind.ImportKeyword &&
|
|
863
1137
|
(base.name.text === "url" || base.name.text === "filename"));
|
|
864
1138
|
}
|
|
1139
|
+
/** A node:module import alone does not require an engine. Retain npm
|
|
1140
|
+
* fallback for require indirection the lowering cannot erase, while
|
|
1141
|
+
* admitting literal calls through the same stable/inline shapes as program
|
|
1142
|
+
* code. Inspect symbols, not names: nested shadows are unrelated bindings. */
|
|
1143
|
+
function npmStaticModuleImportReason7(program, stmt) {
|
|
1144
|
+
const clause = stmt.importClause;
|
|
1145
|
+
if (!clause)
|
|
1146
|
+
return null;
|
|
1147
|
+
const bindings = clause.namedBindings;
|
|
1148
|
+
if (clause.name || (bindings && !ts.isNamedImports(bindings))) {
|
|
1149
|
+
return "its node:module namespace or default import has no static createRequire usage proof";
|
|
1150
|
+
}
|
|
1151
|
+
if (!bindings || !ts.isNamedImports(bindings))
|
|
1152
|
+
return null;
|
|
1153
|
+
const checker = program.getTypeChecker();
|
|
1154
|
+
const sf = stmt.getSourceFile();
|
|
1155
|
+
for (const specifier of bindings.elements) {
|
|
1156
|
+
if ((specifier.propertyName?.text ?? specifier.name.text) !== "createRequire")
|
|
1157
|
+
continue;
|
|
1158
|
+
const imported = checker.getSymbolAtLocation(specifier.name);
|
|
1159
|
+
if (!imported)
|
|
1160
|
+
return "its createRequire import could not be resolved";
|
|
1161
|
+
checker.prefetchSymbolNodesExact(identifierOccurrences7(sf, specifier.name.text));
|
|
1162
|
+
let reason = null;
|
|
1163
|
+
const checkUse = (expr) => {
|
|
1164
|
+
if (!staticCreateRequireUse7(expr)) {
|
|
1165
|
+
reason = "its createRequire result escapes or is used with a computed specifier (static requires need literal specifiers)";
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
ts.walkPreorder(sf, (node) => {
|
|
1169
|
+
if (reason || !ts.isIdentifier(node) || node.text !== specifier.name.text || node === specifier.name || checker.getSymbolAtLocation(node) !== imported)
|
|
1170
|
+
return;
|
|
1171
|
+
const call = node.parent;
|
|
1172
|
+
if (!ts.isCallExpression(call) || call.expression !== node || !isCreateRequireBaseCall7(program, call)) {
|
|
1173
|
+
reason = "its createRequire import is used outside a supported call based on the current file";
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
const decl = call.parent;
|
|
1177
|
+
if (ts.isVariableDeclaration(decl) && decl.initializer === call && ts.isIdentifier(decl.name)) {
|
|
1178
|
+
if ((ts.getCombinedModifierFlags(decl) & ts.ModifierFlags.Export) !== 0) {
|
|
1179
|
+
reason = "its createRequire result escapes through an exported binding";
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
if (!isCreateRequireBinding7(program, decl.name)) {
|
|
1183
|
+
reason = stableCreateRequireBindingReason7(program, decl);
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
const sym = checker.getSymbolAtLocation(decl.name);
|
|
1187
|
+
const name = decl.name.text;
|
|
1188
|
+
checker.prefetchSymbolNodesExact(identifierOccurrences7(sf, name));
|
|
1189
|
+
ts.walkPreorder(sf, (ref) => {
|
|
1190
|
+
if (ts.isIdentifier(ref) && ref.text === name && ref !== decl.name && checker.getSymbolAtLocation(ref) === sym)
|
|
1191
|
+
checkUse(ref);
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
else {
|
|
1195
|
+
checkUse(call);
|
|
1196
|
+
}
|
|
1197
|
+
});
|
|
1198
|
+
if (reason)
|
|
1199
|
+
return reason;
|
|
1200
|
+
}
|
|
1201
|
+
return null;
|
|
1202
|
+
}
|
|
865
1203
|
/** Classifies a require-shaped call as Node's ambient CommonJS global, the
|
|
866
1204
|
* one supported createRequire source binding, or another source binding.
|
|
867
1205
|
* The scanners still collect createRequire calls because they carry static
|
|
@@ -946,9 +1284,11 @@ function nodeEsmSyntaxMarker7(sf) {
|
|
|
946
1284
|
found = node;
|
|
947
1285
|
return "stop";
|
|
948
1286
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1287
|
+
// Only await syntax needs an ancestor walk. Doing this for every node
|
|
1288
|
+
// makes a deeply nested expression take quadratic time to classify.
|
|
1289
|
+
if ((ts.isAwaitExpression(node) ||
|
|
1290
|
+
(ts.isForOfStatement(node) && node.awaitModifier !== undefined)) &&
|
|
1291
|
+
!insideFunctionLike7(node)) {
|
|
952
1292
|
found = node;
|
|
953
1293
|
return "stop";
|
|
954
1294
|
}
|
|
@@ -956,14 +1296,13 @@ function nodeEsmSyntaxMarker7(sf) {
|
|
|
956
1296
|
});
|
|
957
1297
|
return found;
|
|
958
1298
|
}
|
|
959
|
-
const nodeEsmFileCache7 = new WeakMap();
|
|
960
1299
|
/** True when Node would treat this file as an ES MODULE (never defining
|
|
961
1300
|
* require/__dirname there): fixed extensions first, then an explicit
|
|
962
1301
|
* nearest-package type, then Node's syntax markers for ambiguous .js/.ts
|
|
963
1302
|
* files. TypeScript's external-module bit is forced for checker scoping and
|
|
964
1303
|
* therefore intentionally plays no part in this runtime decision. */
|
|
965
|
-
function isNodeEsmFile7(sf) {
|
|
966
|
-
const cached =
|
|
1304
|
+
function isNodeEsmFile7(sf, program) {
|
|
1305
|
+
const cached = program?.analysis.nodeEsmFiles.get(sf);
|
|
967
1306
|
if (cached !== undefined)
|
|
968
1307
|
return cached;
|
|
969
1308
|
let result;
|
|
@@ -981,21 +1320,21 @@ function isNodeEsmFile7(sf) {
|
|
|
981
1320
|
? false
|
|
982
1321
|
: nodeEsmSyntaxMarker7(sf) !== null;
|
|
983
1322
|
}
|
|
984
|
-
|
|
1323
|
+
program?.analysis.nodeEsmFiles.set(sf, result);
|
|
985
1324
|
return result;
|
|
986
1325
|
}
|
|
987
1326
|
/** A JavaScript source file Node treats as CommonJS (not an ES module):
|
|
988
1327
|
* ESM namespace/default machinery must not claim it — its export surface
|
|
989
1328
|
* is module.exports, read through the CJS interop paths and their own
|
|
990
1329
|
* fences. */
|
|
991
|
-
function isCjsJsFile7(sf) {
|
|
992
|
-
return isJsSourceFileName(sf.fileName) && !isNodeEsmFile7(sf);
|
|
1330
|
+
function isCjsJsFile7(sf, program) {
|
|
1331
|
+
return isJsSourceFileName(sf.fileName) && !isNodeEsmFile7(sf, program);
|
|
993
1332
|
}
|
|
994
1333
|
/** The exported spelling of isCjsJsFile7 (the lowering's gate for
|
|
995
1334
|
* module.exports surfaces — `ts.isExternalModule` is NOT the CJS test:
|
|
996
1335
|
* tsgo marks CJS files with export assignments as external modules). */
|
|
997
|
-
export function isCjsJsFile(sf) {
|
|
998
|
-
return isCjsJsFile7(sf);
|
|
1336
|
+
export function isCjsJsFile(sf, program) {
|
|
1337
|
+
return isCjsJsFile7(sf, program);
|
|
999
1338
|
}
|
|
1000
1339
|
/** The self-import TDZ fences: for `import { x } from "<self>"` (default
|
|
1001
1340
|
* and namespace forms included), any TOP-LEVEL reference lexically above
|
|
@@ -1405,7 +1744,7 @@ function identifierOccurrences7(root, text) {
|
|
|
1405
1744
|
* Re-export statements bind nothing locally — always null: the alias is
|
|
1406
1745
|
* link-time plumbing, never an evaluation-time read. Export specifiers
|
|
1407
1746
|
* of an imported binding are the same alias story, not reads. */
|
|
1408
|
-
function backEdgeUseOffence7(program,
|
|
1747
|
+
function backEdgeUseOffence7(program, stmt, occurrences) {
|
|
1409
1748
|
if (!ts.isImportDeclaration(stmt) || stmt.importClause === undefined)
|
|
1410
1749
|
return null;
|
|
1411
1750
|
const checker = program.getTypeChecker();
|
|
@@ -1425,25 +1764,16 @@ function backEdgeUseOffence7(program, sf, stmt) {
|
|
|
1425
1764
|
const sym = checker.getSymbolAtLocation(bindingName);
|
|
1426
1765
|
if (sym === undefined)
|
|
1427
1766
|
continue;
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
const
|
|
1431
|
-
if (
|
|
1432
|
-
return;
|
|
1433
|
-
if (ts.isIdentifier(node) &&
|
|
1434
|
-
node.text === bindingName.text &&
|
|
1435
|
-
!(node.parent !== undefined && ts.isExportSpecifier(node.parent)) &&
|
|
1767
|
+
const references = occurrences.get(bindingName.text) ?? [];
|
|
1768
|
+
checker.prefetchSymbolNodesExact(references);
|
|
1769
|
+
for (const node of references) {
|
|
1770
|
+
if (!(node.parent !== undefined && ts.isExportSpecifier(node.parent)) &&
|
|
1436
1771
|
checker.getSymbolAtLocation(node) === sym &&
|
|
1437
1772
|
!inTypePosition7(node) &&
|
|
1438
1773
|
!inDeferredPosition7(node)) {
|
|
1439
|
-
|
|
1440
|
-
return;
|
|
1774
|
+
return { name: bindingName.text, node };
|
|
1441
1775
|
}
|
|
1442
|
-
|
|
1443
|
-
};
|
|
1444
|
-
visit(sf);
|
|
1445
|
-
if (offence !== null)
|
|
1446
|
-
return offence;
|
|
1776
|
+
}
|
|
1447
1777
|
}
|
|
1448
1778
|
return null;
|
|
1449
1779
|
}
|
|
@@ -1514,6 +1844,30 @@ export function makeCycleAdmission(program, edgesOf) {
|
|
|
1514
1844
|
// reason the cluster's cycles stay fenced, or null when its every
|
|
1515
1845
|
// member passes the inert-top-level bar.
|
|
1516
1846
|
const sccVerdict = new Map();
|
|
1847
|
+
// A module can close many cycle edges, each importing many bindings.
|
|
1848
|
+
// Index its identifiers once for this admission pass. ASTs are immutable;
|
|
1849
|
+
// the pass owns the index so it cannot retain a disposed program.
|
|
1850
|
+
const bindingUses = new Map();
|
|
1851
|
+
const usesOf = (sf) => {
|
|
1852
|
+
const cached = bindingUses.get(sf);
|
|
1853
|
+
if (cached !== undefined)
|
|
1854
|
+
return cached;
|
|
1855
|
+
const uses = new Map();
|
|
1856
|
+
ts.walkPreorder(sf, (node) => {
|
|
1857
|
+
if (ts.isImportDeclaration(node))
|
|
1858
|
+
return "skip";
|
|
1859
|
+
if (ts.isIdentifier(node)) {
|
|
1860
|
+
const references = uses.get(node.text);
|
|
1861
|
+
if (references !== undefined)
|
|
1862
|
+
references.push(node);
|
|
1863
|
+
else
|
|
1864
|
+
uses.set(node.text, [node]);
|
|
1865
|
+
}
|
|
1866
|
+
return undefined;
|
|
1867
|
+
});
|
|
1868
|
+
bindingUses.set(sf, uses);
|
|
1869
|
+
return uses;
|
|
1870
|
+
};
|
|
1517
1871
|
return (importer, e) => {
|
|
1518
1872
|
if (e.stmt === undefined)
|
|
1519
1873
|
return "the cycle closes through a require() edge";
|
|
@@ -1537,7 +1891,7 @@ export function makeCycleAdmission(program, edgesOf) {
|
|
|
1537
1891
|
if (!sccVerdict.has(comp)) {
|
|
1538
1892
|
let reason = null;
|
|
1539
1893
|
for (const m of comp) {
|
|
1540
|
-
if (isCjsJsFile7(m)) {
|
|
1894
|
+
if (isCjsJsFile7(m, program)) {
|
|
1541
1895
|
reason = `${m.fileName} is a CommonJS module — admission covers ES-module cycles only`;
|
|
1542
1896
|
break;
|
|
1543
1897
|
}
|
|
@@ -1550,9 +1904,11 @@ export function makeCycleAdmission(program, edgesOf) {
|
|
|
1550
1904
|
sccVerdict.set(comp, reason);
|
|
1551
1905
|
}
|
|
1552
1906
|
const clusterReason = sccVerdict.get(comp);
|
|
1907
|
+
if (clusterReason === undefined)
|
|
1908
|
+
throw new Error("missing module-cycle verdict");
|
|
1553
1909
|
if (clusterReason !== null)
|
|
1554
1910
|
return clusterReason;
|
|
1555
|
-
const use = backEdgeUseOffence7(program,
|
|
1911
|
+
const use = backEdgeUseOffence7(program, e.stmt, usesOf(importer));
|
|
1556
1912
|
if (use !== null) {
|
|
1557
1913
|
return `the cycle-crossing binding '${use.name}' is read at ${lineOf(use.node)}, outside any function body — a read during the init window observes the partially-initialized module (Node's TDZ ReferenceError / stale var), which is not modeled`;
|
|
1558
1914
|
}
|
|
@@ -1574,7 +1930,7 @@ function resolveImport7(program, from, specifier) {
|
|
|
1574
1930
|
* island under --dynamic. Resolution rides the own resolver (resolve.ts).
|
|
1575
1931
|
* Null for relative and node: specifiers, and for anything that doesn't
|
|
1576
1932
|
* resolve into node_modules. */
|
|
1577
|
-
function resolveNpmImport7(fromFileName, specifier) {
|
|
1933
|
+
function resolveNpmImport7(fromFileName, specifier, resolutionKind = "import") {
|
|
1578
1934
|
if (isRelativeSpecifier(specifier) || specifier.startsWith("node:")) {
|
|
1579
1935
|
return null;
|
|
1580
1936
|
}
|
|
@@ -1583,7 +1939,7 @@ function resolveNpmImport7(fromFileName, specifier) {
|
|
|
1583
1939
|
// answers the entry), so no island embed and no .d.ts type surface.
|
|
1584
1940
|
if (provenanceEntryFor(specifier) !== null)
|
|
1585
1941
|
return null;
|
|
1586
|
-
const resolved = resolveBareModule(fromFileName, specifier);
|
|
1942
|
+
const resolved = resolveBareModule(fromFileName, specifier, undefined, resolutionKind);
|
|
1587
1943
|
if (!resolved)
|
|
1588
1944
|
return null;
|
|
1589
1945
|
if (!isNodeModulesPath(resolved.typesFile)) {
|
|
@@ -1658,29 +2014,27 @@ function processModuleAliasImport7(spec, stmt) {
|
|
|
1658
2014
|
return clause !== undefined && clause.name !== undefined && clause.namedBindings === undefined;
|
|
1659
2015
|
}
|
|
1660
2016
|
/** The whole TS7-lane lifecycle for one entry: spawn (or share) a tsgo
|
|
1661
|
-
* host, build the lowering-world program, run
|
|
1662
|
-
*
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
const host = sharedHost ?? new ts.Ts7Host({ cwd: dirname(entryPath) });
|
|
2017
|
+
* host, build the lowering-world program, run preflight, and release its
|
|
2018
|
+
* snapshot. The caller owns the supplied host and can reuse or close it. */
|
|
2019
|
+
export function checkPreflightTs7(entryPath, host) {
|
|
2020
|
+
const load = loadProgram7(host, resolve(entryPath));
|
|
1666
2021
|
try {
|
|
1667
|
-
const
|
|
1668
|
-
|
|
1669
|
-
const { diags, moduleOrder } = preflight7(load);
|
|
1670
|
-
return { diags, moduleOrder: moduleOrder.map((sf) => sf.fileName) };
|
|
1671
|
-
}
|
|
1672
|
-
finally {
|
|
1673
|
-
load.disposeAll();
|
|
1674
|
-
}
|
|
2022
|
+
const { diags, moduleOrder } = preflight7(load);
|
|
2023
|
+
return { diags, moduleOrder: moduleOrder.map((sf) => sf.fileName) };
|
|
1675
2024
|
}
|
|
1676
2025
|
finally {
|
|
1677
|
-
|
|
1678
|
-
host.close();
|
|
2026
|
+
load.disposeAll();
|
|
1679
2027
|
}
|
|
1680
2028
|
}
|
|
1681
2029
|
function preflight7(load) {
|
|
1682
2030
|
const { program, entry } = load;
|
|
1683
2031
|
const diags = [...load.configDiags];
|
|
2032
|
+
// An explicit entry can itself live in an installed package. Its own
|
|
2033
|
+
// source files are program code, including relative barrels and sibling
|
|
2034
|
+
// modules; their location must not silently erase the module graph.
|
|
2035
|
+
// Match the full installed directory, not just the package name, and
|
|
2036
|
+
// exclude nested installations so dependencies keep their npm policy.
|
|
2037
|
+
const entryPackageFile = entryPackageFilePredicate(entry.fileName);
|
|
1684
2038
|
// Workspace-linked packages register BEFORE the tsc gate. Their files
|
|
1685
2039
|
// live at realpaths OUTSIDE node_modules (the monorepo-tool symlink
|
|
1686
2040
|
// shape), so nothing path-shaped marks them as npm surface — yet their
|
|
@@ -1808,6 +2162,7 @@ function preflight7(load) {
|
|
|
1808
2162
|
* pass above), suppressed here unless --npm-static opted them into being
|
|
1809
2163
|
* program modules. */
|
|
1810
2164
|
const islandJsFile = (file) => isJsSourceFileName(file) &&
|
|
2165
|
+
!entryPackageFile(file) &&
|
|
1811
2166
|
npmStaticPackageOfPath(file) === null &&
|
|
1812
2167
|
(isNodeModulesPath(file) || workspacePackageOfPath(file) !== null);
|
|
1813
2168
|
const nodeModulesJsSuppressed = (d) => d.fileName !== undefined && islandJsFile(d.fileName);
|
|
@@ -1882,6 +2237,8 @@ function preflight7(load) {
|
|
|
1882
2237
|
!npmStaticFileSuppressed(d) &&
|
|
1883
2238
|
!nodeModulesJsSuppressed(d) &&
|
|
1884
2239
|
!namespaceCalleeSuppressed(p, d) &&
|
|
2240
|
+
!inferredJsDiagnosticSuppressed(p, d) &&
|
|
2241
|
+
!isNpmStaticSubclassArgument(p, d) &&
|
|
1885
2242
|
!workspaceImplicitAnySuppressed(p, d) &&
|
|
1886
2243
|
!jsdocTypeSuppressed(p, d, commentDup));
|
|
1887
2244
|
};
|
|
@@ -1914,10 +2271,10 @@ function preflight7(load) {
|
|
|
1914
2271
|
.filter((sf) => sf.fileName !== ambient &&
|
|
1915
2272
|
!sf.isDeclarationFile &&
|
|
1916
2273
|
!sf.fileName.endsWith(".json") &&
|
|
1917
|
-
(!isNodeModulesPath(sf.fileName) || npmStaticPackageOfPath(sf.fileName) !== null) &&
|
|
2274
|
+
(!isNodeModulesPath(sf.fileName) || entryPackageFile(sf.fileName) || npmStaticPackageOfPath(sf.fileName) !== null) &&
|
|
1918
2275
|
!islandJsFile(sf.fileName));
|
|
1919
2276
|
const userFiles = npmStaticActive()
|
|
1920
|
-
? planNpmStaticReexports(program, entry, programFiles, [...createRequireProgramRoots7(program), ...forkTargetPaths(program, program.getSourceFiles())], (sf, spec) => resolveImport7(program, sf, spec) ?? npmStaticDepSf7(program, sf, spec))
|
|
2277
|
+
? planNpmStaticReexports(program, entry, programFiles, [...createRequireProgramRoots7(program), ...forkTargetPaths(program, program.getSourceFiles())], (sf, spec, resolutionKind) => resolveImport7(program, sf, spec) ?? npmStaticDepSf7(program, sf, spec, resolutionKind))
|
|
1921
2278
|
: programFiles;
|
|
1922
2279
|
program.getTypeChecker().prefetchSourceFileStructures(userFiles);
|
|
1923
2280
|
// node_modules JS that no --npm-static opt-in claims is NOT program
|
|
@@ -1941,7 +2298,7 @@ function preflight7(load) {
|
|
|
1941
2298
|
}
|
|
1942
2299
|
continue;
|
|
1943
2300
|
}
|
|
1944
|
-
if (!isNodeEsmFile7(sf)) {
|
|
2301
|
+
if (!isNodeEsmFile7(sf, program)) {
|
|
1945
2302
|
const marker = nodeEsmSyntaxMarker7(sf);
|
|
1946
2303
|
if (marker !== null)
|
|
1947
2304
|
diags.push(commonJsModuleSyntaxDiag(locOf7(marker)));
|
|
@@ -2079,7 +2436,7 @@ function preflight7(load) {
|
|
|
2079
2436
|
// RESOLVED user module lowers; everything else keeps the fence —
|
|
2080
2437
|
// there is no namespace object to materialize.
|
|
2081
2438
|
if (stmt.exportClause && ts.isNamespaceExport(stmt.exportClause)) {
|
|
2082
|
-
if (reDep === null || reDep.fileName.endsWith(".json") || isCjsJsFile7(reDep)) {
|
|
2439
|
+
if (reDep === null || reDep.fileName.endsWith(".json") || isCjsJsFile7(reDep, program)) {
|
|
2083
2440
|
diags.push(unsupportedDiag("SC1013", locOf7(stmt), "namespace re-exports (export * as ns) of this module form"));
|
|
2084
2441
|
continue;
|
|
2085
2442
|
}
|
|
@@ -2110,17 +2467,15 @@ function preflight7(load) {
|
|
|
2110
2467
|
}
|
|
2111
2468
|
const isRelative = isRelativeSpecifier(spec);
|
|
2112
2469
|
const isBare = !isRelative && !ambientModules.has(spec);
|
|
2113
|
-
//
|
|
2114
|
-
//
|
|
2115
|
-
//
|
|
2116
|
-
// only literal-specifier requires, and bundler banners (esbuild's
|
|
2117
|
-
// __createRequire(import.meta.url) prologue) feed the returned
|
|
2118
|
-
// require COMPUTED specifiers at module INIT, so a static compile
|
|
2119
|
-
// would fence at load where the island runs the package as shipped.
|
|
2470
|
+
// Npm packages can use the same static createRequire forms as program
|
|
2471
|
+
// code. Preserve fallback for bundler banners that pass the require
|
|
2472
|
+
// value around or feed it computed specifiers during initialization.
|
|
2120
2473
|
if (canonicalBuiltinModule(spec) === "module") {
|
|
2121
2474
|
const pkg = npmStaticPackageOfPath(sf.fileName);
|
|
2122
2475
|
if (pkg !== null) {
|
|
2123
|
-
|
|
2476
|
+
const reason = npmStaticModuleImportReason7(program, stmt);
|
|
2477
|
+
if (reason !== null)
|
|
2478
|
+
reportNpmStaticOffender(pkg, reason);
|
|
2124
2479
|
}
|
|
2125
2480
|
}
|
|
2126
2481
|
// An import edge Node's own resolution refuses BEFORE any module
|
|
@@ -2245,17 +2600,13 @@ function preflight7(load) {
|
|
|
2245
2600
|
// surface and the lowering keys the same tables
|
|
2246
2601
|
// (builtinNamespaceModuleOf's default-import twin). JS sources
|
|
2247
2602
|
// always (Node never asks for interop flags); TS sources when the
|
|
2248
|
-
//
|
|
2249
|
-
//
|
|
2250
|
-
//
|
|
2251
|
-
//
|
|
2252
|
-
|
|
2253
|
-
// callable module objects (assert, events, test) stay allowed
|
|
2254
|
-
// everywhere.
|
|
2255
|
-
const opts = program.getCompilerOptions();
|
|
2256
|
-
const interopOn = opts.esModuleInterop === true || opts.allowSyntheticDefaultImports === true;
|
|
2603
|
+
// project's explicit or implied synthetic-default permission accepts
|
|
2604
|
+
// the spelling. A TS project without that permission keeps the
|
|
2605
|
+
// SC1012 fence. The callable module objects (assert, events, test)
|
|
2606
|
+
// stay allowed everywhere.
|
|
2607
|
+
const syntheticDefaultsOn = program.getCompilerOptions().allowSyntheticDefaultImports === true;
|
|
2257
2608
|
const defaultOk = builtinDefaultImportModule(spec) !== null ||
|
|
2258
|
-
((isJsSourceFileName(sf.fileName) ||
|
|
2609
|
+
((isJsSourceFileName(sf.fileName) || syntheticDefaultsOn) && canonicalBuiltinModule(spec) !== null);
|
|
2259
2610
|
if (clause.name && !isJson && dep === null && !defaultOk) {
|
|
2260
2611
|
diags.push(unsupportedDiag("SC1012", locOf7(clause.name)));
|
|
2261
2612
|
}
|
|
@@ -2276,7 +2627,7 @@ function preflight7(load) {
|
|
|
2276
2627
|
if (isJson) {
|
|
2277
2628
|
diags.push(unsupportedDiag("SC1013", locOf7(clause.namedBindings), "namespace imports of JSON modules"));
|
|
2278
2629
|
}
|
|
2279
|
-
else if (dep !== null && isCjsJsFile7(dep)) {
|
|
2630
|
+
else if (dep !== null && isCjsJsFile7(dep, program)) {
|
|
2280
2631
|
// A CJS namespace binding whose every use is a bare expression
|
|
2281
2632
|
// statement (`cjs;` — the corpus's "the import linked"
|
|
2282
2633
|
// assertion) carries no surface question: the statement lowers
|
|
@@ -2304,7 +2655,7 @@ function preflight7(load) {
|
|
|
2304
2655
|
const stmts = sf.statements;
|
|
2305
2656
|
let firstRunnable = -1;
|
|
2306
2657
|
stmts.forEach((s, i) => {
|
|
2307
|
-
if (firstRunnable < 0 && !purePrefixStmt7(s))
|
|
2658
|
+
if (firstRunnable < 0 && !purePrefixStmt7(program, s))
|
|
2308
2659
|
firstRunnable = i;
|
|
2309
2660
|
});
|
|
2310
2661
|
for (let k = 0; k < stmts.length; k++) {
|
|
@@ -2318,7 +2669,7 @@ function preflight7(load) {
|
|
|
2318
2669
|
// files keep the full CommonJS scan.
|
|
2319
2670
|
if (!jsRequireFile && bindingKind !== "createRequire")
|
|
2320
2671
|
continue;
|
|
2321
|
-
if (isNodeEsmFile7(sf)) {
|
|
2672
|
+
if (isNodeEsmFile7(sf, program)) {
|
|
2322
2673
|
if (bindingKind !== "createRequire") {
|
|
2323
2674
|
diags.push(unsupportedDiag("SC1013", loc, esmRequireFeature7(bindingKind)));
|
|
2324
2675
|
continue;
|
|
@@ -2346,7 +2697,7 @@ function preflight7(load) {
|
|
|
2346
2697
|
// form above (bundle dists require their workspace siblings —
|
|
2347
2698
|
// the same resolution, the same offender discipline on a
|
|
2348
2699
|
// miss).
|
|
2349
|
-
const npmReq = !req.spec.startsWith("#") ? resolveNpmImport7(sf.fileName, req.spec) : null;
|
|
2700
|
+
const npmReq = !req.spec.startsWith("#") ? resolveNpmImport7(sf.fileName, req.spec, "require") : null;
|
|
2350
2701
|
if (npmReq !== null && isNpmStaticPackage(npmReq.packageName)) {
|
|
2351
2702
|
dep = npmStaticProgramDep(program, npmReq.packageName, npmReq.typesFile);
|
|
2352
2703
|
if (dep === null)
|
|
@@ -2381,8 +2732,16 @@ function preflight7(load) {
|
|
|
2381
2732
|
diags.push(unsupportedDiag("SC1012", loc, "require() of JSON modules"));
|
|
2382
2733
|
continue;
|
|
2383
2734
|
}
|
|
2384
|
-
|
|
2385
|
-
|
|
2735
|
+
// Earlier declarators run too: `const x = read(), dep =
|
|
2736
|
+
// require('./dep')` must not lose the guard merely because both
|
|
2737
|
+
// initializers share one VariableStatement.
|
|
2738
|
+
const precedingDecls = req.decl && ts.isVariableStatement(stmt)
|
|
2739
|
+
? stmt.declarationList.declarations.slice(0, stmt.declarationList.declarations.indexOf(req.decl))
|
|
2740
|
+
: [];
|
|
2741
|
+
const prefixCanRun = (firstRunnable >= 0 && firstRunnable < k) ||
|
|
2742
|
+
precedingDecls.some((decl) => !purePrefixDecl7(decl));
|
|
2743
|
+
const tdzName = prefixCanRun && req.decl
|
|
2744
|
+
? bindingEarlyUse7(program, sf, k, req.decl, precedingDecls)
|
|
2386
2745
|
: null;
|
|
2387
2746
|
if (tdzName !== null) {
|
|
2388
2747
|
diags.push(unsupportedDiag("SC1013", loc, `require() below code that can reach its binding '${tdzName}' (Node initializes the binding AT the require and throws ReferenceError on any earlier access, which is not modeled — move the require above the code that can run first)`));
|
|
@@ -2400,7 +2759,7 @@ function preflight7(load) {
|
|
|
2400
2759
|
const bindingKind = requireCallBindingKind7(program, call);
|
|
2401
2760
|
if (!jsRequireFile && bindingKind !== "createRequire")
|
|
2402
2761
|
continue;
|
|
2403
|
-
if (isNodeEsmFile7(sf)) {
|
|
2762
|
+
if (isNodeEsmFile7(sf, program)) {
|
|
2404
2763
|
if (bindingKind !== "createRequire") {
|
|
2405
2764
|
diags.push(unsupportedDiag("SC1013", loc, esmRequireFeature7(bindingKind)));
|
|
2406
2765
|
continue;
|
|
@@ -2423,7 +2782,7 @@ function preflight7(load) {
|
|
|
2423
2782
|
if (!isRelativeSpecifier(spec)) {
|
|
2424
2783
|
// --npm-static: opted-in packages ride the program-module edge
|
|
2425
2784
|
// (the statement-level require branch above).
|
|
2426
|
-
const npmReq = !spec.startsWith("#") ? resolveNpmImport7(sf.fileName, spec) : null;
|
|
2785
|
+
const npmReq = !spec.startsWith("#") ? resolveNpmImport7(sf.fileName, spec, "require") : null;
|
|
2427
2786
|
if (npmReq !== null && isNpmStaticPackage(npmReq.packageName)) {
|
|
2428
2787
|
const nDep = npmStaticProgramDep(program, npmReq.packageName, npmReq.typesFile);
|
|
2429
2788
|
if (nDep !== null)
|
|
@@ -2572,19 +2931,19 @@ function cjsNamedImportLinkCheck(program, entry, moduleOrder, diags) {
|
|
|
2572
2931
|
// Reexport targets union in only when they resolve to CommonJS program
|
|
2573
2932
|
// files (Node's cjsPreparseModuleExports rule).
|
|
2574
2933
|
const resolveCjsDep = (from, spec) => {
|
|
2575
|
-
const dep =
|
|
2576
|
-
return dep !== null && isCjsJsFile7(dep) ? dep : null;
|
|
2934
|
+
const dep = resolveImport7(program, from, spec) ?? npmStaticDepSf7(program, from, spec, "require");
|
|
2935
|
+
return dep !== null && isCjsJsFile7(dep, program) ? dep : null;
|
|
2577
2936
|
};
|
|
2578
2937
|
const visible = (dep, name) =>
|
|
2579
2938
|
// `default` is the module.exports binding itself — always provided.
|
|
2580
|
-
//
|
|
2581
|
-
//
|
|
2582
|
-
name === "default" ||
|
|
2939
|
+
// The program already owns native source ASTs; reuse them without
|
|
2940
|
+
// starting another syntax session or reparsing their source text.
|
|
2941
|
+
name === "default" || cjsVisibleNames(dep, cjsLexedExportsOfFile, resolveCjsDep, lexMemo).has(name);
|
|
2583
2942
|
/** The statement's resolved LOCAL CommonJS dependency, when it is an
|
|
2584
2943
|
* import/re-export from one. */
|
|
2585
2944
|
const cjsDepOf = (sf, spec) => {
|
|
2586
2945
|
const dep = resolveEdge(sf, spec);
|
|
2587
|
-
return dep !== null && isCjsJsFile7(dep) ? dep : null;
|
|
2946
|
+
return dep !== null && isCjsJsFile7(dep, program) ? dep : null;
|
|
2588
2947
|
};
|
|
2589
2948
|
/** The first lexer-invisible CJS name request of ONE module, in V8's
|
|
2590
2949
|
* check order: all regular named imports sorted by local binding name,
|
|
@@ -2657,7 +3016,7 @@ function cjsNamedImportLinkCheck(program, entry, moduleOrder, diags) {
|
|
|
2657
3016
|
continue;
|
|
2658
3017
|
const spec = specNode.text;
|
|
2659
3018
|
const dep = resolveEdge(sf, spec);
|
|
2660
|
-
if (dep === null || dep.fileName.endsWith(".json") || !isNodeEsmFile7(dep))
|
|
3019
|
+
if (dep === null || dep.fileName.endsWith(".json") || !isNodeEsmFile7(dep, program))
|
|
2661
3020
|
continue;
|
|
2662
3021
|
const bad = dfs(dep);
|
|
2663
3022
|
if (bad !== null)
|
|
@@ -2665,12 +3024,12 @@ function cjsNamedImportLinkCheck(program, entry, moduleOrder, diags) {
|
|
|
2665
3024
|
}
|
|
2666
3025
|
return firstInvisibleOf(sf);
|
|
2667
3026
|
};
|
|
2668
|
-
const bad = isNodeEsmFile7(entry) ? dfs(entry) : null;
|
|
3027
|
+
const bad = isNodeEsmFile7(entry, program) ? dfs(entry) : null;
|
|
2669
3028
|
// ESM modules only require() reaches: same invisibility, but Node's
|
|
2670
3029
|
// SyntaxError fires mid-evaluation at the require — a pointed fence
|
|
2671
3030
|
// instead of a mismodeled crash position.
|
|
2672
3031
|
for (const sf of moduleOrder) {
|
|
2673
|
-
if (!isNodeEsmFile7(sf) || visited.has(sf))
|
|
3032
|
+
if (!isNodeEsmFile7(sf, program) || visited.has(sf))
|
|
2674
3033
|
continue;
|
|
2675
3034
|
const b = firstInvisibleOf(sf);
|
|
2676
3035
|
if (b !== null) {
|
|
@@ -2786,7 +3145,7 @@ function analyzeEsmNamedImportLinks(program, entry) {
|
|
|
2786
3145
|
if (stmt.moduleSpecifier === undefined || !ts.isStringLiteral(stmt.moduleSpecifier))
|
|
2787
3146
|
continue;
|
|
2788
3147
|
const target = resolveEdge(dep, stmt.moduleSpecifier.text);
|
|
2789
|
-
if (target === null || target.fileName.endsWith(".json") || !isNodeEsmFile7(target))
|
|
3148
|
+
if (target === null || target.fileName.endsWith(".json") || !isNodeEsmFile7(target, program))
|
|
2790
3149
|
continue;
|
|
2791
3150
|
const candidate = runtimeExport(target, name, nextSeen);
|
|
2792
3151
|
if (candidate === undefined)
|
|
@@ -2807,7 +3166,7 @@ function analyzeEsmNamedImportLinks(program, entry) {
|
|
|
2807
3166
|
continue;
|
|
2808
3167
|
const spec = stmt.moduleSpecifier.text;
|
|
2809
3168
|
const dep = resolveEdge(sf, spec);
|
|
2810
|
-
if (dep === null || dep.fileName.endsWith(".json") || !isNodeEsmFile7(dep))
|
|
3169
|
+
if (dep === null || dep.fileName.endsWith(".json") || !isNodeEsmFile7(dep, program))
|
|
2811
3170
|
continue;
|
|
2812
3171
|
if (clause.name !== undefined) {
|
|
2813
3172
|
imports.push({ local: clause.name.text, exportName: "default", spec, nameNode: clause.name, dep });
|
|
@@ -2852,7 +3211,7 @@ function analyzeEsmNamedImportLinks(program, entry) {
|
|
|
2852
3211
|
continue;
|
|
2853
3212
|
const spec = moduleSpecifier.text;
|
|
2854
3213
|
const dep = resolveEdge(sf, spec);
|
|
2855
|
-
if (dep === null || dep.fileName.endsWith(".json") || !isNodeEsmFile7(dep))
|
|
3214
|
+
if (dep === null || dep.fileName.endsWith(".json") || !isNodeEsmFile7(dep, program))
|
|
2856
3215
|
continue;
|
|
2857
3216
|
for (const element of exportClause.elements) {
|
|
2858
3217
|
if (element.isTypeOnly)
|
|
@@ -2884,7 +3243,7 @@ function analyzeEsmNamedImportLinks(program, entry) {
|
|
|
2884
3243
|
if (moduleSpecifier === undefined || !ts.isStringLiteral(moduleSpecifier))
|
|
2885
3244
|
continue;
|
|
2886
3245
|
const dep = resolveEdge(sf, moduleSpecifier.text);
|
|
2887
|
-
if (dep === null || dep.fileName.endsWith(".json") || !isNodeEsmFile7(dep))
|
|
3246
|
+
if (dep === null || dep.fileName.endsWith(".json") || !isNodeEsmFile7(dep, program))
|
|
2888
3247
|
continue;
|
|
2889
3248
|
const bad = dfs(dep);
|
|
2890
3249
|
if (bad !== null)
|
|
@@ -2895,7 +3254,7 @@ function analyzeEsmNamedImportLinks(program, entry) {
|
|
|
2895
3254
|
// Native ESM linking itself starts only from an ESM entry. The caller
|
|
2896
3255
|
// supplies dynamic-only roots here too; each such root gets its own
|
|
2897
3256
|
// promise rejection rather than a startup crash.
|
|
2898
|
-
const bad = isNodeEsmFile7(entry) ? dfs(entry) : null;
|
|
3257
|
+
const bad = isNodeEsmFile7(entry, program) ? dfs(entry) : null;
|
|
2899
3258
|
if (bad !== null) {
|
|
2900
3259
|
return {
|
|
2901
3260
|
crash: {
|
|
@@ -2922,7 +3281,7 @@ function esmNamedImportLinkCheck(program, entry, moduleOrder, diags) {
|
|
|
2922
3281
|
// before earlier output). Keep the compile-time fence used by the CJS link
|
|
2923
3282
|
// checker for the analogous mid-evaluation failure instead.
|
|
2924
3283
|
for (const sf of moduleOrder) {
|
|
2925
|
-
if (!isNodeEsmFile7(sf) || analysis.visited.has(sf))
|
|
3284
|
+
if (!isNodeEsmFile7(sf, program) || analysis.visited.has(sf))
|
|
2926
3285
|
continue;
|
|
2927
3286
|
const childFailure = analysis.firstMissingOf(sf);
|
|
2928
3287
|
if (childFailure !== null) {
|
|
@@ -3090,12 +3449,12 @@ export function orderedImportsOf(program, sf) {
|
|
|
3090
3449
|
* as a module edge), else null. No offender reporting here — preflight
|
|
3091
3450
|
* already classified the import; this is the lookup the module-order and
|
|
3092
3451
|
* lowering paths share. */
|
|
3093
|
-
export function npmStaticDepSf7(program, sf, spec) {
|
|
3452
|
+
export function npmStaticDepSf7(program, sf, spec, resolutionKind = "import") {
|
|
3094
3453
|
if (!npmStaticActive() || isRelativeSpecifier(spec))
|
|
3095
3454
|
return null;
|
|
3096
3455
|
if (spec.startsWith("node:") || spec.startsWith("#"))
|
|
3097
3456
|
return null;
|
|
3098
|
-
const npm = resolveNpmImport7(sf.fileName, spec);
|
|
3457
|
+
const npm = resolveNpmImport7(sf.fileName, spec, resolutionKind);
|
|
3099
3458
|
if (npm === null || !isNpmStaticPackage(npm.packageName))
|
|
3100
3459
|
return null;
|
|
3101
3460
|
if (!isJsSourceFileName(npm.typesFile))
|