@scriptc/compiler 0.4.7 → 0.4.8
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/node-fallback/child_process.d.ts +71 -22
- package/ambient/node-fallback/crypto.d.ts +15 -7
- package/ambient/node-fallback/events.d.ts +23 -5
- package/ambient/node-fallback/fs.d.ts +3 -2
- package/ambient/node-fallback/http.d.ts +23 -17
- package/ambient/node-fallback/https.d.ts +5 -2
- package/ambient/node-fallback/net.d.ts +6 -0
- package/ambient/node-fallback/os.d.ts +11 -1
- package/ambient/node-fallback/path-posix.d.ts +6 -0
- package/ambient/node-fallback/path-win32.d.ts +5 -0
- package/ambient/node-fallback/path.d.ts +2 -0
- package/ambient/node-fallback/zlib.d.ts +31 -2
- package/ambient/scriptc-node-fallback.d.ts +37 -7
- package/ambient/scriptc.d.ts +7 -2
- package/dist/backend/executable-features.js +11 -3
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/library-pack.d.ts +6 -0
- package/dist/backend/library-pack.js +17 -6
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/library-pack.test.d.ts +1 -0
- package/dist/backend/library-pack.test.js +28 -0
- package/dist/backend/library-pack.test.js.map +1 -0
- package/dist/backend/linker.d.ts +9 -2
- package/dist/backend/linker.js +190 -32
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +8 -4
- package/dist/backend/lld.js +19 -13
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +3 -1
- package/dist/backend/lld.test.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +15 -2
- package/dist/backend/llvm/alloc.js +172 -36
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +69 -1
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/arenas.d.ts +17 -4
- package/dist/backend/llvm/arenas.js +105 -10
- package/dist/backend/llvm/arenas.js.map +1 -1
- package/dist/backend/llvm/arenas.test.js +229 -0
- package/dist/backend/llvm/arenas.test.js.map +1 -1
- package/dist/backend/llvm/bytes-alias.js +10 -1
- package/dist/backend/llvm/bytes-alias.js.map +1 -1
- package/dist/backend/llvm/bytes-headers.js +6 -0
- package/dist/backend/llvm/bytes-headers.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.js +10 -0
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +16 -9
- package/dist/backend/llvm/classes.js +142 -37
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +42 -0
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
- package/dist/backend/llvm/cpu-dispatch.js +31 -7
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +12 -3
- package/dist/backend/llvm/dyn.js +31 -7
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +67 -4
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +90 -39
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-module.test.d.ts +1 -0
- package/dist/backend/llvm/emit-module.test.js +52 -0
- package/dist/backend/llvm/emit-module.test.js.map +1 -0
- package/dist/backend/llvm/emit-statements.js +99 -15
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +113 -8
- package/dist/backend/llvm/emitter.js +438 -67
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +31 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +19 -1
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +16 -1
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +18 -2
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +31 -10
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +31 -3
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +1 -1
- package/dist/backend/llvm/expr-records.js +124 -56
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +17 -0
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/js-groups.d.ts +21 -0
- package/dist/backend/llvm/js-groups.js +277 -0
- package/dist/backend/llvm/js-groups.js.map +1 -0
- package/dist/backend/llvm/js-ic.d.ts +19 -1
- package/dist/backend/llvm/js-ic.js +96 -23
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +132 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +33 -6
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +44 -3
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +69 -2
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +32 -0
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/loop-state.js +7 -2
- package/dist/backend/llvm/loop-state.js.map +1 -1
- package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
- package/dist/backend/llvm/map-entry-fusion.js +3 -3
- package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +6 -6
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.js +7 -6
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.test.js +4 -1
- package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
- package/dist/backend/llvm/receivers.js +3 -0
- package/dist/backend/llvm/receivers.js.map +1 -1
- package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
- package/dist/backend/llvm/record-entry-fusion.js +217 -0
- package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
- package/dist/backend/llvm/record-results.d.ts +5 -2
- package/dist/backend/llvm/record-results.js +13 -12
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/record-views.js +12 -6
- package/dist/backend/llvm/record-views.js.map +1 -1
- package/dist/backend/llvm/reference-effects.js +1 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +3 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/region-ir.js +1 -0
- package/dist/backend/llvm/region-ir.js.map +1 -1
- package/dist/backend/llvm/region-sites.d.ts +18 -0
- package/dist/backend/llvm/region-sites.js +79 -1
- package/dist/backend/llvm/region-sites.js.map +1 -1
- package/dist/backend/llvm/runtime-registries.test.js +53 -6
- package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +33 -3
- package/dist/backend/llvm/shapes.js +183 -13
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +1 -2
- package/dist/backend/llvm/stack-objects.js +8 -5
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +12 -0
- package/dist/backend/llvm/walkers.js +46 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +12 -2
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +13 -0
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +48 -8
- package/dist/backend/native/executable.js +55 -13
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/helper-identity-record.d.ts +11 -0
- package/dist/backend/native/helper-identity-record.js +76 -0
- package/dist/backend/native/helper-identity-record.js.map +1 -0
- package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
- package/dist/backend/native/helper-identity-record.test.js +101 -0
- package/dist/backend/native/helper-identity-record.test.js.map +1 -0
- package/dist/backend/native/library.js +9 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.js +4 -1
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native/vendor.js +1 -1
- package/dist/backend/native/vendor.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +13 -10
- package/dist/backend/native-codegen-core.js +26 -13
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.js +27 -8
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +110 -14
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +37 -8
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/runtime-pack-core.d.ts +17 -2
- package/dist/backend/runtime-pack-core.js +18 -3
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +211 -2
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/tree-classes.d.ts +42 -0
- package/dist/backend/tree-classes.js +723 -0
- package/dist/backend/tree-classes.js.map +1 -0
- package/dist/backend/tree-classes.test.d.ts +1 -0
- package/dist/backend/tree-classes.test.js +338 -0
- package/dist/backend/tree-classes.test.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +5 -1
- package/dist/backend/vendor-archives.js +51 -7
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +25 -4
- package/dist/backend/vendor-inputs.js +68 -4
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.js +35 -1
- package/dist/backend/vendor-inputs.test.js.map +1 -1
- package/dist/backend/warm-cache.js +1 -1
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/compat/fetch-profile.js +2 -2
- package/dist/coverage/report.js +47 -0
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -1
- package/dist/diagnostics/codes.d.ts +8 -0
- package/dist/diagnostics/codes.js +8 -0
- package/dist/diagnostics/codes.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +27 -9
- package/dist/diagnostics/diagnostic.js +60 -19
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +18 -0
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +21 -2
- package/dist/executable/executable-cache.js +21 -1
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +123 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +199 -248
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +200 -18
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +4 -0
- package/dist/frontend/builtin-modules.js +10 -0
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/early-errors.d.ts +12 -2
- package/dist/frontend/early-errors.js +535 -4
- package/dist/frontend/early-errors.js.map +1 -1
- package/dist/frontend/early-errors.test.js +165 -0
- package/dist/frontend/early-errors.test.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.test.js +65 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
- package/dist/frontend/jsx-opinion-sites.test.js +86 -0
- package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
- package/dist/frontend/lib-exports.d.ts +23 -4
- package/dist/frontend/lib-exports.js +98 -26
- package/dist/frontend/lib-exports.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.js +21 -3
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/buffers.d.ts +8 -0
- package/dist/frontend/lowering/buffers.js +43 -0
- package/dist/frontend/lowering/buffers.js.map +1 -0
- package/dist/frontend/lowering/builtin-calls.js +4 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
- package/dist/frontend/lowering/builtin-namespaces.js +24 -3
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
- package/dist/frontend/lowering/builtin-statics.js +407 -0
- package/dist/frontend/lowering/builtin-statics.js.map +1 -0
- package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
- package/dist/frontend/lowering/builtins/arguments.js +12 -0
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
- package/dist/frontend/lowering/builtins/atomics.js +87 -1
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.js +2 -2
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
- package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
- package/dist/frontend/lowering/builtins/child-process.js +560 -27
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
- package/dist/frontend/lowering/builtins/compression.js +41 -21
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/constants.js +7 -2
- package/dist/frontend/lowering/builtins/constants.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +28 -2
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +4 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +3 -1
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
- package/dist/frontend/lowering/builtins/numbers.js +10 -2
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +6 -3
- package/dist/frontend/lowering/builtins/operating-system.js +96 -16
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +2 -2
- package/dist/frontend/lowering/builtins/process.js +103 -8
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +169 -8
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/properties.js +6 -2
- package/dist/frontend/lowering/builtins/properties.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
- package/dist/frontend/lowering/builtins/readline.js +180 -36
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +35 -12
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/webassembly.js +2 -0
- package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +10 -0
- package/dist/frontend/lowering/call-arguments.js +37 -2
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +10 -0
- package/dist/frontend/lowering/call-signatures.js +103 -0
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +14 -2
- package/dist/frontend/lowering/class-construction.js +99 -5
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +9 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1283 -1030
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +20 -15
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
- package/dist/frontend/lowering/class-runtime-statics.js +20 -1
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/class-unions.js +21 -4
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +9 -0
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +8 -0
- package/dist/frontend/lowering/coercions/state.js +17 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +20 -5
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +10 -1
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
- package/dist/frontend/lowering/coercions/unions.js +54 -10
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
- package/dist/frontend/lowering/constructor-returns.js +284 -58
- package/dist/frontend/lowering/constructor-returns.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +156 -62
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +21 -3
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-from-async.js +139 -3
- package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
- package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
- package/dist/frontend/lowering/containers/array-iteration.js +24 -7
- package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +14 -11
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
- package/dist/frontend/lowering/containers/bytes.js +446 -86
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +5 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +21 -12
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +52 -17
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
- package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
- package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
- package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
- package/dist/frontend/lowering/crypto-tables.js +5 -5
- package/dist/frontend/lowering/dispatch-sites.js +3 -0
- package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
- package/dist/frontend/lowering/divergences.d.ts +40 -0
- package/dist/frontend/lowering/divergences.js +239 -20
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/effect-free.d.ts +12 -0
- package/dist/frontend/lowering/effect-free.js +44 -0
- package/dist/frontend/lowering/effect-free.js.map +1 -0
- package/dist/frontend/lowering/expressions/array-literals.d.ts +10 -0
- package/dist/frontend/lowering/expressions/array-literals.js +62 -0
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +115 -5
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +151 -7
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +31 -2
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
- package/dist/frontend/lowering/expressions/narrowing.js +175 -22
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +173 -11
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +5 -1
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +8 -0
- package/dist/frontend/lowering/expressions/property-access.js +379 -109
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +237 -7
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +8 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
- package/dist/frontend/lowering/expressions/union-fields.js +103 -13
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +74 -55
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/function-returns.js +37 -10
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/general-streams.js +5 -0
- package/dist/frontend/lowering/general-streams.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
- package/dist/frontend/lowering/generator-delegation.js +301 -118
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +27 -1
- package/dist/frontend/lowering/generic-functions.js +432 -18
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/global-function-values.d.ts +25 -0
- package/dist/frontend/lowering/global-function-values.js +193 -0
- package/dist/frontend/lowering/global-function-values.js.map +1 -0
- package/dist/frontend/lowering/global-values.d.ts +6 -4
- package/dist/frontend/lowering/global-values.js +24 -10
- package/dist/frontend/lowering/global-values.js.map +1 -1
- package/dist/frontend/lowering/host-global-values.d.ts +31 -0
- package/dist/frontend/lowering/host-global-values.js +121 -0
- package/dist/frontend/lowering/host-global-values.js.map +1 -0
- package/dist/frontend/lowering/host-globals.d.ts +74 -0
- package/dist/frontend/lowering/host-globals.js +344 -0
- package/dist/frontend/lowering/host-globals.js.map +1 -0
- package/dist/frontend/lowering/http2-constants.js +1 -1
- package/dist/frontend/lowering/iterator-adapters.js +46 -17
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
- package/dist/frontend/lowering/iterator-prototype.js +160 -0
- package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
- package/dist/frontend/lowering/key-order-witness.js +43 -22
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +1 -0
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +11 -3
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +30 -15
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
- package/dist/frontend/lowering/lower-async-iteration.js +15 -0
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.js +11 -1
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +25 -0
- package/dist/frontend/lowering/lower-calls.js +929 -227
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.test.js +59 -16
- package/dist/frontend/lowering/lower-calls.test.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +20 -0
- package/dist/frontend/lowering/lower-classes.js +468 -44
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -2
- package/dist/frontend/lowering/lower-event-emitter.js +253 -83
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +1 -1
- package/dist/frontend/lowering/lower-exprs.js +71 -20
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +25 -6
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +57 -10
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
- package/dist/frontend/lowering/lower-global-value.js +14 -5
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
- package/dist/frontend/lowering/lower-inspect.js +638 -64
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +48 -2
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +18 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.js +16 -6
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +303 -87
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +45 -0
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +14 -11
- package/dist/frontend/lowering/lower-stmts.js +270 -52
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +110 -27
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lower-url.js +6 -3
- package/dist/frontend/lowering/lower-url.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +227 -21
- package/dist/frontend/lowering/lowerer.js +651 -92
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +18 -0
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
- package/dist/frontend/lowering/lowering-facts.js +323 -0
- package/dist/frontend/lowering/lowering-facts.js.map +1 -0
- package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
- package/dist/frontend/lowering/lowering-facts.test.js +100 -0
- package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
- package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
- package/dist/frontend/lowering/nan-coded-reads.js +112 -9
- package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
- package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
- package/dist/frontend/lowering/optional-arguments.js +26 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/partial-assertions.d.ts +0 -3
- package/dist/frontend/lowering/partial-assertions.js +9 -15
- package/dist/frontend/lowering/partial-assertions.js.map +1 -1
- package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
- package/dist/frontend/lowering/primitive-throws.js +241 -0
- package/dist/frontend/lowering/primitive-throws.js.map +1 -0
- package/dist/frontend/lowering/primitive-wrappers.js +1 -0
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
- package/dist/frontend/lowering/record-inherited.d.ts +17 -1
- package/dist/frontend/lowering/record-inherited.js +16 -2
- package/dist/frontend/lowering/record-inherited.js.map +1 -1
- package/dist/frontend/lowering/record-links.d.ts +73 -0
- package/dist/frontend/lowering/record-links.js +797 -0
- package/dist/frontend/lowering/record-links.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
- package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
- package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
- package/dist/frontend/lowering/runtime-optional-report.js +300 -0
- package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +3 -1
- package/dist/frontend/lowering/static-typeof.js +6 -1
- package/dist/frontend/lowering/static-typeof.js.map +1 -1
- package/dist/frontend/lowering/strict-mode.d.ts +1 -5
- package/dist/frontend/lowering/strict-mode.js +4 -30
- package/dist/frontend/lowering/strict-mode.js.map +1 -1
- package/dist/frontend/lowering/structural-instances.d.ts +7 -0
- package/dist/frontend/lowering/structural-instances.js +23 -0
- package/dist/frontend/lowering/structural-instances.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +15 -1
- package/dist/frontend/lowering/surfaces.js +78 -10
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/union-retag.d.ts +13 -1
- package/dist/frontend/lowering/union-retag.js +55 -1
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +51 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.d.ts +8 -0
- package/dist/frontend/lowering/unit-journal.js +14 -0
- package/dist/frontend/lowering/unit-journal.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.test.js +36 -1
- package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
- package/dist/frontend/lowering/zlib-constants.js +3 -2
- package/dist/frontend/lowering/zlib-constants.js.map +1 -1
- package/dist/frontend/npm-static.js +78 -9
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm-static.test.js +95 -2
- package/dist/frontend/npm-static.test.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +5 -4
- package/dist/frontend/pipeline.js +94 -31
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +68 -11
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program.d.ts +62 -2
- package/dist/frontend/program.js +695 -422
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +37 -1
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/services-node.d.ts +7 -0
- package/dist/frontend/services-node.js +32 -1
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services-node.test.js +51 -0
- package/dist/frontend/services-node.test.js.map +1 -1
- package/dist/frontend/shape-inference/overlay.js +68 -2
- package/dist/frontend/shape-inference/overlay.js.map +1 -1
- package/dist/frontend/tier-analysis.d.ts +9 -0
- package/dist/frontend/tier-analysis.js +1 -0
- package/dist/frontend/tier-analysis.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +57 -3
- package/dist/frontend/tsc-codes.js +935 -150
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/tsc-codes.test.js +221 -12
- package/dist/frontend/tsc-codes.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +91 -9
- package/dist/frontend/type-mapper.js +622 -181
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +80 -15
- package/dist/index.js.map +1 -1
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +60 -0
- package/dist/index.test.js.map +1 -0
- package/dist/ir/builtin-effects.js +43 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +242 -16
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/callback-specialization.d.ts +3 -2
- package/dist/ir/callback-specialization.js +35 -25
- package/dist/ir/callback-specialization.js.map +1 -1
- package/dist/ir/capture-values.d.ts +8 -4
- package/dist/ir/capture-values.js +9 -6
- package/dist/ir/capture-values.js.map +1 -1
- package/dist/ir/char-unit-locals.d.ts +6 -2
- package/dist/ir/char-unit-locals.js +11 -2
- package/dist/ir/char-unit-locals.js.map +1 -1
- package/dist/ir/class-key-index.d.ts +18 -0
- package/dist/ir/class-key-index.js +29 -0
- package/dist/ir/class-key-index.js.map +1 -0
- package/dist/ir/class-key-index.test.d.ts +1 -0
- package/dist/ir/class-key-index.test.js +25 -0
- package/dist/ir/class-key-index.test.js.map +1 -0
- package/dist/ir/codec.generated.d.ts +1 -1
- package/dist/ir/codec.generated.js +724 -648
- package/dist/ir/codec.generated.js.map +1 -1
- package/dist/ir/constant-globals.d.ts +5 -2
- package/dist/ir/constant-globals.js +25 -27
- package/dist/ir/constant-globals.js.map +1 -1
- package/dist/ir/expression-inlining.d.ts +4 -2
- package/dist/ir/expression-inlining.js +8 -2
- package/dist/ir/expression-inlining.js.map +1 -1
- package/dist/ir/field-values.d.ts +5 -2
- package/dist/ir/field-values.js +32 -21
- package/dist/ir/field-values.js.map +1 -1
- package/dist/ir/fields.generated.d.ts +11 -2
- package/dist/ir/fields.generated.js +8 -0
- package/dist/ir/fields.generated.js.map +1 -1
- package/dist/ir/final-fields.js +1 -1
- package/dist/ir/final-fields.js.map +1 -1
- package/dist/ir/function-references.d.ts +5 -4
- package/dist/ir/function-references.js +7 -4
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +7 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/init-only-globals.d.ts +4 -2
- package/dist/ir/init-only-globals.js +17 -18
- package/dist/ir/init-only-globals.js.map +1 -1
- package/dist/ir/inline-array-views.js +1 -0
- package/dist/ir/inline-array-views.js.map +1 -1
- package/dist/ir/int32-slots.js +7 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/ir.d.ts +59 -4
- package/dist/ir/ir.js +7 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-groups.d.ts +51 -0
- package/dist/ir/js-groups.js +394 -0
- package/dist/ir/js-groups.js.map +1 -0
- package/dist/ir/js-groups.test.d.ts +1 -0
- package/dist/ir/js-groups.test.js +555 -0
- package/dist/ir/js-groups.test.js.map +1 -0
- package/dist/ir/js-ic.js +30 -5
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +27 -1
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/node-index.d.ts +23 -6
- package/dist/ir/node-index.js +126 -49
- package/dist/ir/node-index.js.map +1 -1
- package/dist/ir/numeric-call-specialization.d.ts +4 -2
- package/dist/ir/numeric-call-specialization.js +40 -26
- package/dist/ir/numeric-call-specialization.js.map +1 -1
- package/dist/ir/paired-while-loops.d.ts +4 -2
- package/dist/ir/paired-while-loops.js +8 -2
- package/dist/ir/paired-while-loops.js.map +1 -1
- package/dist/ir/parameter-versions.d.ts +13 -4
- package/dist/ir/parameter-versions.js +63 -42
- package/dist/ir/parameter-versions.js.map +1 -1
- package/dist/ir/property-bags.d.ts +4 -2
- package/dist/ir/property-bags.js +22 -17
- package/dist/ir/property-bags.js.map +1 -1
- package/dist/ir/row-pairs.d.ts +4 -2
- package/dist/ir/row-pairs.js +12 -11
- package/dist/ir/row-pairs.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +87 -12
- package/dist/ir/runtime-features.js +263 -160
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +109 -139
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/runtime-jam-loops.d.ts +35 -0
- package/dist/ir/runtime-jam-loops.js +604 -0
- package/dist/ir/runtime-jam-loops.js.map +1 -0
- package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
- package/dist/ir/runtime-jam-loops.test.js +565 -0
- package/dist/ir/runtime-jam-loops.test.js.map +1 -0
- package/dist/ir/saturating-loop-jams.d.ts +4 -2
- package/dist/ir/saturating-loop-jams.js +11 -10
- package/dist/ir/saturating-loop-jams.js.map +1 -1
- package/dist/ir/scalar-records.d.ts +5 -2
- package/dist/ir/scalar-records.js +12 -2
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/self-captures.d.ts +4 -2
- package/dist/ir/self-captures.js +32 -27
- package/dist/ir/self-captures.js.map +1 -1
- package/dist/ir/serialize.d.ts +6 -1
- package/dist/ir/serialize.js +87 -23
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.js +26 -0
- package/dist/ir/serialize.test.js.map +1 -1
- package/dist/ir/tiers.js +1 -0
- package/dist/ir/tiers.js.map +1 -1
- package/dist/ir/traverse.js +4 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/typed-argument-clones.d.ts +30 -0
- package/dist/ir/typed-argument-clones.js +789 -0
- package/dist/ir/typed-argument-clones.js.map +1 -0
- package/dist/ir/union-arm-loops.d.ts +3 -0
- package/dist/ir/union-arm-loops.js +373 -0
- package/dist/ir/union-arm-loops.js.map +1 -0
- package/dist/ir/union-arm-loops.test.d.ts +1 -0
- package/dist/ir/union-arm-loops.test.js +230 -0
- package/dist/ir/union-arm-loops.test.js.map +1 -0
- package/dist/ir/validate.js +88 -18
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/compiler-self-identity.d.ts +8 -2
- package/dist/library/compiler-self-identity.js +92 -18
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.js +150 -3
- package/dist/library/compiler-self-identity.test.js.map +1 -1
- package/dist/library/int-infer.d.ts +5 -0
- package/dist/library/int-infer.js +15 -3
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/ir-policy.js +1 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-cache.d.ts +4 -0
- package/dist/library/library-cache.js +2 -0
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +26 -0
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/prepare.js +99 -31
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cache.d.ts +7 -0
- package/dist/native/cache.js +47 -0
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +13 -1
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +1 -1
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +18 -3
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache-open.test.js +31 -5
- package/dist/native/executable-cache-open.test.js.map +1 -1
- package/dist/native/executable-cache.d.ts +6 -1
- package/dist/native/executable-cache.js +7 -1
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.d.ts +3 -0
- package/dist/native/prepare.js +43 -26
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +25 -3
- package/dist/native/prepare.test.js.map +1 -1
- package/dist/native/sanitizer.js +10 -1
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +7 -2
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/node-islands/boundary.d.ts +12 -0
- package/dist/node-islands/boundary.js +38 -6
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/boundary.test.d.ts +1 -0
- package/dist/node-islands/boundary.test.js +76 -0
- package/dist/node-islands/boundary.test.js.map +1 -0
- package/dist/node-islands/detect.d.ts +9 -0
- package/dist/node-islands/detect.js +110 -0
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +24 -0
- package/dist/node-islands/detect.test.js.map +1 -1
- package/dist/node-islands/graph-islands.d.ts +40 -0
- package/dist/node-islands/graph-islands.js +128 -0
- package/dist/node-islands/graph-islands.js.map +1 -0
- package/dist/node-islands/growth.d.ts +57 -0
- package/dist/node-islands/growth.js +205 -0
- package/dist/node-islands/growth.js.map +1 -0
- package/dist/node-islands/report.d.ts +12 -0
- package/dist/node-islands/report.js +28 -0
- package/dist/node-islands/report.js.map +1 -1
- package/dist/node-islands/report.test.js +2 -0
- package/dist/node-islands/report.test.js.map +1 -1
- package/dist/node-islands/rules.js +5 -0
- package/dist/node-islands/rules.js.map +1 -1
- package/dist/node-islands/scan.d.ts +11 -2
- package/dist/node-islands/scan.js +61 -9
- package/dist/node-islands/scan.js.map +1 -1
- package/dist/wasm/translate.js +11 -5
- package/dist/wasm/translate.js.map +1 -1
- package/dist/wasm/translate.test.js +35 -0
- package/dist/wasm/translate.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +184 -117
package/dist/frontend/program.js
CHANGED
|
@@ -57,7 +57,7 @@ import { cjsLexedExportsOfFile, cjsVisibleNames } from "./cjs-syntax.js";
|
|
|
57
57
|
import { ambientDtsPath, fallbackDtsPath, fallbackModulesNamedIn, isFallbackDtsPath, isNodeTypesPath, overridesDtsPath, tsgoPath, } from "./dts-paths.js";
|
|
58
58
|
import { builtinDefaultImportModule, canonicalBuiltinModule, npmBuiltinAliasOf, SUPPORTED_NODE_MODULES, unsupportedModuleFeatureOf, TEMPORAL_GLOBAL, } from "./builtin-modules.js";
|
|
59
59
|
import { clearWorkspacePackages, isRelativeSpecifier, isWorkspacePackageName, npmPackageNameOf, packageNameOfSpecifier, registerWorkspacePackage, workspacePackageOfPath, } from "./workspace-registry.js";
|
|
60
|
-
import { ADOPTED_OPTIONS, isJsSourceFileName,
|
|
60
|
+
import { ADOPTED_OPTIONS, isJsSourceFileName, jsOpinion, jsTscCodeTriage, } from "./tsc-codes.js";
|
|
61
61
|
import { trackedFileExists, trackedReadFile, trackedRealpath } from "./input-tracker.js";
|
|
62
62
|
import { earlyErrorDiagnostics7 } from "./early-errors.js";
|
|
63
63
|
import { forkTargetPaths } from "./fork-target.js";
|
|
@@ -1173,71 +1173,103 @@ function declBoundaryDroppedDiag(file) {
|
|
|
1173
1173
|
* preflight diagnostics. Preserve the caller's complete load shape when
|
|
1174
1174
|
* mutating it, including its owned services and disposal callback. */
|
|
1175
1175
|
export function checkPreflight(load) {
|
|
1176
|
-
const { diags, moduleOrder, startupCrash, inlineRequireCycleCalls, moduleEdges, dynamicImportRejections, } = preflight7(load);
|
|
1176
|
+
const { diags, moduleOrder, startupCrash, inlineRequireCycleCalls, moduleEdges, dynamicImportRejections, admittedOpinions, } = preflight7(load);
|
|
1177
1177
|
load.moduleOrder = moduleOrder;
|
|
1178
1178
|
load.startupCrash = startupCrash;
|
|
1179
1179
|
load.inlineRequireCycleCalls = inlineRequireCycleCalls;
|
|
1180
1180
|
load.moduleEdges = moduleEdges;
|
|
1181
1181
|
load.dynamicImportRejections = dynamicImportRejections;
|
|
1182
|
+
load.admittedOpinions = admittedOpinions;
|
|
1183
|
+
// Measurement aid: prints every opinion site this preflight admitted, so a
|
|
1184
|
+
// corpus run can show which rows carry evidence (SCRIPTC_DEBUG_ADMITTED=1).
|
|
1185
|
+
// Silent by default; no lowering reads the set.
|
|
1186
|
+
if (process.env["SCRIPTC_DEBUG_ADMITTED"] === "1")
|
|
1187
|
+
for (const site of admittedOpinions)
|
|
1188
|
+
process.stderr.write(`scriptc admitted TS${site.code} ${site.view} ${site.file}:${site.pos}-${site.end}\n`);
|
|
1182
1189
|
return diags;
|
|
1183
1190
|
}
|
|
1184
|
-
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
return true;
|
|
1219
|
-
if (JS_ANY_OPERATOR_CODES.has(d.code)) {
|
|
1220
|
-
const text = ts.flattenDiagnosticMessageText(d, "\n");
|
|
1221
|
-
// A primitive wrapper operand (`new Number(1) * 2`): the operator
|
|
1222
|
-
// converts it with ToPrimitive, as for any object.
|
|
1223
|
-
return text.includes("'any'") || /'(Number|String|Boolean)'/.test(text);
|
|
1224
|
-
}
|
|
1225
|
-
// An index write on a String wrapper (`new String("ab")[5] = "q"`): Node
|
|
1226
|
-
// adds the property past the end and ignores writes to the read-only
|
|
1227
|
-
// index properties (sloppy) or throws (strict), as the object does.
|
|
1228
|
-
if (d.code === 2542 && ts.flattenDiagnosticMessageText(d, "\n").includes("type 'String'"))
|
|
1229
|
-
return true;
|
|
1230
|
-
// The deprecated Buffer(...) call without `new`, which Node's Buffer
|
|
1231
|
-
// function accepts (containers/bytes.ts lowers it), and fs.ReadStream(...)
|
|
1232
|
-
// and fs.WriteStream(...), which construct their stream
|
|
1233
|
-
// (builtins/fs-streams.ts).
|
|
1234
|
-
if (d.code === 2348) {
|
|
1235
|
-
const text = ts.flattenDiagnosticMessageText(d, "\n");
|
|
1236
|
-
return (text.includes("'BufferConstructor'") ||
|
|
1237
|
-
text.includes("'typeof ReadStream'") ||
|
|
1238
|
-
text.includes("'typeof WriteStream'"));
|
|
1191
|
+
/** The module evaluation order and the graph facts derived with it, without
|
|
1192
|
+
* the diagnostics. `--npm-static`'s library fixpoint reloads the program
|
|
1193
|
+
* once per package it discovers and reads the order alone (to find the next
|
|
1194
|
+
* package); only the last program's diagnostics are ever reported, and its
|
|
1195
|
+
* checkPreflight completes this walk instead of repeating it. */
|
|
1196
|
+
export function checkModuleOrder(load) {
|
|
1197
|
+
registerWorkspaceEdges(load);
|
|
1198
|
+
fillPreflightFields(load, preflightStructure(load));
|
|
1199
|
+
}
|
|
1200
|
+
function fillPreflightFields(load, structure) {
|
|
1201
|
+
load.moduleOrder = structure.order;
|
|
1202
|
+
load.inlineRequireCycleCalls = structure.inlineRequireCycleCalls;
|
|
1203
|
+
load.moduleEdges = structure.moduleEdges;
|
|
1204
|
+
load.dynamicImportRejections = structure.dynamicImportRejections;
|
|
1205
|
+
}
|
|
1206
|
+
/** The innermost node whose token span contains [pos, end): the node an
|
|
1207
|
+
* opinion row's site guard inspects, and the one `island` rows ask about
|
|
1208
|
+
* (a diagnostic carries no node). */
|
|
1209
|
+
function diagnosticNode7(sf, pos, end) {
|
|
1210
|
+
let node = sf;
|
|
1211
|
+
// The lowering's nesting fence is 200 levels; a recovered AST is never
|
|
1212
|
+
// deeper than that on the path to one diagnostic.
|
|
1213
|
+
for (let depth = 0; depth < 200; depth++) {
|
|
1214
|
+
let next;
|
|
1215
|
+
ts.forEachChild(node, (child) => {
|
|
1216
|
+
if (ts.tokenStartOfNode(child) <= pos && end <= child.end) {
|
|
1217
|
+
next = child;
|
|
1218
|
+
return true;
|
|
1219
|
+
}
|
|
1220
|
+
return undefined;
|
|
1221
|
+
});
|
|
1222
|
+
if (next === undefined)
|
|
1223
|
+
break;
|
|
1224
|
+
node = next;
|
|
1239
1225
|
}
|
|
1240
|
-
return
|
|
1226
|
+
return node;
|
|
1227
|
+
}
|
|
1228
|
+
/** The JS_OPINIONS admission for one checker diagnostic (tsc-codes.ts), or
|
|
1229
|
+
* null when the diagnostic stays. Five conditions, in order:
|
|
1230
|
+
*
|
|
1231
|
+
* 1. the file is a JavaScript source (never .ts/.mts/.cts/.tsx/.d.ts);
|
|
1232
|
+
* 2. a row admits the code, and the file is unchecked JavaScript unless the
|
|
1233
|
+
* row is one a checked project has always seen (`checkedJs: "enforce"`);
|
|
1234
|
+
* 3. the diagnostic is a checker diagnostic, not a parser one (a syntactic
|
|
1235
|
+
* diagnostic leaves a recovered AST);
|
|
1236
|
+
* 4. the row's site guard accepts the diagnostic's node, if it has one;
|
|
1237
|
+
* 5. an `island` row does not apply in strict code (scriptc's own
|
|
1238
|
+
* isStrictCode, never tsc's module opinion).
|
|
1239
|
+
*
|
|
1240
|
+
* Admission says nothing about the LOWERING: the caller records the site
|
|
1241
|
+
* (AdmittedOpinion) so a view's lowering path can be gated on it. */
|
|
1242
|
+
function jsOpinionOf7(p, d, projectCheckJs, syntacticOf) {
|
|
1243
|
+
if (d.fileName === undefined || !isJsSourceFileName(d.fileName))
|
|
1244
|
+
return null;
|
|
1245
|
+
const opinion = jsOpinion(d.code);
|
|
1246
|
+
if (opinion === null)
|
|
1247
|
+
return null;
|
|
1248
|
+
const sf = p.getSourceFile(d.fileName);
|
|
1249
|
+
if (sf !== undefined &&
|
|
1250
|
+
opinion.checkedJs === "enforce" &&
|
|
1251
|
+
isCheckedJsSourceFile(sf, projectCheckJs))
|
|
1252
|
+
return null;
|
|
1253
|
+
const pos = d.pos;
|
|
1254
|
+
const end = d.end;
|
|
1255
|
+
const spanless = pos === undefined || end === undefined;
|
|
1256
|
+
// A diagnostic with no span, or one that names a file the program does
|
|
1257
|
+
// not carry, cannot be placed in the AST. A row with no node guard needs
|
|
1258
|
+
// no node, so the admission applies exactly as it always has; the caller
|
|
1259
|
+
// records nothing (there is no site a view could be gated on).
|
|
1260
|
+
const nodeFree = opinion.site === undefined && opinion.view !== "island";
|
|
1261
|
+
if (spanless || sf === undefined)
|
|
1262
|
+
return nodeFree ? opinion : null;
|
|
1263
|
+
if (syntacticOf(sf).some((s) => s.code === d.code && s.pos === pos && s.end === end))
|
|
1264
|
+
return null;
|
|
1265
|
+
if (nodeFree)
|
|
1266
|
+
return opinion;
|
|
1267
|
+
const node = diagnosticNode7(sf, pos, end);
|
|
1268
|
+
if (opinion.site !== undefined && !opinion.site(node, d))
|
|
1269
|
+
return null;
|
|
1270
|
+
if (opinion.view === "island" && isStrictCode(node))
|
|
1271
|
+
return null;
|
|
1272
|
+
return opinion;
|
|
1241
1273
|
}
|
|
1242
1274
|
/** The specifier of a `require("...")` call: the callee is the bare
|
|
1243
1275
|
* identifier `require` and the single argument a string literal. The one
|
|
@@ -2483,8 +2515,18 @@ function jsUndeclaredWriteDiags(program, files) {
|
|
|
2483
2515
|
if (ts.isIdentifier(node) &&
|
|
2484
2516
|
node.text !== "" &&
|
|
2485
2517
|
isJsWriteTarget7(node) &&
|
|
2486
|
-
undeclaredJsName7(checker, node))
|
|
2487
|
-
|
|
2518
|
+
undeclaredJsName7(checker, node)) {
|
|
2519
|
+
const sloppyWrite = !isStrictCode(node);
|
|
2520
|
+
const diag = unsupportedDiag("SC1091", { file: sf.fileName, start: node.getStart(sf), end: node.end }, `writing the undeclared name '${node.text}' in a JavaScript source`);
|
|
2521
|
+
// A sloppy-mode write creates the global at run time, a sloppy-only
|
|
2522
|
+
// semantic the native tier does not implement: the reason lets an
|
|
2523
|
+
// automatic island policy put this module in a Node island instead
|
|
2524
|
+
// of refusing the build. A strict-mode write throws ReferenceError,
|
|
2525
|
+
// which is an ordinary lowering gap and stays a plain refusal.
|
|
2526
|
+
if (sloppyWrite)
|
|
2527
|
+
diag.reason = "implicit-global-write";
|
|
2528
|
+
diags.push(diag);
|
|
2529
|
+
}
|
|
2488
2530
|
ts.forEachChild(node, (child) => {
|
|
2489
2531
|
stack.push(child);
|
|
2490
2532
|
return undefined;
|
|
@@ -2785,6 +2827,36 @@ function isCjsJsFile7(sf, program) {
|
|
|
2785
2827
|
export function isCjsJsFile(sf, program) {
|
|
2786
2828
|
return isCjsJsFile7(sf, program);
|
|
2787
2829
|
}
|
|
2830
|
+
function hasUseStrictDirective(statements) {
|
|
2831
|
+
for (const statement of statements) {
|
|
2832
|
+
if (!ts.isExpressionStatement(statement) || !ts.isStringLiteral(statement.expression))
|
|
2833
|
+
return false;
|
|
2834
|
+
if (statement.expression.text === "use strict")
|
|
2835
|
+
return true;
|
|
2836
|
+
}
|
|
2837
|
+
return false;
|
|
2838
|
+
}
|
|
2839
|
+
/** Whether `node` runs in strict mode code: inside a class body, a function
|
|
2840
|
+
* with a "use strict" directive, a module, or a script that starts with
|
|
2841
|
+
* "use strict". CommonJS JavaScript is sloppy otherwise; the sloppy-only
|
|
2842
|
+
* semantics (implicit globals, `with`, direct eval, Annex B) need a Node
|
|
2843
|
+
* island. */
|
|
2844
|
+
export function isStrictCode(node) {
|
|
2845
|
+
for (let parent = node.parent; parent; parent = parent.parent) {
|
|
2846
|
+
if (ts.isClassDeclaration(parent) || ts.isClassExpression(parent))
|
|
2847
|
+
return true;
|
|
2848
|
+
if (ts.isFunctionLike(parent) &&
|
|
2849
|
+
parent.body &&
|
|
2850
|
+
ts.isBlock(parent.body) &&
|
|
2851
|
+
hasUseStrictDirective(parent.body.statements.nodes))
|
|
2852
|
+
return true;
|
|
2853
|
+
if (ts.isSourceFile(parent)) {
|
|
2854
|
+
return (hasUseStrictDirective(parent.statements.nodes) ||
|
|
2855
|
+
(!isCjsJsFile7(parent) && (isNodeEsmFile7(parent) || ts.isExternalModule(parent))));
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
return false;
|
|
2859
|
+
}
|
|
2788
2860
|
/** The self-import TDZ fences: for `import { x } from "<self>"` (default
|
|
2789
2861
|
* and namespace forms included), any TOP-LEVEL reference lexically above
|
|
2790
2862
|
* the aliased declaration observes Node's temporal dead zone — the direct
|
|
@@ -4892,13 +4964,18 @@ function typeOnlyNamespace7(decl) {
|
|
|
4892
4964
|
* program, or null (unresolvable / outside the program). Exported (as
|
|
4893
4965
|
* resolveImport) for the lowering: CommonJS require statements lower to
|
|
4894
4966
|
* guarded %init calls of exactly the module preflight resolved here. */
|
|
4895
|
-
function resolveImport7(program, from, specifier, resolutionKind = "import"
|
|
4967
|
+
function resolveImport7(program, from, specifier, resolutionKind = "import",
|
|
4968
|
+
/** False for the graph passes that over-approximate edges (see
|
|
4969
|
+
* `resolveRuntimeEdge`): they resolve specifiers Node may never load, so
|
|
4970
|
+
* a miss there is no evidence about the package's entry and must not
|
|
4971
|
+
* classify it. The walks that model real loads pass the default. */
|
|
4972
|
+
reportMiss = true) {
|
|
4896
4973
|
const resolved = resolveProjectModule(from.fileName, specifier);
|
|
4897
4974
|
if (resolved !== null)
|
|
4898
4975
|
return program.getSourceFile(resolved) ?? null;
|
|
4899
4976
|
const npm = resolveNpmImport7(from.fileName, specifier, resolutionKind);
|
|
4900
4977
|
return npm && isNpmStaticPackage(npm.packageName)
|
|
4901
|
-
? npmStaticProgramDep(program, npm.packageName, npm.typesFile)
|
|
4978
|
+
? npmStaticProgramDep(program, npm.packageName, npm.typesFile, reportMiss)
|
|
4902
4979
|
: null;
|
|
4903
4980
|
}
|
|
4904
4981
|
function resolveNpmImport7(fromFileName, specifier, resolutionKind = "import") {
|
|
@@ -4968,14 +5045,16 @@ function npmStaticProgramFile(program, resolvedFile) {
|
|
|
4968
5045
|
* entry maps to, or null with the package marked an offender (resolution
|
|
4969
5046
|
* still answering declarations, or the file missing from the type-checked
|
|
4970
5047
|
* program — a path-identity mismatch between the two resolvers). */
|
|
4971
|
-
function npmStaticProgramDep(program, packageName, resolvedFile) {
|
|
5048
|
+
function npmStaticProgramDep(program, packageName, resolvedFile, reportMiss = true) {
|
|
4972
5049
|
if (!isJsSourceFileName(resolvedFile)) {
|
|
4973
|
-
|
|
5050
|
+
if (reportMiss)
|
|
5051
|
+
reportNpmStaticOffender(packageName, `its import resolves to '${resolvedFile}', not to runtime JavaScript`);
|
|
4974
5052
|
return null;
|
|
4975
5053
|
}
|
|
4976
5054
|
const dep = npmStaticProgramFile(program, resolvedFile);
|
|
4977
5055
|
if (dep === null) {
|
|
4978
|
-
|
|
5056
|
+
if (reportMiss)
|
|
5057
|
+
reportNpmStaticOffender(packageName, `its entry '${resolvedFile}' did not join the type-checked program`);
|
|
4979
5058
|
return null;
|
|
4980
5059
|
}
|
|
4981
5060
|
return dep;
|
|
@@ -5030,27 +5109,42 @@ function declarationHasRuntimeFile(declaration) {
|
|
|
5030
5109
|
return trackedFileExists(name.slice(0, -declared.length) + runtime);
|
|
5031
5110
|
return false;
|
|
5032
5111
|
}
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5112
|
+
/** Whether two resolutions name the same module file. Their spellings differ
|
|
5113
|
+
* routinely — a tsconfig `paths` answer keeps the project's spelling where
|
|
5114
|
+
* the npm resolver answers realpath'd — so the real paths decide. */
|
|
5115
|
+
function sameResolvedFile(a, b) {
|
|
5116
|
+
const normalize = (path) => path.replaceAll("\\", "/");
|
|
5117
|
+
if (normalize(a) === normalize(b))
|
|
5118
|
+
return true;
|
|
5119
|
+
return normalize(trackedRealpath(a) ?? a) === normalize(trackedRealpath(b) ?? b);
|
|
5120
|
+
}
|
|
5121
|
+
/** A program file TypeScript's checker pulled in from a package the build
|
|
5122
|
+
* does not compile — unselected node_modules JavaScript, or an unselected
|
|
5123
|
+
* workspace package's shipped JavaScript at a realpath outside node_modules
|
|
5124
|
+
* (the symlinked-install shape): Node never loads it as program source. */
|
|
5125
|
+
function unselectedPackageJsFilePredicate(entryFileName) {
|
|
5126
|
+
const entryPackageFile = entryPackageFilePredicate(entryFileName);
|
|
5127
|
+
return (file) => isJsSourceFileName(file) &&
|
|
5128
|
+
!entryPackageFile(file) &&
|
|
5129
|
+
npmStaticPackageOfPath(file) === null &&
|
|
5130
|
+
(isNodeModulesPath(file) || workspacePackageOfPath(file) !== null);
|
|
5131
|
+
}
|
|
5132
|
+
/** Workspace-linked packages register before the tsc gate. Their files live
|
|
5133
|
+
* at realpaths OUTSIDE node_modules (the monorepo-tool symlink shape), so
|
|
5134
|
+
* nothing path-shaped marks them as npm surface — yet their shipped JS
|
|
5135
|
+
* follows the same foreign-tsconfig rules as node_modules JS. The lazy
|
|
5136
|
+
* registration inside the import-fence walk registers them too, but too late
|
|
5137
|
+
* for the gate, so one pass over the program's import edges registers them up
|
|
5138
|
+
* front: every bare specifier any program file loads — import/export
|
|
5139
|
+
* declarations, dynamic import("literal") (tsgo chases those into the program
|
|
5140
|
+
* too; a CLI reaches its workspace sibling exactly that way),
|
|
5141
|
+
* require("literal") — resolved with the own resolver, workspace answers
|
|
5142
|
+
* recorded. Runs once per load, ahead of the gate and the walk. */
|
|
5143
|
+
function registerWorkspaceEdges(load) {
|
|
5144
|
+
if (load.workspaceProbed === true)
|
|
5145
|
+
return;
|
|
5146
|
+
load.workspaceProbed = true;
|
|
5147
|
+
const { program } = load;
|
|
5054
5148
|
{
|
|
5055
5149
|
const supportedBuiltins = new Set(SUPPORTED_NODE_MODULES);
|
|
5056
5150
|
const probed = new Set();
|
|
@@ -5076,317 +5170,126 @@ function preflight7(load) {
|
|
|
5076
5170
|
probe(sf.fileName, specifier);
|
|
5077
5171
|
}
|
|
5078
5172
|
}
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5173
|
+
}
|
|
5174
|
+
function preflightStructure(load) {
|
|
5175
|
+
if (load.preflightStructure === undefined)
|
|
5176
|
+
load.preflightStructure = preflightStructure7(load);
|
|
5177
|
+
return load.preflightStructure;
|
|
5178
|
+
}
|
|
5179
|
+
function preflightStructure7(load) {
|
|
5180
|
+
const { program, entry } = load;
|
|
5181
|
+
// The walk's own diagnostics. The config diagnostics and the tsc gate are
|
|
5182
|
+
// preflightDiagnostics7's, which reports them ahead of these.
|
|
5183
|
+
const diags = [];
|
|
5184
|
+
const unselectedPackageJsFile = unselectedPackageJsFilePredicate(entry.fileName);
|
|
5185
|
+
// An explicit entry can itself live in an installed package. Its own
|
|
5186
|
+
// source files are program code, including relative barrels and sibling
|
|
5187
|
+
// modules; their location must not erase the module graph.
|
|
5188
|
+
// Match the full installed directory, not just the package name, and
|
|
5189
|
+
// exclude nested installations so dependencies keep their npm policy.
|
|
5190
|
+
const entryPackageFile = entryPackageFilePredicate(entry.fileName);
|
|
5191
|
+
// Preflight and lowering share this CheckerFacade. Claim executable
|
|
5192
|
+
// source files after workspace discovery and the tsc gate but before
|
|
5193
|
+
// structural preflight checker queries, so a miss cannot trigger the old
|
|
5194
|
+
// whole-file sweep (and eagerly fetch every dead body's answers). The
|
|
5195
|
+
// structure wave includes declaration headers and top-level code;
|
|
5196
|
+
// reachable bodies are added by lowering's worklists.
|
|
5197
|
+
const ambient = ambientDtsPath();
|
|
5198
|
+
const programFiles = program
|
|
5199
|
+
.getImplementationSourceFiles()
|
|
5200
|
+
.filter((sf) => sf.fileName !== ambient &&
|
|
5201
|
+
!sf.isDeclarationFile &&
|
|
5202
|
+
!sf.fileName.endsWith(".json") &&
|
|
5203
|
+
(!isNodeModulesPath(sf.fileName) ||
|
|
5204
|
+
entryPackageFile(sf.fileName) ||
|
|
5205
|
+
npmStaticPackageOfPath(sf.fileName) !== null) &&
|
|
5206
|
+
!unselectedPackageJsFile(sf.fileName));
|
|
5207
|
+
// Files reached only through `import type` / `export type … from` are
|
|
5208
|
+
// checker input, never program modules: Node does not load them, so
|
|
5209
|
+
// their imports and syntax must not fence the program.
|
|
5210
|
+
//
|
|
5211
|
+
// Reachability over-approximates: `callReferencesOf` and the reexport
|
|
5212
|
+
// planner count EVERY call with a leading string literal as a loading
|
|
5213
|
+
// edge, so a bare specifier that merely names a package — a model id
|
|
5214
|
+
// passed to a catalog helper, a settings key passed to `markModified` —
|
|
5215
|
+
// reaches npm resolution here. Whether this walk runs at all depends on
|
|
5216
|
+
// the program it is handed (it early-returns unless an erased reference
|
|
5217
|
+
// resolves, and the island rounds change the program), so classifying a
|
|
5218
|
+
// miss from it made package selection depend on program composition: the
|
|
5219
|
+
// same build could refuse a static package's entry as "did not join the
|
|
5220
|
+
// type-checked program" or compile it, run to run. Report nothing from
|
|
5221
|
+
// these edges; the walks that model real loads (import/export
|
|
5222
|
+
// declarations and `require()`/`import()` calls) own the offender
|
|
5223
|
+
// classification.
|
|
5224
|
+
const resolveRuntimeEdge = (sf, spec, resolutionKind) => resolveImport7(program, sf, spec, resolutionKind, false) ??
|
|
5225
|
+
npmStaticDepSf7(program, sf, spec, resolutionKind);
|
|
5226
|
+
const typeOnlyFiles = typeOnlyReachedFiles(program, entry, programFiles, () => [
|
|
5227
|
+
...forkTargetPaths(program, program.getImplementationSourceFiles()),
|
|
5228
|
+
...workerTargetPaths(program, program.getImplementationSourceFiles()),
|
|
5229
|
+
], resolveRuntimeEdge);
|
|
5230
|
+
const runtimeFiles = typeOnlyFiles.size === 0 ? programFiles : programFiles.filter((sf) => !typeOnlyFiles.has(sf));
|
|
5231
|
+
const userFiles = npmStaticActive()
|
|
5232
|
+
? planNpmStaticReexports(program, entry, runtimeFiles, [
|
|
5233
|
+
...createRequireProgramRoots7(program),
|
|
5234
|
+
...forkTargetPaths(program, program.getImplementationSourceFiles()),
|
|
5235
|
+
...workerTargetPaths(program, program.getImplementationSourceFiles()),
|
|
5236
|
+
], resolveRuntimeEdge)
|
|
5237
|
+
: runtimeFiles;
|
|
5238
|
+
program.getTypeChecker().prefetchSourceFileStructures(userFiles);
|
|
5239
|
+
// Unselected node_modules JS is not native program source even when
|
|
5240
|
+
// maxNodeModuleJsDepth pulled it into the checker (nodeModulesJsSuppressed).
|
|
5241
|
+
// Node stops at the nearest package.json even when it is malformed, and
|
|
5242
|
+
// an explicit CommonJS scope (or .cjs/.cts extension) disables ambiguous-
|
|
5243
|
+
// file syntax detection entirely. TypeScript's bundler checker models
|
|
5244
|
+
// neither loader rule, so restore them before any module-edge analysis:
|
|
5245
|
+
// one malformed-scope diagnostic per package file, and one pointed syntax
|
|
5246
|
+
// diagnostic per CommonJS source file.
|
|
5247
|
+
const invalidPackageConfigs = new Set();
|
|
5248
|
+
for (const sf of userFiles) {
|
|
5249
|
+
const invalidConfig = nearestInvalidPackageJsonPath(sf.fileName);
|
|
5250
|
+
if (invalidConfig !== null) {
|
|
5251
|
+
if (!invalidPackageConfigs.has(invalidConfig)) {
|
|
5252
|
+
invalidPackageConfigs.add(invalidConfig);
|
|
5253
|
+
diags.push(invalidPackageConfigDiag(invalidConfig, { file: sf.fileName, start: 0, end: 0 }));
|
|
5254
|
+
}
|
|
5255
|
+
continue;
|
|
5091
5256
|
}
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
if (canonicalBuiltinModule(stmt.moduleSpecifier.text) === null)
|
|
5119
|
-
continue;
|
|
5120
|
-
const bindings = stmt.importClause?.namedBindings;
|
|
5121
|
-
if (bindings && ts.isNamespaceImport(bindings))
|
|
5122
|
-
names.add(bindings.name.text);
|
|
5257
|
+
if (!isNodeEsmFile7(sf, program)) {
|
|
5258
|
+
const marker = nodeEsmSyntaxMarker7(sf);
|
|
5259
|
+
if (marker !== null)
|
|
5260
|
+
diags.push(commonJsModuleSyntaxDiag(locOf7(marker)));
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
const ambientModules = new Set(SUPPORTED_NODE_MODULES);
|
|
5264
|
+
// Ambient `declare module "name"` declarations anywhere in the program —
|
|
5265
|
+
// exact names and `*` patterns — so the import fence can say "type
|
|
5266
|
+
// surface only, no runtime module" instead of the generic package story.
|
|
5267
|
+
// Computed lazily: the scan only runs when a bare-import fence is about
|
|
5268
|
+
// to fire.
|
|
5269
|
+
let ambientModuleDecls = null;
|
|
5270
|
+
const ambientDeclared = (spec) => {
|
|
5271
|
+
if (ambientModuleDecls === null) {
|
|
5272
|
+
ambientModuleDecls = { names: new Set(), patterns: [] };
|
|
5273
|
+
for (const f of program.getSourceFiles()) {
|
|
5274
|
+
for (const s of f.statements.nodes) {
|
|
5275
|
+
if (!ts.isModuleDeclaration(s) || !ts.isStringLiteral(s.name))
|
|
5276
|
+
continue;
|
|
5277
|
+
const name = s.name.text;
|
|
5278
|
+
if (name.includes("*"))
|
|
5279
|
+
ambientModuleDecls.patterns.push(name);
|
|
5280
|
+
else
|
|
5281
|
+
ambientModuleDecls.names.add(name);
|
|
5282
|
+
}
|
|
5123
5283
|
}
|
|
5124
5284
|
}
|
|
5125
|
-
if (names.
|
|
5126
|
-
return false;
|
|
5127
|
-
const sf = p.getSourceFile(d.fileName);
|
|
5128
|
-
return sf !== undefined && names.has(sf.text.slice(d.pos, d.end));
|
|
5129
|
-
};
|
|
5130
|
-
const npmStaticFileSuppressed = (d) => d.fileName !== undefined && npmStaticPackageOfPath(d.fileName) !== null;
|
|
5131
|
-
const unselectedPackageJsFile = (file) => isJsSourceFileName(file) &&
|
|
5132
|
-
!entryPackageFile(file) &&
|
|
5133
|
-
npmStaticPackageOfPath(file) === null &&
|
|
5134
|
-
(isNodeModulesPath(file) || workspacePackageOfPath(file) !== null);
|
|
5135
|
-
const nodeModulesJsSuppressed = (d) => d.fileName !== undefined && unselectedPackageJsFile(d.fileName);
|
|
5136
|
-
/* JSDoc TYPE positions in JS files are documentation Node never reads:
|
|
5137
|
-
* a name-resolution failure THERE (2304/2552 — the pattern's utilities.js
|
|
5138
|
-
* spells a mapped type over a @template name it never declared) types
|
|
5139
|
-
* as the error-any and the per-site fences apply, same stance as the
|
|
5140
|
-
* strictness families above. A 2300 duplicate-identifier PAIR formed by
|
|
5141
|
-
* a @typedef and a same-named class/function is the same story — the
|
|
5142
|
-
* typedef half sits inside the comment, and the code half is suppressed
|
|
5143
|
-
* exactly when its partner (same file, same name) was comment-side, so
|
|
5144
|
-
* a REAL duplicate declaration (both halves in code — Node's own
|
|
5145
|
-
* SyntaxError) keeps tsc's voice. */
|
|
5146
|
-
const insideBlockComment = (text, pos) => {
|
|
5147
|
-
const open = text.lastIndexOf("/*", pos);
|
|
5148
|
-
if (open < 0)
|
|
5149
|
-
return false;
|
|
5150
|
-
const close = text.indexOf("*/", open + 2);
|
|
5151
|
-
return close === -1 || close >= pos;
|
|
5152
|
-
};
|
|
5153
|
-
const jsdocTypeSuppressed = (p, d, commentDup) => {
|
|
5154
|
-
if (d.fileName === undefined || !isJsSourceFileName(d.fileName))
|
|
5155
|
-
return false;
|
|
5156
|
-
if (d.code !== 2304 && d.code !== 2552 && d.code !== 2300 && d.code !== 1003)
|
|
5157
|
-
return false;
|
|
5158
|
-
if (d.pos === undefined)
|
|
5159
|
-
return false;
|
|
5160
|
-
const sf = p.getSourceFile(d.fileName);
|
|
5161
|
-
if (!sf)
|
|
5162
|
-
return false;
|
|
5163
|
-
if (insideBlockComment(sf.text, d.pos))
|
|
5285
|
+
if (ambientModuleDecls.names.has(spec))
|
|
5164
5286
|
return true;
|
|
5165
|
-
return
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
* ? window : …`) are code Node never runs. A name the file feature-tests
|
|
5172
|
-
* this way is therefore not a type error in JavaScript; a reached use
|
|
5173
|
-
* still meets the lowering's located refusal. TypeScript files keep the
|
|
5174
|
-
* error and its hint. */
|
|
5175
|
-
const typeofTestedNameSuppressed = (p, d) => {
|
|
5176
|
-
if (d.code !== 2304 && d.code !== 2552 && d.code !== 2584)
|
|
5177
|
-
return false;
|
|
5178
|
-
if (d.fileName === undefined || !isJsSourceFileName(d.fileName))
|
|
5179
|
-
return false;
|
|
5180
|
-
if (d.pos === undefined || d.end === undefined)
|
|
5181
|
-
return false;
|
|
5182
|
-
const sf = p.getSourceFile(d.fileName);
|
|
5183
|
-
if (!sf)
|
|
5184
|
-
return false;
|
|
5185
|
-
const name = sf.text.slice(d.pos, d.end);
|
|
5186
|
-
if (!/^[A-Za-z_$][\w$]*$/.test(name))
|
|
5187
|
-
return false;
|
|
5188
|
-
return new RegExp(`\\btypeof\\s*\\(?\\s*${name.replace(/\$/g, "\\$")}(?![\\w$])`).test(sf.text);
|
|
5189
|
-
};
|
|
5190
|
-
// A `return` at the top level of a CommonJS module (TS1108): Node runs
|
|
5191
|
-
// the module as a function body, so the return ends the module's
|
|
5192
|
-
// evaluation. ES modules and TypeScript keep the error.
|
|
5193
|
-
const cjsTopLevelReturnSuppressed = (p, d) => {
|
|
5194
|
-
if (d.code !== 1108 || d.fileName === undefined || !isJsSourceFileName(d.fileName))
|
|
5195
|
-
return false;
|
|
5196
|
-
const sf = p.getSourceFile(d.fileName);
|
|
5197
|
-
return sf !== undefined && isCjsJsFile7(sf, p);
|
|
5198
|
-
};
|
|
5199
|
-
const workspaceImplicitAnySuppressed = (p, d) => {
|
|
5200
|
-
if (d.code !== 7016 || d.fileName === undefined || d.pos === undefined || d.end === undefined)
|
|
5201
|
-
return false;
|
|
5202
|
-
const sf = p.getSourceFile(d.fileName);
|
|
5203
|
-
if (!sf)
|
|
5204
|
-
return false;
|
|
5205
|
-
const spec = sf.text.slice(d.pos, d.end).replace(/^['"]|['"]$/g, "");
|
|
5206
|
-
const prefix = spec.startsWith("@")
|
|
5207
|
-
? spec.split("/").slice(0, 2).join("/")
|
|
5208
|
-
: spec.split("/")[0];
|
|
5209
|
-
return isWorkspacePackageName(prefix);
|
|
5210
|
-
};
|
|
5211
|
-
// A JavaScript file that TypeScript checks keeps the type errors that
|
|
5212
|
-
// protect its JSDoc types: a value of another type reaching a typed slot,
|
|
5213
|
-
// a call with the wrong arity, and a subclass member that does not
|
|
5214
|
-
// match its base.
|
|
5215
|
-
const projectCheckJs = load.typeWorld?.projectCheckJs ?? false;
|
|
5216
|
-
const enforcedInCheckedJs = (p, d) => {
|
|
5217
|
-
if (!CHECKED_JS_ENFORCED_CODES.has(d.code) || d.fileName === undefined)
|
|
5218
|
-
return false;
|
|
5219
|
-
const sf = p.getSourceFile(d.fileName);
|
|
5220
|
-
return sf !== undefined && isCheckedJsSourceFile(sf, projectCheckJs);
|
|
5221
|
-
};
|
|
5222
|
-
// keptErrors drops every diagnostic of these files: the gate does not ask
|
|
5223
|
-
// the checker for them.
|
|
5224
|
-
const diagnosticsKept = (fileName) => npmStaticPackageOfPath(fileName) === null &&
|
|
5225
|
-
!unselectedPackageJsFile(fileName) &&
|
|
5226
|
-
!isPackageShimFile(fileName);
|
|
5227
|
-
const errorsOf = (p) => keptErrors(p, ts.getPreEmitDiagnostics(p, diagnosticsKept));
|
|
5228
|
-
const keptErrors = (p, all) => {
|
|
5229
|
-
// First pass: every comment-side 2300's (file, name) — the partners
|
|
5230
|
-
// the second pass forgives.
|
|
5231
|
-
const commentDup = new Set();
|
|
5232
|
-
for (const d of all) {
|
|
5233
|
-
if (d.code !== 2300 || d.fileName === undefined || d.pos === undefined || d.end === undefined)
|
|
5234
|
-
continue;
|
|
5235
|
-
if (!isJsSourceFileName(d.fileName))
|
|
5236
|
-
continue;
|
|
5237
|
-
const sf = p.getSourceFile(d.fileName);
|
|
5238
|
-
if (sf && insideBlockComment(sf.text, d.pos))
|
|
5239
|
-
commentDup.add(`${d.fileName}:${sf.text.slice(d.pos, d.end)}`);
|
|
5240
|
-
}
|
|
5241
|
-
return all.filter((d) => d.category === ts.DiagnosticCategory.Error &&
|
|
5242
|
-
(!suppressedJsStrictness7(d) || enforcedInCheckedJs(p, d)) &&
|
|
5243
|
-
!npmStaticFileSuppressed(d) &&
|
|
5244
|
-
!nodeModulesJsSuppressed(d) &&
|
|
5245
|
-
(d.fileName === undefined || !isPackageShimFile(d.fileName)) &&
|
|
5246
|
-
!namespaceCalleeSuppressed(p, d) &&
|
|
5247
|
-
!inferredJsDiagnosticSuppressed(p, d) &&
|
|
5248
|
-
!isNpmStaticSubclassArgument(p, d) &&
|
|
5249
|
-
!workspaceImplicitAnySuppressed(p, d) &&
|
|
5250
|
-
!typeofTestedNameSuppressed(p, d) &&
|
|
5251
|
-
!cjsTopLevelReturnSuppressed(p, d) &&
|
|
5252
|
-
!jsdocTypeSuppressed(p, d, commentDup));
|
|
5253
|
-
};
|
|
5254
|
-
// The tsc gate, with a second chance: the LOWERING world's checker
|
|
5255
|
-
// includes the divergence overrides (JSON.parse(): unknown, the Promise
|
|
5256
|
-
// executor shape, ...), which are TIGHTER than the standard lib — a
|
|
5257
|
-
// project that typechecks clean under its own tsc can still error here
|
|
5258
|
-
// (any-typed JSON.parse results, most commonly). Those errors are OURS,
|
|
5259
|
-
// not the project's, so they must not fail preflight: when the lowering
|
|
5260
|
-
// world has errors, the PROJECT world (same program without the override
|
|
5261
|
-
// declarations) is built and consulted. Clean there → preflight passes
|
|
5262
|
-
// and the override-affected sites meet the lowerer's honest fences
|
|
5263
|
-
// instead (the SC1100 checked-cast family). Dirty there → the project-
|
|
5264
|
-
// world errors are the ones reported: they are reproducible with the
|
|
5265
|
-
// project's own tsc, which is what "fix type errors first" asks for.
|
|
5266
|
-
// With JSX sources, the program over the original text answers the tsc
|
|
5267
|
-
// gate; its positions move into the rewritten text the program holds.
|
|
5268
|
-
// Errors only the rewritten text has come from the calls the JSX lowers
|
|
5269
|
-
// to (a factory whose signature does not accept them).
|
|
5270
|
-
const tscWorld = load.tscWorld;
|
|
5271
|
-
const tscErrors = tscWorld === undefined ? errorsOf(program) : keptErrors(tscWorld.program, tscWorld.diagnostics);
|
|
5272
|
-
if (tscErrors.length > 0) {
|
|
5273
|
-
const world = tscWorld === undefined || tscWorld.declWorldFallback === true
|
|
5274
|
-
? load.projectWorld()
|
|
5275
|
-
: (tscWorld.projectWorld ?? tscWorld.program);
|
|
5276
|
-
for (const d of errorsOf(world)) {
|
|
5277
|
-
const diag = toPassthrough(d);
|
|
5278
|
-
const lowered = tscWorld === undefined ? undefined : load.jsxSources?.get(diag.loc.file);
|
|
5279
|
-
if (lowered !== undefined) {
|
|
5280
|
-
diag.loc = {
|
|
5281
|
-
...diag.loc,
|
|
5282
|
-
start: lowered.rewrittenPosition(diag.loc.start, false),
|
|
5283
|
-
end: lowered.rewrittenPosition(diag.loc.end, true),
|
|
5284
|
-
};
|
|
5285
|
-
}
|
|
5286
|
-
diags.push(diag);
|
|
5287
|
-
}
|
|
5288
|
-
}
|
|
5289
|
-
else if (load.jsxSources !== undefined) {
|
|
5290
|
-
for (const file of load.jsxSources.keys()) {
|
|
5291
|
-
const sf = program.getSourceFile(file);
|
|
5292
|
-
if (sf === undefined)
|
|
5293
|
-
continue;
|
|
5294
|
-
const own = [...program.getSyntacticDiagnostics(sf), ...program.getSemanticDiagnostics(sf)];
|
|
5295
|
-
for (const d of keptErrors(program, own)) {
|
|
5296
|
-
const diag = toPassthrough(d);
|
|
5297
|
-
diag.message = `${diag.message} (in the call this JSX lowers to)`;
|
|
5298
|
-
diags.push(diag);
|
|
5299
|
-
}
|
|
5300
|
-
}
|
|
5301
|
-
}
|
|
5302
|
-
// Preflight and lowering share this CheckerFacade. Claim executable
|
|
5303
|
-
// source files after workspace discovery and the tsc gate but before
|
|
5304
|
-
// structural preflight checker queries, so a miss cannot trigger the old
|
|
5305
|
-
// whole-file sweep (and eagerly fetch every dead body's answers). The
|
|
5306
|
-
// structure wave includes declaration headers and top-level code;
|
|
5307
|
-
// reachable bodies are added by lowering's worklists.
|
|
5308
|
-
const ambient = ambientDtsPath();
|
|
5309
|
-
const programFiles = program
|
|
5310
|
-
.getImplementationSourceFiles()
|
|
5311
|
-
.filter((sf) => sf.fileName !== ambient &&
|
|
5312
|
-
!sf.isDeclarationFile &&
|
|
5313
|
-
!sf.fileName.endsWith(".json") &&
|
|
5314
|
-
(!isNodeModulesPath(sf.fileName) ||
|
|
5315
|
-
entryPackageFile(sf.fileName) ||
|
|
5316
|
-
npmStaticPackageOfPath(sf.fileName) !== null) &&
|
|
5317
|
-
!unselectedPackageJsFile(sf.fileName));
|
|
5318
|
-
// Files reached only through `import type` / `export type … from` are
|
|
5319
|
-
// checker input, never program modules: Node does not load them, so
|
|
5320
|
-
// their imports and syntax must not fence the program.
|
|
5321
|
-
const resolveRuntimeEdge = (sf, spec, resolutionKind) => resolveImport7(program, sf, spec, resolutionKind) ??
|
|
5322
|
-
npmStaticDepSf7(program, sf, spec, resolutionKind);
|
|
5323
|
-
const typeOnlyFiles = typeOnlyReachedFiles(program, entry, programFiles, () => [
|
|
5324
|
-
...forkTargetPaths(program, program.getImplementationSourceFiles()),
|
|
5325
|
-
...workerTargetPaths(program, program.getImplementationSourceFiles()),
|
|
5326
|
-
], resolveRuntimeEdge);
|
|
5327
|
-
const runtimeFiles = typeOnlyFiles.size === 0 ? programFiles : programFiles.filter((sf) => !typeOnlyFiles.has(sf));
|
|
5328
|
-
const userFiles = npmStaticActive()
|
|
5329
|
-
? planNpmStaticReexports(program, entry, runtimeFiles, [
|
|
5330
|
-
...createRequireProgramRoots7(program),
|
|
5331
|
-
...forkTargetPaths(program, program.getImplementationSourceFiles()),
|
|
5332
|
-
...workerTargetPaths(program, program.getImplementationSourceFiles()),
|
|
5333
|
-
], resolveRuntimeEdge)
|
|
5334
|
-
: runtimeFiles;
|
|
5335
|
-
program.getTypeChecker().prefetchSourceFileStructures(userFiles);
|
|
5336
|
-
// Unselected node_modules JS is not native program source even when
|
|
5337
|
-
// maxNodeModuleJsDepth pulled it into the checker (nodeModulesJsSuppressed).
|
|
5338
|
-
// Node stops at the nearest package.json even when it is malformed, and
|
|
5339
|
-
// an explicit CommonJS scope (or .cjs/.cts extension) disables ambiguous-
|
|
5340
|
-
// file syntax detection entirely. TypeScript's bundler checker models
|
|
5341
|
-
// neither loader rule, so restore them before any module-edge analysis:
|
|
5342
|
-
// one malformed-scope diagnostic per package file, and one pointed syntax
|
|
5343
|
-
// diagnostic per CommonJS source file.
|
|
5344
|
-
const invalidPackageConfigs = new Set();
|
|
5345
|
-
for (const sf of userFiles) {
|
|
5346
|
-
const invalidConfig = nearestInvalidPackageJsonPath(sf.fileName);
|
|
5347
|
-
if (invalidConfig !== null) {
|
|
5348
|
-
if (!invalidPackageConfigs.has(invalidConfig)) {
|
|
5349
|
-
invalidPackageConfigs.add(invalidConfig);
|
|
5350
|
-
diags.push(invalidPackageConfigDiag(invalidConfig, { file: sf.fileName, start: 0, end: 0 }));
|
|
5351
|
-
}
|
|
5352
|
-
continue;
|
|
5353
|
-
}
|
|
5354
|
-
if (!isNodeEsmFile7(sf, program)) {
|
|
5355
|
-
const marker = nodeEsmSyntaxMarker7(sf);
|
|
5356
|
-
if (marker !== null)
|
|
5357
|
-
diags.push(commonJsModuleSyntaxDiag(locOf7(marker)));
|
|
5358
|
-
}
|
|
5359
|
-
}
|
|
5360
|
-
const ambientModules = new Set(SUPPORTED_NODE_MODULES);
|
|
5361
|
-
// Ambient `declare module "name"` declarations anywhere in the program —
|
|
5362
|
-
// exact names and `*` patterns — so the import fence can say "type
|
|
5363
|
-
// surface only, no runtime module" instead of the generic package story.
|
|
5364
|
-
// Computed lazily: the scan only runs when a bare-import fence is about
|
|
5365
|
-
// to fire.
|
|
5366
|
-
let ambientModuleDecls = null;
|
|
5367
|
-
const ambientDeclared = (spec) => {
|
|
5368
|
-
if (ambientModuleDecls === null) {
|
|
5369
|
-
ambientModuleDecls = { names: new Set(), patterns: [] };
|
|
5370
|
-
for (const f of program.getSourceFiles()) {
|
|
5371
|
-
for (const s of f.statements.nodes) {
|
|
5372
|
-
if (!ts.isModuleDeclaration(s) || !ts.isStringLiteral(s.name))
|
|
5373
|
-
continue;
|
|
5374
|
-
const name = s.name.text;
|
|
5375
|
-
if (name.includes("*"))
|
|
5376
|
-
ambientModuleDecls.patterns.push(name);
|
|
5377
|
-
else
|
|
5378
|
-
ambientModuleDecls.names.add(name);
|
|
5379
|
-
}
|
|
5380
|
-
}
|
|
5381
|
-
}
|
|
5382
|
-
if (ambientModuleDecls.names.has(spec))
|
|
5383
|
-
return true;
|
|
5384
|
-
return ambientModuleDecls.patterns.some((p) => {
|
|
5385
|
-
const star = p.indexOf("*");
|
|
5386
|
-
return (spec.length >= p.length - 1 &&
|
|
5387
|
-
spec.startsWith(p.slice(0, star)) &&
|
|
5388
|
-
spec.endsWith(p.slice(star + 1)));
|
|
5389
|
-
});
|
|
5287
|
+
return ambientModuleDecls.patterns.some((p) => {
|
|
5288
|
+
const star = p.indexOf("*");
|
|
5289
|
+
return (spec.length >= p.length - 1 &&
|
|
5290
|
+
spec.startsWith(p.slice(0, star)) &&
|
|
5291
|
+
spec.endsWith(p.slice(star + 1)));
|
|
5292
|
+
});
|
|
5390
5293
|
};
|
|
5391
5294
|
// Module edges. An edge that closes a cycle is judged by the shared
|
|
5392
5295
|
// admission engine (makeCycleAdmission): admissible when nothing can
|
|
@@ -5568,12 +5471,30 @@ function preflight7(load) {
|
|
|
5568
5471
|
// Project modules win before npm fallback: this is the source graph
|
|
5569
5472
|
// tsgo type-checked for tsconfig paths, package imports/self-references,
|
|
5570
5473
|
// and provenance entries. Ordinary packages still answer null here.
|
|
5571
|
-
const
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
:
|
|
5474
|
+
const projectAnswer = isBare ? resolveImport7(program, sf, spec) : null;
|
|
5475
|
+
let projDep = projectAnswer;
|
|
5476
|
+
let npm = null;
|
|
5477
|
+
if (isBare && !spec.startsWith("#")) {
|
|
5478
|
+
// A tsconfig `paths` target can name an installed package's directory
|
|
5479
|
+
// (pi maps "typebox": ["./node_modules/typebox"]): its declarations
|
|
5480
|
+
// are the package's own, so Node resolves the same specifier to the
|
|
5481
|
+
// same answer and the import is an npm import after all. The npm arm
|
|
5482
|
+
// below owns it then — its runtime refusal, npm-static membership and
|
|
5483
|
+
// island policy included. A mapping whose answer the npm resolver does
|
|
5484
|
+
// not reproduce stays a project import (and its SC1010).
|
|
5485
|
+
const installed = projectAnswer !== null &&
|
|
5486
|
+
projectAnswer.isDeclarationFile &&
|
|
5487
|
+
isNodeModulesPath(projectAnswer.fileName)
|
|
5488
|
+
? resolveNpmImport7(sf.fileName, spec)
|
|
5489
|
+
: null;
|
|
5490
|
+
if (installed !== null && sameResolvedFile(installed.typesFile, projectAnswer.fileName)) {
|
|
5491
|
+
projDep = null;
|
|
5492
|
+
npm = installed;
|
|
5493
|
+
}
|
|
5494
|
+
else if (projectAnswer === null) {
|
|
5495
|
+
npm = resolveNpmImport7(sf.fileName, spec);
|
|
5496
|
+
}
|
|
5497
|
+
}
|
|
5577
5498
|
if (npm && isNodeTypesPath(npm.typesFile)) {
|
|
5578
5499
|
diags.push(unsupportedDiag("SC1010", locOf7(stmt), unsupportedModuleFeatureOf(spec)));
|
|
5579
5500
|
continue;
|
|
@@ -6086,11 +6007,6 @@ function preflight7(load) {
|
|
|
6086
6007
|
}
|
|
6087
6008
|
};
|
|
6088
6009
|
visit(entry);
|
|
6089
|
-
// ECMAScript's sloppy-mode WRITE to an undeclared name, which the JS
|
|
6090
|
-
// relaxation above admits for READS (plan D-2): refused by name, with the
|
|
6091
|
-
// island route in the text (SC1091).
|
|
6092
|
-
for (const d of jsUndeclaredWriteDiags(program, order))
|
|
6093
|
-
diags.push(d);
|
|
6094
6010
|
// The startup crash Node's RESOLUTION phase reports: modules resolve
|
|
6095
6011
|
// their request specifiers in source order, children linking depth-first
|
|
6096
6012
|
// as each resolves (ModuleJob.syncLink) — a preorder walk over the
|
|
@@ -6101,6 +6017,7 @@ function preflight7(load) {
|
|
|
6101
6017
|
// Node's fetch/resolve phase runs before instantiate.
|
|
6102
6018
|
let resolveCrash = null;
|
|
6103
6019
|
const dynamicImportRejections = new Map();
|
|
6020
|
+
const fallbacks = [];
|
|
6104
6021
|
{
|
|
6105
6022
|
const seen = new Set();
|
|
6106
6023
|
const walk = (sf) => {
|
|
@@ -6173,32 +6090,388 @@ function preflight7(load) {
|
|
|
6173
6090
|
// preflight: when any other diagnostic already fails the build, every
|
|
6174
6091
|
// refusal keeps its compile-fence fallback instead — the report names
|
|
6175
6092
|
// each import's story, so edges whose crash will never compile still
|
|
6176
|
-
// get a diagnostic. (No reachable refusal → same: fallbacks only.)
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
}
|
|
6093
|
+
// get a diagnostic. (No reachable refusal → same: fallbacks only.) The
|
|
6094
|
+
// "otherwise pass" half of that question is preflightDiagnostics7's:
|
|
6095
|
+
// it alone sees the tsc gate's diagnostics, so it reports `fallbacks`.
|
|
6096
|
+
for (const [sf, cands] of refusals) {
|
|
6097
|
+
if (covered.has(sf) && !startup.has(sf))
|
|
6098
|
+
continue;
|
|
6099
|
+
for (const c of cands)
|
|
6100
|
+
fallbacks.push(c.fallback);
|
|
6185
6101
|
}
|
|
6186
6102
|
}
|
|
6187
|
-
|
|
6103
|
+
return {
|
|
6104
|
+
order,
|
|
6105
|
+
moduleEdges: edges,
|
|
6106
|
+
dynamicImportRejections,
|
|
6107
|
+
inlineRequireCycleCalls,
|
|
6108
|
+
diags,
|
|
6109
|
+
resolveCrash,
|
|
6110
|
+
fallbacks,
|
|
6111
|
+
};
|
|
6112
|
+
}
|
|
6113
|
+
/** The whole preflight for one load: the tsc gate, the module graph walk and
|
|
6114
|
+
* every diagnostic they report, in report order. The structure is memoized,
|
|
6115
|
+
* so a caller that asked for the order first (checkModuleOrder) pays for the
|
|
6116
|
+
* walk once. */
|
|
6117
|
+
function preflight7(load) {
|
|
6118
|
+
registerWorkspaceEdges(load);
|
|
6119
|
+
const gate = preflightGate7(load);
|
|
6120
|
+
const structure = preflightStructure(load);
|
|
6121
|
+
const { diags, startupCrash } = preflightDiagnostics7(load, structure, gate.diags);
|
|
6122
|
+
return {
|
|
6123
|
+
diags,
|
|
6124
|
+
moduleOrder: structure.order,
|
|
6125
|
+
startupCrash,
|
|
6126
|
+
inlineRequireCycleCalls: structure.inlineRequireCycleCalls,
|
|
6127
|
+
moduleEdges: structure.moduleEdges,
|
|
6128
|
+
dynamicImportRejections: structure.dynamicImportRejections,
|
|
6129
|
+
admittedOpinions: gate.admittedOpinions,
|
|
6130
|
+
};
|
|
6131
|
+
}
|
|
6132
|
+
/** The diagnostics half of preflight: the tsc gate ahead of the walk's own
|
|
6133
|
+
* diagnostics, then the passes that judge the completed module order. The
|
|
6134
|
+
* tsc gate runs first on every load whose order was not requested on its
|
|
6135
|
+
* own, exactly as it did inside the single pass. */
|
|
6136
|
+
function preflightDiagnostics7(load, structure, gate) {
|
|
6137
|
+
const { program, entry } = load;
|
|
6138
|
+
const order = structure.order;
|
|
6139
|
+
const diags = [...load.configDiags];
|
|
6140
|
+
for (const d of gate)
|
|
6141
|
+
diags.push(d);
|
|
6142
|
+
for (const d of structure.diags)
|
|
6143
|
+
diags.push(d);
|
|
6144
|
+
// ECMAScript's sloppy-mode WRITE to an undeclared name, which the JS
|
|
6145
|
+
// relaxation above admits for READS (plan D-2): refused by name, with the
|
|
6146
|
+
// island route in the text (SC1091).
|
|
6147
|
+
for (const d of jsUndeclaredWriteDiags(program, order))
|
|
6148
|
+
diags.push(d);
|
|
6149
|
+
// The crash channel engages only when nothing else fails preflight.
|
|
6150
|
+
let startupCrash = structure.resolveCrash;
|
|
6151
|
+
if (startupCrash === null || diags.length > 0) {
|
|
6152
|
+
startupCrash = null;
|
|
6153
|
+
for (const d of structure.fallbacks)
|
|
6154
|
+
diags.push(d);
|
|
6155
|
+
}
|
|
6156
|
+
const linkCrash = startupCrash !== null
|
|
6188
6157
|
? null
|
|
6189
6158
|
: earlierLinkCrash(order, cjsNamedImportLinkCheck(program, entry, order, diags), esmNamedImportLinkCheck(program, entry, order, diags));
|
|
6190
6159
|
// ECMAScript early errors the TypeScript checker does not model (plan
|
|
6191
6160
|
// §7.7 D-4): a JavaScript source the spec makes a SyntaxError fails here,
|
|
6192
6161
|
// before any lowering, exactly where a tsc parse error fails.
|
|
6193
6162
|
diags.push(...earlyErrorDiagnostics7(order, (sf) => isNodeEsmFile7(sf, program)));
|
|
6194
|
-
return {
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6163
|
+
return { diags, startupCrash: startupCrash ?? linkCrash };
|
|
6164
|
+
}
|
|
6165
|
+
function preflightGate7(load) {
|
|
6166
|
+
const { program, entry } = load;
|
|
6167
|
+
const diags = [];
|
|
6168
|
+
const unselectedPackageJsFile = unselectedPackageJsFilePredicate(entry.fileName);
|
|
6169
|
+
const toPassthrough = (d) => {
|
|
6170
|
+
const message = ts.flattenDiagnosticMessageText(d, "\n");
|
|
6171
|
+
// File-less (global/options) diagnostics anchor at the entry with a
|
|
6172
|
+
// zero span, exactly like the 5.9.3 lane's `d.start ?? 0` fallback.
|
|
6173
|
+
const file = d.fileName ?? entry.fileName;
|
|
6174
|
+
const start = d.fileName !== undefined ? d.pos : 0;
|
|
6175
|
+
const end = d.fileName !== undefined ? d.end : 0;
|
|
6176
|
+
// A JavaScript source's `refuse`/`rewrite` code names the construct
|
|
6177
|
+
// scriptc does not lower (tsc-codes.ts): the user sees what is missing
|
|
6178
|
+
// instead of TypeScript's opinion about legal JavaScript.
|
|
6179
|
+
const triaged = d.fileName !== undefined && isJsSourceFileName(d.fileName) ? jsTscCodeTriage(d.code) : null;
|
|
6180
|
+
if (triaged?.action === "refuse" || triaged?.action === "rewrite") {
|
|
6181
|
+
const diag = unsupportedDiag("SC1090", { file, start, end }, triaged.feature, `${triaged.hint} (TypeScript reports TS${d.code} here.)`);
|
|
6182
|
+
return diag;
|
|
6183
|
+
}
|
|
6184
|
+
const diag = tscPassthroughDiag(message, { file, start, end });
|
|
6185
|
+
const hint = typeWorldHint(d, message, load);
|
|
6186
|
+
if (hint !== null) {
|
|
6187
|
+
diag.typeWorld = true;
|
|
6188
|
+
diag.hint = hint;
|
|
6189
|
+
}
|
|
6190
|
+
return diag;
|
|
6191
|
+
};
|
|
6192
|
+
/* TS7 checker change (not finding 5, same discipline): tsgo types a
|
|
6193
|
+
* NAMESPACE import as the spec's non-callable module namespace object
|
|
6194
|
+
* even when the module is declared with the callable `export =` shape —
|
|
6195
|
+
* 5.9.3 bound the callable value directly, so `import * as a from
|
|
6196
|
+
* "node:assert"; a(x)` typechecked there and draws TS2349 here. Those
|
|
6197
|
+
* callable module objects are scriptc's OWN declared surface, and calls
|
|
6198
|
+
* through the namespace binding are fenced per site by the lowering (the
|
|
6199
|
+
* assert-fences fixture pins the wording), so tsgo's extra TS2349 on
|
|
6200
|
+
* exactly those callees — an identifier that is a namespace-import
|
|
6201
|
+
* binding of a supported builtin module — is suppressed to the 5.9.3
|
|
6202
|
+
* verdict. Nothing else rides this: any other non-callable call keeps
|
|
6203
|
+
* tsc's voice in both lanes. */
|
|
6204
|
+
const builtinNamespaceNames = new Map();
|
|
6205
|
+
const namespaceCalleeSuppressed = (p, d) => {
|
|
6206
|
+
if (d.code !== 2349 || d.fileName === undefined)
|
|
6207
|
+
return false;
|
|
6208
|
+
let names = builtinNamespaceNames.get(d.fileName);
|
|
6209
|
+
if (!names) {
|
|
6210
|
+
names = new Set();
|
|
6211
|
+
builtinNamespaceNames.set(d.fileName, names);
|
|
6212
|
+
const sf = p.getSourceFile(d.fileName);
|
|
6213
|
+
for (const stmt of sf?.statements?.nodes ?? []) {
|
|
6214
|
+
if (!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier))
|
|
6215
|
+
continue;
|
|
6216
|
+
if (canonicalBuiltinModule(stmt.moduleSpecifier.text) === null)
|
|
6217
|
+
continue;
|
|
6218
|
+
const bindings = stmt.importClause?.namedBindings;
|
|
6219
|
+
if (bindings && ts.isNamespaceImport(bindings))
|
|
6220
|
+
names.add(bindings.name.text);
|
|
6221
|
+
}
|
|
6222
|
+
}
|
|
6223
|
+
if (names.size === 0)
|
|
6224
|
+
return false;
|
|
6225
|
+
const sf = p.getSourceFile(d.fileName);
|
|
6226
|
+
return sf !== undefined && names.has(sf.text.slice(d.pos, d.end));
|
|
6227
|
+
};
|
|
6228
|
+
const npmStaticFileSuppressed = (d) => d.fileName !== undefined && npmStaticPackageOfPath(d.fileName) !== null;
|
|
6229
|
+
const nodeModulesJsSuppressed = (d) => d.fileName !== undefined && unselectedPackageJsFile(d.fileName);
|
|
6230
|
+
/* JSDoc TYPE positions in JS files are documentation Node never reads:
|
|
6231
|
+
* a name-resolution failure THERE (2304/2552 — the pattern's utilities.js
|
|
6232
|
+
* spells a mapped type over a @template name it never declared) types
|
|
6233
|
+
* as the error-any and the per-site fences apply, same stance as the
|
|
6234
|
+
* strictness families above. A 2300 duplicate-identifier PAIR formed by
|
|
6235
|
+
* a @typedef and a same-named class/function is the same story — the
|
|
6236
|
+
* typedef half sits inside the comment, and the code half is suppressed
|
|
6237
|
+
* exactly when its partner (same file, same name) was comment-side, so
|
|
6238
|
+
* a REAL duplicate declaration (both halves in code — Node's own
|
|
6239
|
+
* SyntaxError) keeps tsc's voice. */
|
|
6240
|
+
const insideBlockComment = (text, pos) => {
|
|
6241
|
+
const open = text.lastIndexOf("/*", pos);
|
|
6242
|
+
if (open < 0)
|
|
6243
|
+
return false;
|
|
6244
|
+
const close = text.indexOf("*/", open + 2);
|
|
6245
|
+
return close === -1 || close >= pos;
|
|
6246
|
+
};
|
|
6247
|
+
const jsdocTypeSuppressed = (p, d, commentDup) => {
|
|
6248
|
+
if (d.fileName === undefined || !isJsSourceFileName(d.fileName))
|
|
6249
|
+
return false;
|
|
6250
|
+
if (d.code !== 2304 && d.code !== 2552 && d.code !== 2300 && d.code !== 1003)
|
|
6251
|
+
return false;
|
|
6252
|
+
if (d.pos === undefined)
|
|
6253
|
+
return false;
|
|
6254
|
+
const sf = p.getSourceFile(d.fileName);
|
|
6255
|
+
if (!sf)
|
|
6256
|
+
return false;
|
|
6257
|
+
if (insideBlockComment(sf.text, d.pos))
|
|
6258
|
+
return true;
|
|
6259
|
+
return d.code === 2300 && commentDup.has(`${d.fileName}:${sf.text.slice(d.pos, d.end)}`);
|
|
6260
|
+
};
|
|
6261
|
+
/* `typeof window` / `typeof self` in a JavaScript file: the operand of
|
|
6262
|
+
* typeof may name a global nothing declares (Node answers "undefined"
|
|
6263
|
+
* and never throws), the feature-detection idiom every isomorphic
|
|
6264
|
+
* package uses, and the guarded uses of that name (`typeof window < "u"
|
|
6265
|
+
* ? window : …`) are code Node never runs. A name the file feature-tests
|
|
6266
|
+
* this way is therefore not a type error in JavaScript; a reached use
|
|
6267
|
+
* still meets the lowering's located refusal. TypeScript files keep the
|
|
6268
|
+
* error and its hint. */
|
|
6269
|
+
const typeofTestedNameSuppressed = (p, d) => {
|
|
6270
|
+
if (d.code !== 2304 && d.code !== 2552 && d.code !== 2584)
|
|
6271
|
+
return false;
|
|
6272
|
+
if (d.fileName === undefined || !isJsSourceFileName(d.fileName))
|
|
6273
|
+
return false;
|
|
6274
|
+
if (d.pos === undefined || d.end === undefined)
|
|
6275
|
+
return false;
|
|
6276
|
+
const sf = p.getSourceFile(d.fileName);
|
|
6277
|
+
if (!sf)
|
|
6278
|
+
return false;
|
|
6279
|
+
const name = sf.text.slice(d.pos, d.end);
|
|
6280
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(name))
|
|
6281
|
+
return false;
|
|
6282
|
+
return new RegExp(`\\btypeof\\s*\\(?\\s*${name.replace(/\$/g, "\\$")}(?![\\w$])`).test(sf.text);
|
|
6283
|
+
};
|
|
6284
|
+
// A `return` at the top level of a CommonJS module (TS1108): Node runs
|
|
6285
|
+
// the module as a function body, so the return ends the module's
|
|
6286
|
+
// evaluation. ES modules and TypeScript keep the error.
|
|
6287
|
+
const cjsTopLevelReturnSuppressed = (p, d) => {
|
|
6288
|
+
if (d.code !== 1108 || d.fileName === undefined || !isJsSourceFileName(d.fileName))
|
|
6289
|
+
return false;
|
|
6290
|
+
const sf = p.getSourceFile(d.fileName);
|
|
6291
|
+
return sf !== undefined && isCjsJsFile7(sf, p);
|
|
6292
|
+
};
|
|
6293
|
+
const workspaceImplicitAnySuppressed = (p, d) => {
|
|
6294
|
+
if (d.code !== 7016 || d.fileName === undefined || d.pos === undefined || d.end === undefined)
|
|
6295
|
+
return false;
|
|
6296
|
+
const sf = p.getSourceFile(d.fileName);
|
|
6297
|
+
if (!sf)
|
|
6298
|
+
return false;
|
|
6299
|
+
const spec = sf.text.slice(d.pos, d.end).replace(/^['"]|['"]$/g, "");
|
|
6300
|
+
const prefix = spec.startsWith("@")
|
|
6301
|
+
? spec.split("/").slice(0, 2).join("/")
|
|
6302
|
+
: spec.split("/")[0];
|
|
6303
|
+
return isWorkspacePackageName(prefix);
|
|
6304
|
+
};
|
|
6305
|
+
// A JavaScript file that TypeScript checks keeps the type errors that
|
|
6306
|
+
// protect its JSDoc types: a value of another type reaching a typed slot,
|
|
6307
|
+
// a call with the wrong arity, and a subclass member that does not
|
|
6308
|
+
// match its base (the rows that say `checkedJs: "enforce"` in
|
|
6309
|
+
// JS_OPINIONS).
|
|
6310
|
+
const projectCheckJs = load.typeWorld?.projectCheckJs ?? false;
|
|
6311
|
+
// The opinion sites this preflight admits (tsc-codes.ts, JS_OPINIONS),
|
|
6312
|
+
// deduped across the worlds the gate consults (the lowering world, the
|
|
6313
|
+
// project world, the JSX text). The lowering asks opinionAt about one of
|
|
6314
|
+
// them; a view's lowering path is gated on the record, never on syntax.
|
|
6315
|
+
const admittedOpinions = new Map();
|
|
6316
|
+
const recordAdmittedOpinion = (site) => {
|
|
6317
|
+
admittedOpinions.set(`${site.file}\0${site.pos}\0${site.end}\0${site.code}`, site);
|
|
6318
|
+
};
|
|
6319
|
+
// A diagnostic's span is an offset into the text of the program that
|
|
6320
|
+
// answered it. With JSX sources the gate's worlds hold the files as
|
|
6321
|
+
// written, while the lowering asks opinionAt about nodes of `program`,
|
|
6322
|
+
// which carries the rewritten text; an original offset recorded as a site
|
|
6323
|
+
// would name an unrelated node wherever a rewrite moved the text. The span
|
|
6324
|
+
// moves into that text exactly as a reported diagnostic's location does
|
|
6325
|
+
// below: copied text keeps its offset, a span inside JSX maps to the call
|
|
6326
|
+
// it lowered to.
|
|
6327
|
+
const admittedSite = (p, site) => {
|
|
6328
|
+
if (p === program)
|
|
6329
|
+
return site;
|
|
6330
|
+
const lowered = load.jsxSources?.get(site.file);
|
|
6331
|
+
if (lowered === undefined)
|
|
6332
|
+
return site;
|
|
6333
|
+
return {
|
|
6334
|
+
...site,
|
|
6335
|
+
pos: lowered.rewrittenPosition(site.pos, false),
|
|
6336
|
+
end: lowered.rewrittenPosition(site.end, true),
|
|
6337
|
+
};
|
|
6338
|
+
};
|
|
6339
|
+
// keptErrors drops every diagnostic of these files: the gate does not ask
|
|
6340
|
+
// the checker for them.
|
|
6341
|
+
const diagnosticsKept = (fileName) => npmStaticPackageOfPath(fileName) === null &&
|
|
6342
|
+
!unselectedPackageJsFile(fileName) &&
|
|
6343
|
+
!isPackageShimFile(fileName);
|
|
6344
|
+
const errorsOf = (p) => keptErrors(p, ts.getPreEmitDiagnostics(p, diagnosticsKept));
|
|
6345
|
+
const keptErrors = (p, all) => {
|
|
6346
|
+
// First pass: every comment-side 2300's (file, name) — the partners
|
|
6347
|
+
// the second pass forgives.
|
|
6348
|
+
const commentDup = new Set();
|
|
6349
|
+
for (const d of all) {
|
|
6350
|
+
if (d.code !== 2300 || d.fileName === undefined || d.pos === undefined || d.end === undefined)
|
|
6351
|
+
continue;
|
|
6352
|
+
if (!isJsSourceFileName(d.fileName))
|
|
6353
|
+
continue;
|
|
6354
|
+
const sf = p.getSourceFile(d.fileName);
|
|
6355
|
+
if (sf && insideBlockComment(sf.text, d.pos))
|
|
6356
|
+
commentDup.add(`${d.fileName}:${sf.text.slice(d.pos, d.end)}`);
|
|
6357
|
+
}
|
|
6358
|
+
// The syntactic diagnostics of a JS file, asked for only when a
|
|
6359
|
+
// diagnostic names a code an opinion row covers.
|
|
6360
|
+
const syntactic = new Map();
|
|
6361
|
+
const syntacticOf = (sf) => {
|
|
6362
|
+
let list = syntactic.get(sf.fileName);
|
|
6363
|
+
if (list === undefined) {
|
|
6364
|
+
list = p.getSyntacticDiagnostics(sf);
|
|
6365
|
+
syntactic.set(sf.fileName, list);
|
|
6366
|
+
}
|
|
6367
|
+
return list;
|
|
6368
|
+
};
|
|
6369
|
+
// The older filters that answer from the file name, the source text or
|
|
6370
|
+
// the syntax alone. The recording pass below uses this subset: the two
|
|
6371
|
+
// filters that ask the CHECKER a question
|
|
6372
|
+
// (inferredJsDiagnosticSuppressed, isNpmStaticSubclassArgument) are
|
|
6373
|
+
// deliberately not consulted for an admitted diagnostic. Before this
|
|
6374
|
+
// table, an admitted diagnostic was dropped before the chain reached
|
|
6375
|
+
// them, so asking now would add a checker query a program's compile
|
|
6376
|
+
// never made — and tsgo answers the query on a destructuring pattern
|
|
6377
|
+
// with a panic ("Value is not an instance of 'TupleType'"), which is how
|
|
6378
|
+
// this slice's Test262 replay first failed. The kept path still consults
|
|
6379
|
+
// every filter, in the order it always did.
|
|
6380
|
+
const keptApartFromOpinionTextually = (d) => !npmStaticFileSuppressed(d) &&
|
|
6381
|
+
!nodeModulesJsSuppressed(d) &&
|
|
6382
|
+
(d.fileName === undefined || !isPackageShimFile(d.fileName)) &&
|
|
6383
|
+
!namespaceCalleeSuppressed(p, d) &&
|
|
6384
|
+
!workspaceImplicitAnySuppressed(p, d) &&
|
|
6385
|
+
!typeofTestedNameSuppressed(p, d) &&
|
|
6386
|
+
!cjsTopLevelReturnSuppressed(p, d) &&
|
|
6387
|
+
!jsdocTypeSuppressed(p, d, commentDup);
|
|
6388
|
+
// Every filter except the opinion admission, in its historical order.
|
|
6389
|
+
const keptApartFromOpinion = (d) => keptApartFromOpinionTextually(d) &&
|
|
6390
|
+
!inferredJsDiagnosticSuppressed(p, d) &&
|
|
6391
|
+
!isNpmStaticSubclassArgument(p, d);
|
|
6392
|
+
const admitted = [];
|
|
6393
|
+
const kept = all.filter((d) => {
|
|
6394
|
+
if (d.category !== ts.DiagnosticCategory.Error)
|
|
6395
|
+
return false;
|
|
6396
|
+
// The 8xxx range is TypeScript's JSDoc-specific diagnostic family
|
|
6397
|
+
// (malformed tags, signature/tag mismatches): comment semantics with no
|
|
6398
|
+
// runtime meaning in a JS file, and no lowering view to record.
|
|
6399
|
+
if (d.fileName !== undefined &&
|
|
6400
|
+
isJsSourceFileName(d.fileName) &&
|
|
6401
|
+
d.code >= 8000 &&
|
|
6402
|
+
d.code <= 8999)
|
|
6403
|
+
return false;
|
|
6404
|
+
const opinion = jsOpinionOf7(p, d, projectCheckJs, syntacticOf);
|
|
6405
|
+
if (opinion !== null) {
|
|
6406
|
+
admitted.push({ d, opinion });
|
|
6407
|
+
return false;
|
|
6408
|
+
}
|
|
6409
|
+
return keptApartFromOpinion(d);
|
|
6410
|
+
});
|
|
6411
|
+
for (const { d, opinion } of admitted) {
|
|
6412
|
+
// No span, no site: nothing a view's lowering could be gated on.
|
|
6413
|
+
if (d.fileName === undefined || d.pos === undefined || d.end === undefined)
|
|
6414
|
+
continue;
|
|
6415
|
+
if (keptApartFromOpinionTextually(d))
|
|
6416
|
+
recordAdmittedOpinion(admittedSite(p, {
|
|
6417
|
+
file: d.fileName,
|
|
6418
|
+
pos: d.pos,
|
|
6419
|
+
end: d.end,
|
|
6420
|
+
code: d.code,
|
|
6421
|
+
view: opinion.view,
|
|
6422
|
+
}));
|
|
6423
|
+
}
|
|
6424
|
+
return kept;
|
|
6201
6425
|
};
|
|
6426
|
+
// The tsc gate, with a second chance: the LOWERING world's checker
|
|
6427
|
+
// includes the divergence overrides (JSON.parse(): unknown, the Promise
|
|
6428
|
+
// executor shape, ...), which are TIGHTER than the standard lib — a
|
|
6429
|
+
// project that typechecks clean under its own tsc can still error here
|
|
6430
|
+
// (any-typed JSON.parse results, most commonly). Those errors are OURS,
|
|
6431
|
+
// not the project's, so they must not fail preflight: when the lowering
|
|
6432
|
+
// world has errors, the PROJECT world (same program without the override
|
|
6433
|
+
// declarations) is built and consulted. Clean there → preflight passes
|
|
6434
|
+
// and the override-affected sites meet the lowerer's honest fences
|
|
6435
|
+
// instead (the SC1100 checked-cast family). Dirty there → the project-
|
|
6436
|
+
// world errors are the ones reported: they are reproducible with the
|
|
6437
|
+
// project's own tsc, which is what "fix type errors first" asks for.
|
|
6438
|
+
// With JSX sources, the program over the original text answers the tsc
|
|
6439
|
+
// gate; its positions move into the rewritten text the program holds.
|
|
6440
|
+
// Errors only the rewritten text has come from the calls the JSX lowers
|
|
6441
|
+
// to (a factory whose signature does not accept them).
|
|
6442
|
+
const tscWorld = load.tscWorld;
|
|
6443
|
+
const tscErrors = tscWorld === undefined ? errorsOf(program) : keptErrors(tscWorld.program, tscWorld.diagnostics);
|
|
6444
|
+
if (tscErrors.length > 0) {
|
|
6445
|
+
const world = tscWorld === undefined || tscWorld.declWorldFallback === true
|
|
6446
|
+
? load.projectWorld()
|
|
6447
|
+
: (tscWorld.projectWorld ?? tscWorld.program);
|
|
6448
|
+
for (const d of errorsOf(world)) {
|
|
6449
|
+
const diag = toPassthrough(d);
|
|
6450
|
+
const lowered = tscWorld === undefined ? undefined : load.jsxSources?.get(diag.loc.file);
|
|
6451
|
+
if (lowered !== undefined) {
|
|
6452
|
+
diag.loc = {
|
|
6453
|
+
...diag.loc,
|
|
6454
|
+
start: lowered.rewrittenPosition(diag.loc.start, false),
|
|
6455
|
+
end: lowered.rewrittenPosition(diag.loc.end, true),
|
|
6456
|
+
};
|
|
6457
|
+
}
|
|
6458
|
+
diags.push(diag);
|
|
6459
|
+
}
|
|
6460
|
+
}
|
|
6461
|
+
else if (load.jsxSources !== undefined) {
|
|
6462
|
+
for (const file of load.jsxSources.keys()) {
|
|
6463
|
+
const sf = program.getSourceFile(file);
|
|
6464
|
+
if (sf === undefined)
|
|
6465
|
+
continue;
|
|
6466
|
+
const own = [...program.getSyntacticDiagnostics(sf), ...program.getSemanticDiagnostics(sf)];
|
|
6467
|
+
for (const d of keptErrors(program, own)) {
|
|
6468
|
+
const diag = toPassthrough(d);
|
|
6469
|
+
diag.message = `${diag.message} (in the call this JSX lowers to)`;
|
|
6470
|
+
diags.push(diag);
|
|
6471
|
+
}
|
|
6472
|
+
}
|
|
6473
|
+
}
|
|
6474
|
+
return { diags, admittedOpinions: [...admittedOpinions.values()] };
|
|
6202
6475
|
}
|
|
6203
6476
|
/* ── the CJS named-import link check ─────────────────────────────────────
|
|
6204
6477
|
* Node builds a CommonJS module's ESM facade from its LEXER (cjs-lexer.ts
|
|
@@ -6794,7 +7067,7 @@ const nodeBuiltinNames = new Set(builtinModules);
|
|
|
6794
7067
|
export { ambientDtsPath, fallbackDtsPath, isFallbackDtsPath, isNodeTypesPath, overridesDtsPath, } from "./dts-paths.js";
|
|
6795
7068
|
export { builtinDefaultImportModule, canonicalBuiltinModule, npmBuiltinAliasOf, SUPPORTED_BUILTIN_MODULES, } from "./builtin-modules.js";
|
|
6796
7069
|
export { npmPackageNameOf, workspacePackageOfPath } from "./workspace-registry.js";
|
|
6797
|
-
export { requireSpecOf7 as requireSpecOf, isRequireStatement7 as isRequireStatement, requiresOf7 as requiresOf, splitRequireCallOf7 as splitRequireCallOf, isNodeEsmFile7 as isNodeEsmFile, resolveImport7 as resolveImport, resolveNpmImport7 as resolveNpmImport, locOf7 as locOf, requireEarlyReference7 as requireEarlyReference, inDeferredPosition7 as inDeferredPosition, };
|
|
7070
|
+
export { requireSpecOf7 as requireSpecOf, requireCallBindingKind7 as requireCallBindingKind, isRequireStatement7 as isRequireStatement, requiresOf7 as requiresOf, splitRequireCallOf7 as splitRequireCallOf, isNodeEsmFile7 as isNodeEsmFile, resolveImport7 as resolveImport, resolveNpmImport7 as resolveNpmImport, locOf7 as locOf, requireEarlyReference7 as requireEarlyReference, inDeferredPosition7 as inDeferredPosition, };
|
|
6798
7071
|
/** True for JavaScript source files (.js/.mjs/.cjs) — the files whose
|
|
6799
7072
|
* types come entirely from inference (checkJs + JSDoc) and whose classes
|
|
6800
7073
|
* declare fields by constructor assignment. */
|