@barefootjs/jsx 0.40.1 → 0.40.2

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.
Files changed (176) hide show
  1. package/dist/adapters/ambiguous-nil-arithmetic.d.ts +4 -3
  2. package/dist/adapters/ambiguous-nil-arithmetic.d.ts.map +1 -1
  3. package/dist/adapters/boolean-result.d.ts +32 -10
  4. package/dist/adapters/boolean-result.d.ts.map +1 -1
  5. package/dist/adapters/brace-delimiter-text.d.ts +18 -0
  6. package/dist/adapters/brace-delimiter-text.d.ts.map +1 -0
  7. package/dist/adapters/callback-method.d.ts +38 -5
  8. package/dist/adapters/callback-method.d.ts.map +1 -1
  9. package/dist/adapters/computed-const.d.ts +11 -1
  10. package/dist/adapters/computed-const.d.ts.map +1 -1
  11. package/dist/adapters/dsl-template-adapter.d.ts +21 -0
  12. package/dist/adapters/dsl-template-adapter.d.ts.map +1 -1
  13. package/dist/adapters/loop-bound-names.d.ts +9 -1
  14. package/dist/adapters/loop-bound-names.d.ts.map +1 -1
  15. package/dist/adapters/loop-row-type.d.ts +52 -0
  16. package/dist/adapters/loop-row-type.d.ts.map +1 -0
  17. package/dist/adapters/nil-reading.d.ts +68 -0
  18. package/dist/adapters/nil-reading.d.ts.map +1 -0
  19. package/dist/adapters/non-primitive-equality.d.ts +33 -0
  20. package/dist/adapters/non-primitive-equality.d.ts.map +1 -0
  21. package/dist/adapters/number-value.d.ts +5 -3
  22. package/dist/adapters/number-value.d.ts.map +1 -1
  23. package/dist/adapters/operand-typing.d.ts +126 -0
  24. package/dist/adapters/operand-typing.d.ts.map +1 -0
  25. package/dist/adapters/parsed-expr-emitter.d.ts +70 -12
  26. package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
  27. package/dist/adapters/primitive-plan.d.ts +291 -0
  28. package/dist/adapters/primitive-plan.d.ts.map +1 -0
  29. package/dist/analyzer-context.d.ts +4 -0
  30. package/dist/analyzer-context.d.ts.map +1 -1
  31. package/dist/analyzer.d.ts.map +1 -1
  32. package/dist/augment-inherited-props.d.ts +63 -8
  33. package/dist/augment-inherited-props.d.ts.map +1 -1
  34. package/dist/compiler.d.ts.map +1 -1
  35. package/dist/event-handler-name.d.ts +12 -0
  36. package/dist/event-handler-name.d.ts.map +1 -1
  37. package/dist/expression-parser.d.ts +8 -0
  38. package/dist/expression-parser.d.ts.map +1 -1
  39. package/dist/index.d.ts +19 -9
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +4628 -2198
  42. package/dist/ir-to-client-js/build-references.d.ts.map +1 -1
  43. package/dist/ir-to-client-js/child-props-object.d.ts +64 -0
  44. package/dist/ir-to-client-js/child-props-object.d.ts.map +1 -0
  45. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  46. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
  47. package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
  48. package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
  49. package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts +4 -2
  50. package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts.map +1 -1
  51. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  52. package/dist/ir-to-client-js/imports.d.ts +2 -2
  53. package/dist/ir-to-client-js/imports.d.ts.map +1 -1
  54. package/dist/ir-to-client-js/index.d.ts +2 -6
  55. package/dist/ir-to-client-js/index.d.ts.map +1 -1
  56. package/dist/ir-to-client-js/plan/build-static-array-child-init.d.ts.map +1 -1
  57. package/dist/ir-to-client-js/plan/static-array-child-init.d.ts +30 -18
  58. package/dist/ir-to-client-js/plan/static-array-child-init.d.ts.map +1 -1
  59. package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
  60. package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts +3 -2
  61. package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts.map +1 -1
  62. package/dist/jsx-to-ir.d.ts +1 -0
  63. package/dist/jsx-to-ir.d.ts.map +1 -1
  64. package/dist/nullable-signal-attr.d.ts +68 -9
  65. package/dist/nullable-signal-attr.d.ts.map +1 -1
  66. package/dist/prop-rewrite.d.ts +7 -0
  67. package/dist/prop-rewrite.d.ts.map +1 -1
  68. package/dist/props-object-whole-read.d.ts +15 -0
  69. package/dist/props-object-whole-read.d.ts.map +1 -0
  70. package/dist/rich-type-refusal.d.ts.map +1 -1
  71. package/dist/scope/binding-scope.d.ts +85 -10
  72. package/dist/scope/binding-scope.d.ts.map +1 -1
  73. package/dist/scope/lexical-scope-walk.d.ts +3 -2
  74. package/dist/scope/lexical-scope-walk.d.ts.map +1 -1
  75. package/dist/scope/root-prop-alias.d.ts +10 -7
  76. package/dist/scope/root-prop-alias.d.ts.map +1 -1
  77. package/dist/strip-types.d.ts +13 -0
  78. package/dist/strip-types.d.ts.map +1 -1
  79. package/dist/template-position-walk.d.ts +21 -3
  80. package/dist/template-position-walk.d.ts.map +1 -1
  81. package/dist/types.d.ts +90 -0
  82. package/dist/types.d.ts.map +1 -1
  83. package/package.json +2 -2
  84. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +3 -3
  85. package/src/__tests__/binding-scope.test.ts +89 -1
  86. package/src/__tests__/body-destructure-props-object-alias.test.ts +123 -0
  87. package/src/__tests__/boolean-result.test.ts +22 -5
  88. package/src/__tests__/brace-delimiter-text.test.ts +26 -0
  89. package/src/__tests__/callback-method.test.ts +62 -2
  90. package/src/__tests__/child-components-in-map.test.ts +1 -1
  91. package/src/__tests__/computed-const.test.ts +103 -0
  92. package/src/__tests__/emit-to-string-call.test.ts +2 -1
  93. package/src/__tests__/hydration-payload-analysis.test.ts +166 -0
  94. package/src/__tests__/issue-2724-prop-alias-loop-not-static.test.ts +7 -7
  95. package/src/__tests__/issue-2754-rest-spread-needs-slot.test.ts +5 -2
  96. package/src/__tests__/issue-2798-static-nested-loop-bindings.test.ts +1 -1
  97. package/src/__tests__/issue-2835-props-type-member-name-collision.test.ts +4 -4
  98. package/src/__tests__/issue-3044-nested-prop-object-array-not-static.test.ts +1 -1
  99. package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +2 -1
  100. package/src/__tests__/issue-3713-props-spread-loop-row.test.ts +65 -0
  101. package/src/__tests__/lookup-literal-const.test.ts +9 -3
  102. package/src/__tests__/loop-index-reactivity.test.ts +2 -2
  103. package/src/__tests__/loop-param-accessor-key-member-safety.test.ts +1 -1
  104. package/src/__tests__/loop-plan.test.ts +1 -1
  105. package/src/__tests__/loop-row-const-initializer-shadow.test.ts +146 -0
  106. package/src/__tests__/loop-row-type.test.ts +64 -0
  107. package/src/__tests__/lowering-value-position.test.ts +4 -0
  108. package/src/__tests__/module-const-destructure-default.test.ts +156 -0
  109. package/src/__tests__/nested-loop-index-param.test.ts +1 -1
  110. package/src/__tests__/nested-loop-reactive-attrs.test.ts +2 -2
  111. package/src/__tests__/nested-row-shadowing.test.ts +2 -2
  112. package/src/__tests__/nil-reading.test.ts +77 -0
  113. package/src/__tests__/nullable-signal-attr.test.ts +134 -0
  114. package/src/__tests__/primitive-plan.test.ts +416 -0
  115. package/src/__tests__/profile-loop-binding-ids.test.ts +2 -2
  116. package/src/__tests__/profile-nested-binding-ids.test.ts +2 -2
  117. package/src/__tests__/props-object-whole-read.test.ts +40 -0
  118. package/src/__tests__/reactive-attrs-in-map.test.ts +1 -1
  119. package/src/__tests__/reactive-factory-inlining.test.ts +4 -1
  120. package/src/__tests__/rest-binding-gaps.test.ts +192 -0
  121. package/src/__tests__/root-prop-alias.test.ts +53 -8
  122. package/src/__tests__/static-loop-csr-materialize.test.ts +2 -2
  123. package/src/__tests__/static-record-literal-array.test.ts +171 -0
  124. package/src/__tests__/string-concat-identifier.test.ts +40 -1
  125. package/src/adapters/ambiguous-nil-arithmetic.ts +22 -13
  126. package/src/adapters/boolean-result.ts +72 -66
  127. package/src/adapters/brace-delimiter-text.ts +25 -0
  128. package/src/adapters/callback-method.ts +151 -27
  129. package/src/adapters/computed-const.ts +238 -4
  130. package/src/adapters/dsl-template-adapter.ts +40 -2
  131. package/src/adapters/loop-bound-names.ts +9 -1
  132. package/src/adapters/loop-plan.ts +1 -1
  133. package/src/adapters/loop-row-type.ts +139 -0
  134. package/src/adapters/nil-reading.ts +297 -0
  135. package/src/adapters/non-primitive-equality.ts +92 -0
  136. package/src/adapters/number-value.ts +17 -4
  137. package/src/adapters/operand-typing.ts +522 -0
  138. package/src/adapters/parsed-expr-emitter.ts +154 -19
  139. package/src/adapters/primitive-plan.ts +696 -0
  140. package/src/analyzer-context.ts +6 -0
  141. package/src/analyzer.ts +505 -19
  142. package/src/augment-inherited-props.ts +108 -10
  143. package/src/compiler.ts +17 -0
  144. package/src/event-handler-name.ts +15 -0
  145. package/src/expression-parser.ts +70 -1
  146. package/src/index.ts +33 -7
  147. package/src/ir-to-client-js/build-references.ts +69 -0
  148. package/src/ir-to-client-js/child-props-object.ts +106 -0
  149. package/src/ir-to-client-js/collect-elements.ts +30 -55
  150. package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +6 -1
  151. package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +29 -28
  152. package/src/ir-to-client-js/control-flow/shared.ts +20 -22
  153. package/src/ir-to-client-js/control-flow/stringify/claim-plan.ts +5 -3
  154. package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +2 -2
  155. package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +1 -1
  156. package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +2 -2
  157. package/src/ir-to-client-js/control-flow/stringify/loop.ts +1 -1
  158. package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +3 -3
  159. package/src/ir-to-client-js/html-template.ts +25 -8
  160. package/src/ir-to-client-js/imports.ts +1 -1
  161. package/src/ir-to-client-js/index.ts +53 -11
  162. package/src/ir-to-client-js/plan/build-static-array-child-init.ts +31 -14
  163. package/src/ir-to-client-js/plan/static-array-child-init.ts +27 -18
  164. package/src/ir-to-client-js/prop-handling.ts +22 -3
  165. package/src/ir-to-client-js/stringify/static-array-child-init.ts +26 -10
  166. package/src/jsx-to-ir.ts +446 -37
  167. package/src/nullable-signal-attr.ts +246 -29
  168. package/src/prop-rewrite.ts +30 -6
  169. package/src/props-object-whole-read.ts +87 -0
  170. package/src/rich-type-refusal.ts +2 -1
  171. package/src/scope/binding-scope.ts +182 -18
  172. package/src/scope/lexical-scope-walk.ts +4 -3
  173. package/src/scope/root-prop-alias.ts +15 -8
  174. package/src/strip-types.ts +31 -3
  175. package/src/template-position-walk.ts +57 -28
  176. package/src/types.ts +87 -0
package/src/jsx-to-ir.ts CHANGED
@@ -43,15 +43,18 @@ import {
43
43
  AttrValueOf,
44
44
  } from './types.ts'
45
45
  import { type AnalyzerContext, type MultiReturnJsxInfo, getSourceLocation, collectReactiveGetterNames, tsTypeToTypeInfo } from './analyzer-context.ts'
46
- import { parseExpression, isSupported, parseBlockBody, foldBlockToExpr, predicateTernaryToLogical, tsNodeToParsedExpr, sortComparatorFromArrow, stringifyParsedExpr, cssKebabCase, CALLBACK_METHODS, unboundCallbackParamRead, unboundCallbackParamReason, type ParsedExpr } from './expression-parser.ts'
46
+ import { parseExpression, freeIdentifiers, isSupported, parseBlockBody, foldBlockToExpr, predicateTernaryToLogical, tsNodeToParsedExpr, sortComparatorFromArrow, stringifyParsedExpr, cssKebabCase, CALLBACK_METHODS, unboundCallbackParamRead, unboundCallbackParamReason, type ParsedExpr } from './expression-parser.ts'
47
47
  import { fallbackChainParts, nullishChainParts } from './children-nullish.ts'
48
- import type { IRLoopSort, FunctionInfo, ConstantInfo, ParamInfo, FreeReference } from './types.ts'
48
+ import type { IRLoopSort, FunctionInfo, ConstantInfo, ParamInfo, FreeReference, SpreadAttr, JsSourceText } from './types.ts'
49
+ import { resolveStaticConstBinding } from './augment-inherited-props.ts'
50
+ import { componentScopeNames } from './adapters/computed-const.ts'
49
51
  import { formatParamWithType } from './module-exports.ts'
50
52
  import { createError, ErrorCodes, internalInvariant } from './errors.ts'
51
53
  import { CLIENT_BUILTIN_SOURCE, isClientBuiltinName, type ClientBuiltinTag } from './builtins.ts'
52
54
  import { containsReactiveExpression, collectReactiveBrandLeaves } from './reactivity-checker.ts'
53
55
  import {
54
56
  rewriteBarePropRefs as rewriteBarePropRefsCore,
57
+ rewriteBarePropRefsStructural as rewriteBarePropRefsStructuralCore,
55
58
  collectAstPropRefs,
56
59
  rewriteScopedValueRefs,
57
60
  } from './prop-rewrite.ts'
@@ -624,6 +627,24 @@ function lowerToLocaleDateCalls(text: string, expr: ts.Node, ctx: TransformConte
624
627
  * Returns undefined if no rewriting is needed (SolidJS-style or no props).
625
628
  */
626
629
  function rewriteBarePropRefs(text: string, expr: ts.Node, ctx: TransformContext): string | undefined {
630
+ return rewriteBarePropRefsVia(text, expr, ctx, rewriteBarePropRefsCore) ?? undefined
631
+ }
632
+
633
+ /**
634
+ * `rewriteBarePropRefs` with no regex fallback (#3845): `null` when `text`
635
+ * does not parse as an expression, for a caller that refuses the shape
636
+ * rather than emit a scope-blind splice.
637
+ */
638
+ function rewriteBarePropRefsStructural(text: string, expr: ts.Node, ctx: TransformContext): string | undefined | null {
639
+ return rewriteBarePropRefsVia(text, expr, ctx, rewriteBarePropRefsStructuralCore)
640
+ }
641
+
642
+ function rewriteBarePropRefsVia(
643
+ text: string,
644
+ expr: ts.Node,
645
+ ctx: TransformContext,
646
+ core: typeof rewriteBarePropRefsStructuralCore,
647
+ ): string | undefined | null {
627
648
  // #2292: lower a Date-typed prop's catalogued accessor call BEFORE the
628
649
  // bare-prop-name rewrite below, so the receiver identifier still picks
629
650
  // up the usual `_p.` prefix (destructured mode) or falls through to the
@@ -676,7 +697,7 @@ function rewriteBarePropRefs(text: string, expr: ts.Node, ctx: TransformContext)
676
697
  return info ? livePropReadExpr(info, undefined, false) : `${PROPS_PARAM}.${callerKey}`
677
698
  }
678
699
  : undefined
679
- return rewriteBarePropRefsCore(dateLowered, expr, propNames, extraPropRefs, propAliases ?? undefined, replacementFor)
700
+ return core(dateLowered, expr, propNames, extraPropRefs, propAliases ?? undefined, replacementFor)
680
701
  }
681
702
 
682
703
  /**
@@ -3990,6 +4011,7 @@ type FilterPredicateResult = {
3990
4011
  param: string
3991
4012
  predicate?: ParsedExpr
3992
4013
  raw: string
4014
+ templateRaw?: string
3993
4015
  }
3994
4016
 
3995
4017
  /**
@@ -4085,7 +4107,7 @@ function extractFilterPredicate(
4085
4107
  }
4086
4108
  const unbound = unboundFilterParamReason(callback, predicate, ctx)
4087
4109
  if (unbound) return { result: null, unsupportedReason: unbound }
4088
- return { result: { param, predicate, raw } }
4110
+ return withTemplatePredicate({ param, predicate, raw }, callback, ctx)
4089
4111
  }
4090
4112
 
4091
4113
  // Expression body: filter(t => !t.done)
@@ -4100,7 +4122,53 @@ function extractFilterPredicate(
4100
4122
  const unbound = unboundFilterParamReason(callback, predicate, ctx)
4101
4123
  if (unbound) return { result: null, unsupportedReason: unbound }
4102
4124
 
4103
- return { result: { param, predicate, raw } }
4125
+ return withTemplatePredicate({ param, predicate, raw }, callback, ctx)
4126
+ }
4127
+
4128
+ /**
4129
+ * Attach the predicate's client-template text (`templateRaw`, #3845): `raw`
4130
+ * with each destructured-prop read rewritten to `_p.<key>`, the same rewrite
4131
+ * `templateArray` gets. The predicate's own parameters are bound for the
4132
+ * rewrite, so `filter((one) => one)` keeps its parameter even when a prop is
4133
+ * named `one`.
4134
+ *
4135
+ * The rewrite is structural only. A block body is rewritten as the body of
4136
+ * an arrow (`() => { … }`), so its `let` / `const` shadow a prop for their
4137
+ * block and a `var` for the whole body (`walkWithScope`). The regex fallback
4138
+ * is never used: it cannot see an inner binding and would turn
4139
+ * `const one = 'a'` into `const _p.one = 'a'`. A text that does not parse is
4140
+ * refused as off-subset, like any other predicate the compiler cannot
4141
+ * model.
4142
+ */
4143
+ function withTemplatePredicate(
4144
+ result: FilterPredicateResult,
4145
+ callback: ts.ArrowFunction,
4146
+ ctx: TransformContext,
4147
+ ): FilterExtractionResult {
4148
+ const savedScope = ctx.scope
4149
+ const params = new Set<string>()
4150
+ for (const p of callback.parameters) collectBindingNames(p.name, params)
4151
+ ctx.scope = savedScope.enterCallback([...params])
4152
+ try {
4153
+ const templateRaw = rewritePredicateBody(result.raw, callback.body, ctx)
4154
+ if (templateRaw === null) {
4155
+ return { result: null, unsupportedReason: 'Filter predicate cannot be rewritten for the client template' }
4156
+ }
4157
+ return { result: templateRaw === undefined ? result : { ...result, templateRaw } }
4158
+ } finally {
4159
+ ctx.scope = savedScope
4160
+ }
4161
+ }
4162
+
4163
+ /** Arrow head a block-bodied predicate is parsed under, so its body is a function body. */
4164
+ const BLOCK_PREDICATE_HEAD = '() => '
4165
+
4166
+ /** The structural prop rewrite of a predicate body: `null` when it cannot be done. */
4167
+ function rewritePredicateBody(raw: string, body: ts.ConciseBody, ctx: TransformContext): string | undefined | null {
4168
+ if (!ts.isBlock(body)) return rewriteBarePropRefsStructural(raw, body, ctx)
4169
+ const rewritten = rewriteBarePropRefsStructural(`${BLOCK_PREDICATE_HEAD}${raw}`, body, ctx)
4170
+ if (rewritten === undefined || rewritten === null) return rewritten
4171
+ return rewritten.startsWith(BLOCK_PREDICATE_HEAD) ? rewritten.slice(BLOCK_PREDICATE_HEAD.length) : null
4104
4172
  }
4105
4173
 
4106
4174
  /**
@@ -7236,44 +7304,60 @@ interface ProcessedAttributes {
7236
7304
  // runtime to spread at hydration time, which loses that per-key resolution
7237
7305
  // and is reserved for cases where the key set isn't statically known.
7238
7306
  //
7239
- // The `spreadExpr === restName` check is what restricts unrolling to the
7240
- // rest-prop itself: arbitrary `{...someObject}` spreads can't be unrolled
7241
- // because we don't have a static key list for them.
7307
+ // `closedRestSpreadSource` restricts unrolling to the rest-prop itself:
7308
+ // arbitrary `{...someObject}` spreads can't be unrolled because we don't
7309
+ // have a static key list for them.
7242
7310
  //
7243
7311
  // The shape returned satisfies both IRAttribute and IRProp.
7244
7312
  function expandSpreadAttribute(
7245
7313
  attr: ts.JsxSpreadAttribute,
7246
7314
  ctx: TransformContext,
7315
+ constEntries?: ReadonlyArray<{ key: string; text: string }>,
7316
+ restFallbacks?: ReadonlyMap<string, RestKeyFallback>,
7247
7317
  ): Array<{
7248
7318
  name: string
7249
7319
  value: AttrValue
7250
7320
  loc: SourceLocation
7251
7321
  freeIdentifiers?: ReadonlySet<string>
7252
7322
  restExpandedKey?: boolean
7323
+ restFallback?: JsSourceText
7253
7324
  }> {
7254
7325
  const spreadExpr = ctx.getJS(attr.expression)
7255
7326
  const expandedKeys = ctx.analyzer.restPropsExpandedKeys
7256
- const restName = ctx.analyzer.restPropsName
7257
7327
  const loc = getSourceLocation(attr, ctx.sourceFile, ctx.filePath)
7258
7328
  const spreadFreeIdentifiers = extractFreeIdentifiersFromNode(attr.expression)
7329
+ const source = closedRestSpreadSource(attr, ctx)
7330
+ if (source === null && refuseBodyRestSpreadUnderShadowedProps(attr, ctx)) return []
7259
7331
 
7260
- if (expandedKeys.length > 0 && restName && spreadExpr === restName) {
7332
+ if (source !== null) {
7261
7333
  // Expanded per-key attrs reference `${restName}.${key}` — `restName` is
7262
7334
  // the only free identifier (the `.${key}` tail is a member-access name,
7263
7335
  // not an identifier reference). `restExpandedKey` (#3057) marks these so
7264
7336
  // Phase 2 (`collectElements`) can bind them reactively off a live
7265
7337
  // `_p.<key>` read instead of the one-time `${restName}.${key}` snapshot
7266
- // — see `IRAttribute.restExpandedKey`'s docstring.
7267
- const perKeyFreeIds: ReadonlySet<string> = new Set([restName])
7268
- return expandedKeys.map(key => ({
7269
- name: key,
7270
- value: AttrValueOf.expression(`${restName}.${key}`),
7271
- loc,
7272
- freeIdentifiers: perKeyFreeIds,
7273
- restExpandedKey: true,
7274
- }))
7338
+ // — see `IRAttribute.restExpandedKey`'s docstring. `source` is the
7339
+ // props object for a body rest (`closedRestSpreadSource`). A key an
7340
+ // earlier attribute also writes keeps that value when the caller
7341
+ // omitted it (`restFallbacks`, {@link closedRestFallbacks}).
7342
+ const perKeyFreeIds: ReadonlySet<string> = new Set([source])
7343
+ return expandedKeys.map(key => {
7344
+ const read = `${source}.${key}`
7345
+ const fallback = restFallbacks?.get(key)
7346
+ return {
7347
+ name: key,
7348
+ value: fallback === undefined
7349
+ ? AttrValueOf.expression(read)
7350
+ : AttrValueOf.expression(restKeyWithFallback(read, fallback.text), { templateExpr: restKeyWithFallback(read, fallback.templateText) }),
7351
+ loc,
7352
+ freeIdentifiers: fallback === undefined ? perKeyFreeIds : new Set([source, ...fallback.freeIdentifiers]),
7353
+ restExpandedKey: true,
7354
+ ...(fallback !== undefined && { restFallback: fallback.templateText }),
7355
+ }
7356
+ })
7275
7357
  }
7276
7358
 
7359
+ if (constEntries) return constEntries.map(({ key, text }) => ({ name: key, value: AttrValueOf.expression(text), loc }))
7360
+
7277
7361
  // Allocate a component-scoped slot ID so adapters that need a
7278
7362
  // structured plumbing path (Go's `.Spread_N` struct field) can
7279
7363
  // address this spread without recomputing identity downstream
@@ -7281,14 +7365,341 @@ function expandSpreadAttribute(
7281
7365
  // it. The closed-type expansion branch above returns before this
7282
7366
  // point, so closed-type rest spreads stay on the per-key fast path.
7283
7367
  const slotId = generateSpreadSlotId(ctx)
7368
+ const value = AttrValueOf.spread(spreadExpr, ctx.getTemplateJS(attr.expression), slotId)
7369
+ const callerBag = callerBagOfSpread(value, ctx)
7284
7370
  return [{
7285
7371
  name: '...',
7286
- value: AttrValueOf.spread(spreadExpr, ctx.getTemplateJS(attr.expression), slotId),
7372
+ value: callerBag ? { ...value, callerBag } : value,
7287
7373
  loc,
7288
7374
  freeIdentifiers: spreadFreeIdentifiers,
7289
7375
  }]
7290
7376
  }
7291
7377
 
7378
+ /**
7379
+ * The name each key of a closed-type rest spread (`{...rest}` with a
7380
+ * statically known key set, `IRMetadata.restPropsExpandedKeys`) is read
7381
+ * off, or null when `attr` is not one. A rest a body destructure of the
7382
+ * props object binds (`const { label, ...rest } = props`) holds the props
7383
+ * object's keys minus the ones the destructure takes, so its keys read the
7384
+ * props object (#3844): a template binds every declared prop as its own
7385
+ * variable, while its rest bag holds only undeclared keys. A loop row or
7386
+ * callback parameter spelled like the rest binding is that binding, not
7387
+ * the component's rest props (#3851).
7388
+ */
7389
+ function closedRestSpreadSource(attr: ts.JsxSpreadAttribute, ctx: TransformContext): string | null {
7390
+ const restName = ctx.analyzer.restPropsName
7391
+ if (ctx.analyzer.restPropsExpandedKeys.length === 0 || !restName || ctx.scope.isBound(restName)) return null
7392
+ let expr: ts.Expression = attr.expression
7393
+ while (ts.isParenthesizedExpression(expr)) expr = expr.expression
7394
+ if (!ts.isIdentifier(expr) || expr.text !== restName) return null
7395
+ const source = ctx.analyzer.restPropsOmittedKeys && ctx.analyzer.propsObjectName ? ctx.analyzer.propsObjectName : restName
7396
+ // A body rest's keys read the props object, which a loop row or callback
7397
+ // parameter of the same name hides here: no spelling of the per-key read
7398
+ // reaches the component's props (`expandSpreadAttribute` refuses it).
7399
+ return source !== restName && ctx.scope.isBound(source) ? null : source
7400
+ }
7401
+
7402
+ /**
7403
+ * BF101 for a spread of a props-object body rest (`const { a, ...rest } =
7404
+ * props`) where a loop row or callback parameter shadows the props
7405
+ * object's name (`rows.map(props => <li {...rest} />)`): its keys are read
7406
+ * off the props object, which that binding hides (#3854).
7407
+ */
7408
+ function refuseBodyRestSpreadUnderShadowedProps(attr: ts.JsxSpreadAttribute, ctx: TransformContext): boolean {
7409
+ const restName = ctx.analyzer.restPropsName
7410
+ const propsName = ctx.analyzer.propsObjectName
7411
+ if (!restName || !propsName || !ctx.analyzer.restPropsOmittedKeys || ctx.analyzer.restPropsExpandedKeys.length === 0) return false
7412
+ if (ctx.scope.isBound(restName) || !ctx.scope.isBound(propsName)) return false
7413
+ let expr: ts.Expression = attr.expression
7414
+ while (ts.isParenthesizedExpression(expr)) expr = expr.expression
7415
+ if (!ts.isIdentifier(expr) || expr.text !== restName) return false
7416
+ ctx.analyzer.errors.push({
7417
+ code: 'BF101',
7418
+ severity: 'error',
7419
+ message: `\`{...${restName}}\` spreads the component's props through a rest, inside a binding that shadows the props object's name \`${propsName}\`, so its keys have no spelling that reaches the component's props.`,
7420
+ loc: getSourceLocation(attr, ctx.sourceFile, ctx.filePath),
7421
+ suggestion: { message: `Rename the inner \`${propsName}\` binding.` },
7422
+ })
7423
+ return true
7424
+ }
7425
+
7426
+ /**
7427
+ * What a closed-type rest spread's keys fall back to (#3851). JSX applies
7428
+ * attributes and spreads in order, and a spread overrides only with the
7429
+ * keys its object has: `<Chip tone="x" {...rest} />` keeps `tone="x"` when
7430
+ * the caller omitted `tone`. A closed rest spread is expanded into one
7431
+ * attribute per key the props type declares, so each key an earlier
7432
+ * attribute (or an expanded const spread) writes reads `rest.key ??
7433
+ * (earlier)` instead ({@link restKeyWithFallback}), and the earlier explicit
7434
+ * attribute is dropped: the expanded key now carries both values.
7435
+ *
7436
+ * `fallbacks` maps each closed rest spread to its keys' fallback sources,
7437
+ * and `properties` is `properties` without the dropped attributes. An
7438
+ * earlier value that has no source form (a JSX element prop) or may have an
7439
+ * effect (`isReadOnlyAttrValue`) is refused with BF021. `ref`, `key` and
7440
+ * event handlers are not attribute writes and are left as they are; an
7441
+ * open spread (`{...obj}`) writes keys nothing knows statically, so no
7442
+ * fallback reaches across it.
7443
+ */
7444
+ function closedRestFallbacks(
7445
+ properties: readonly ts.JsxAttributeLike[],
7446
+ entries: ReadonlyMap<ts.JsxSpreadAttribute, ReadonlyArray<{ key: string; text: string }>>,
7447
+ ctx: TransformContext,
7448
+ ): { properties: ts.JsxAttributeLike[]; fallbacks: Map<ts.JsxSpreadAttribute, Map<string, RestKeyFallback>> } {
7449
+ const fallbacks = new Map<ts.JsxSpreadAttribute, Map<string, RestKeyFallback>>()
7450
+ const dropped = new Set<ts.JsxAttributeLike>()
7451
+ const lastWrite = new Map<string, KeyWrite>()
7452
+ for (const attr of properties) {
7453
+ if (ts.isJsxAttribute(attr)) {
7454
+ const name = attr.name.getText(ctx.sourceFile)
7455
+ if (name !== 'ref' && name !== 'key' && !isEventHandlerName(name)) lastWrite.set(name, { attr, value: attrValueFallback(attr, ctx) })
7456
+ continue
7457
+ }
7458
+ if (!ts.isJsxSpreadAttribute(attr)) continue
7459
+ const constEntries = entries.get(attr)
7460
+ const source = constEntries ? null : closedRestSpreadSource(attr, ctx)
7461
+ if (constEntries) {
7462
+ for (const e of constEntries) lastWrite.set(e.key, { value: { text: e.text, templateText: e.text, freeIdentifiers: new Set() } })
7463
+ } else if (source === null) {
7464
+ lastWrite.clear()
7465
+ } else {
7466
+ const keyFallbacks = closedRestKeyFallbacks(attr, source, lastWrite, dropped, ctx)
7467
+ if (keyFallbacks.size > 0) fallbacks.set(attr, keyFallbacks)
7468
+ }
7469
+ }
7470
+ return { properties: properties.filter(attr => !dropped.has(attr)), fallbacks }
7471
+ }
7472
+
7473
+ /** {@link closedRestFallbacks} for one closed rest spread reading its keys off `source`. */
7474
+ function closedRestKeyFallbacks(
7475
+ attr: ts.JsxSpreadAttribute,
7476
+ source: string,
7477
+ lastWrite: Map<string, KeyWrite>,
7478
+ dropped: Set<ts.JsxAttributeLike>,
7479
+ ctx: TransformContext,
7480
+ ): Map<string, RestKeyFallback> {
7481
+ const keyFallbacks = new Map<string, RestKeyFallback>()
7482
+ for (const key of ctx.analyzer.restPropsExpandedKeys) {
7483
+ const read = `${source}.${key}`
7484
+ const earlier = lastWrite.get(key)
7485
+ lastWrite.set(key, { value: { text: read, templateText: read, freeIdentifiers: new Set([source]) } })
7486
+ if (!earlier) continue
7487
+ if (earlier.value === null || (earlier.attr && !isReadOnlyAttrValue(earlier.attr.initializer))) {
7488
+ const why = earlier.value === null ? 'its value has no expression form to keep' : 'its value may have an effect, which JS runs exactly once'
7489
+ ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_JSX_PATTERN, getSourceLocation(earlier.attr ?? attr, ctx.sourceFile, ctx.filePath), {
7490
+ message: `'${key}' is written before a {...${ctx.getJS(attr.expression)}} spread that may also carry it, and ${why} when the caller omits '${key}'.`,
7491
+ suggestion: { message: `Write '${key}' after the spread, or compute the value in a local const and pass that.` },
7492
+ }))
7493
+ continue
7494
+ }
7495
+ keyFallbacks.set(key, earlier.value)
7496
+ lastWrite.set(key, {
7497
+ value: {
7498
+ text: restKeyWithFallback(read, earlier.value.text),
7499
+ templateText: restKeyWithFallback(read, earlier.value.templateText),
7500
+ freeIdentifiers: new Set([source, ...earlier.value.freeIdentifiers]),
7501
+ },
7502
+ })
7503
+ if (earlier.attr) dropped.add(earlier.attr)
7504
+ }
7505
+ return keyFallbacks
7506
+ }
7507
+
7508
+ /** A value a closed rest spread's key falls back to ({@link closedRestFallbacks}): its source text and free names. */
7509
+ interface RestKeyFallback {
7510
+ text: string
7511
+ /** `text` as a client-JS template reads it (`TransformContext.getTemplateJS`). */
7512
+ templateText: string
7513
+ freeIdentifiers: ReadonlySet<string>
7514
+ }
7515
+
7516
+ /** The last write of a key before a spread: the explicit attribute that made it, if any, and its value (null when it has no expression form). */
7517
+ interface KeyWrite {
7518
+ attr?: ts.JsxAttribute
7519
+ value: RestKeyFallback | null
7520
+ }
7521
+
7522
+ /**
7523
+ * `read`, or `fallback` when the key `read` reads is absent. A caller's
7524
+ * explicit `null` reads as absent too, as everywhere a template tests
7525
+ * whether a spread carries a key: no template backend tells the two apart.
7526
+ */
7527
+ function restKeyWithFallback(read: string, fallback: string): string {
7528
+ return `${read} ?? (${fallback})`
7529
+ }
7530
+
7531
+ /**
7532
+ * A JSX attribute's value as a fallback of a later closed rest spread
7533
+ * ({@link closedRestFallbacks}): `true` for a bare attribute, the string
7534
+ * literal, or the expression. Null for a value with no expression form (a
7535
+ * JSX element, an empty `{}`).
7536
+ */
7537
+ function attrValueFallback(attr: ts.JsxAttribute, ctx: TransformContext): RestKeyFallback | null {
7538
+ const value = attr.initializer
7539
+ if (value === undefined) return { text: 'true', templateText: 'true', freeIdentifiers: new Set() }
7540
+ if (ts.isStringLiteral(value)) {
7541
+ const text = JSON.stringify(value.text)
7542
+ return { text, templateText: text, freeIdentifiers: new Set() }
7543
+ }
7544
+ if (!ts.isJsxExpression(value) || value.expression === undefined) return null
7545
+ const expr = unwrapTransparentTsWrappers(value.expression)
7546
+ if (ts.isJsxElement(expr) || ts.isJsxSelfClosingElement(expr) || ts.isJsxFragment(expr)) return null
7547
+ return {
7548
+ text: ctx.getJS(value.expression),
7549
+ templateText: ctx.getTemplateJS(value.expression),
7550
+ freeIdentifiers: extractFreeIdentifiersFromNode(value.expression),
7551
+ }
7552
+ }
7553
+
7554
+ /**
7555
+ * How an element's or component call's static const spreads resolve
7556
+ * against everything else it is given (#3844): `entries` maps each spread
7557
+ * of a const holding a static object literal to the `key: value-source`
7558
+ * pairs it passes, and `properties` is the attribute list without the
7559
+ * explicit attributes such a spread overrides.
7560
+ *
7561
+ * JSX applies attributes and spreads in order and the last write of a key
7562
+ * wins, so the plan walks them from the last: a key an explicit attribute
7563
+ * or an expanded spread writes is dropped from every earlier explicit
7564
+ * attribute and expanded spread. A spread that is not expanded (`{...rest}`,
7565
+ * a computed object) overrides nothing statically; what it holds is merged
7566
+ * at render time after what comes before it, as before. Each key is
7567
+ * therefore written once, with the value JS gives it. When an overridden
7568
+ * attribute's value may have an effect, nothing is expanded (see the end
7569
+ * of the function).
7570
+ */
7571
+ function staticSpreadPlan(attributes: ts.JsxAttributes, ctx: TransformContext): {
7572
+ properties: ts.JsxAttributeLike[]
7573
+ entries: Map<ts.JsxSpreadAttribute, Array<{ key: string; text: string }>>
7574
+ } {
7575
+ const entries = new Map<ts.JsxSpreadAttribute, Array<{ key: string; text: string }>>()
7576
+ const overridden = new Set<ts.JsxAttributeLike>()
7577
+ const written = new Set<string>()
7578
+ for (const attr of [...attributes.properties].reverse()) {
7579
+ if (ts.isJsxAttribute(attr)) {
7580
+ const name = attr.name.getText(ctx.sourceFile)
7581
+ if (written.has(name)) overridden.add(attr)
7582
+ written.add(name)
7583
+ continue
7584
+ }
7585
+ const spread = expandStaticConstSpread(attr, ctx)
7586
+ if (!spread) continue
7587
+ entries.set(attr, spread.filter(e => !written.has(e.key)))
7588
+ for (const e of spread) written.add(e.key)
7589
+ }
7590
+ // Dropping an overridden attribute drops the evaluation of its value. JS
7591
+ // still evaluates it, so a value that may have an effect (a call, an
7592
+ // assignment) keeps every spread of the element a spread, merged in order
7593
+ // at render time.
7594
+ if ([...overridden].some(attr => !ts.isJsxAttribute(attr) || !isEffectFreeAttrValue(attr.initializer))) {
7595
+ return { properties: [...attributes.properties], entries: new Map() }
7596
+ }
7597
+ return { properties: attributes.properties.filter(attr => !overridden.has(attr)), entries }
7598
+ }
7599
+
7600
+ /**
7601
+ * Whether evaluating a JSX attribute's value can have no effect: no value
7602
+ * (`disabled`), a string, or an expression {@link isEffectFreeExpression}
7603
+ * accepts.
7604
+ */
7605
+ function isEffectFreeAttrValue(value: ts.JsxAttributeValue | undefined): boolean {
7606
+ if (value === undefined || ts.isStringLiteral(value)) return true
7607
+ if (!ts.isJsxExpression(value)) return false
7608
+ return value.expression === undefined || isEffectFreeExpression(value.expression)
7609
+ }
7610
+
7611
+ /**
7612
+ * Whether a JSX attribute's value reads without an effect for a closed
7613
+ * rest spread's fallback ({@link closedRestFallbacks}), which evaluates it
7614
+ * only when the caller omits the key: an {@link isEffectFreeAttrValue}
7615
+ * value, or a member read off a name (`props.title`, `row?.label`). A prop
7616
+ * or row read has no effect the render can observe; anything else (a call,
7617
+ * an assignment) is refused, since JS evaluates it exactly once.
7618
+ */
7619
+ function isReadOnlyAttrValue(value: ts.JsxAttributeValue | undefined): boolean {
7620
+ if (isEffectFreeAttrValue(value)) return true
7621
+ if (value === undefined || !ts.isJsxExpression(value) || value.expression === undefined) return false
7622
+ let expr: ts.Expression = value.expression
7623
+ while (ts.isParenthesizedExpression(expr) || ts.isPropertyAccessExpression(expr)) expr = expr.expression
7624
+ return ts.isIdentifier(expr)
7625
+ }
7626
+
7627
+ /**
7628
+ * A literal (string, number, boolean, `null`, a template literal without
7629
+ * substitutions, a negated number) or a plain name (`label`), possibly
7630
+ * parenthesized. Anything else is treated as possibly having an effect: a
7631
+ * call, an assignment, `new`, an operator, and also a member access
7632
+ * (`props.value.title`), which can run a getter.
7633
+ */
7634
+ function isEffectFreeExpression(expr: ts.Expression): boolean {
7635
+ if (ts.isParenthesizedExpression(expr)) return isEffectFreeExpression(expr.expression)
7636
+ if (ts.isStringLiteral(expr) || ts.isNumericLiteral(expr) || ts.isNoSubstitutionTemplateLiteral(expr) || ts.isIdentifier(expr)) return true
7637
+ if (expr.kind === ts.SyntaxKind.TrueKeyword || expr.kind === ts.SyntaxKind.FalseKeyword || expr.kind === ts.SyntaxKind.NullKeyword) return true
7638
+ if (ts.isPrefixUnaryExpression(expr) && expr.operator === ts.SyntaxKind.MinusToken) return ts.isNumericLiteral(expr.operand)
7639
+ return false
7640
+ }
7641
+
7642
+ /**
7643
+ * The entries of a spread of a const holding a static object literal
7644
+ * (`const base = { label: 'x', tone: 'info' }`, `<Chip {...base} />`), as
7645
+ * the `key: value-source` pairs the spread passes, one per key with the
7646
+ * value of its last occurrence in the literal (#3844). Carried that way,
7647
+ * every backend reads each value as a literal instead of a bag no template
7648
+ * binds; {@link staticSpreadPlan} resolves them against the element's other
7649
+ * attributes.
7650
+ *
7651
+ * Only when the read reaches the const (`resolveStaticConstBinding`; a
7652
+ * module const also not shadowed by a component binding) and every entry
7653
+ * is a plain `key: value` whose value reads no name (a literal, or an array
7654
+ * or object of literals), and whose key is not `key`, `ref` or an event
7655
+ * handler name. `null` otherwise, and the spread stays a spread.
7656
+ */
7657
+ function expandStaticConstSpread(attr: ts.JsxSpreadAttribute, ctx: TransformContext): Array<{ key: string; text: string }> | null {
7658
+ let expr: ts.Expression = attr.expression
7659
+ while (ts.isParenthesizedExpression(expr)) expr = expr.expression
7660
+ if (!ts.isIdentifier(expr)) return null
7661
+ const name = expr.text
7662
+ const constant = resolveStaticConstBinding(name, ctx.analyzer.localConstants, n => ctx.scope.isBound(n))
7663
+ if (!constant || constant.parsed?.kind !== 'object-literal') return null
7664
+ if (constant.isModule && componentScopeNames(ctx.analyzer).has(name)) return null
7665
+ const init = parseConstInitializer(constant)
7666
+ if (!init || !ts.isObjectLiteralExpression(init)) return null
7667
+ return staticObjectSpreadEntries(init)
7668
+ }
7669
+
7670
+ /**
7671
+ * {@link expandStaticConstSpread}'s entries of the object literal `init`,
7672
+ * or `null` when one of them has no per-key form.
7673
+ */
7674
+ function staticObjectSpreadEntries(init: ts.ObjectLiteralExpression): Array<{ key: string; text: string }> | null {
7675
+ const entries = new Map<string, string>()
7676
+ for (const prop of init.properties) {
7677
+ if (!ts.isPropertyAssignment(prop)) return null
7678
+ const key = ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name) ? prop.name.text : null
7679
+ if (key === null || key === 'key' || key === 'ref' || isEventHandlerName(key)) return null
7680
+ if (freeIdentifiers(tsNodeToParsedExpr(prop.initializer))?.size !== 0) return null
7681
+ entries.set(key, astText(prop.initializer))
7682
+ }
7683
+ return [...entries].map(([key, text]) => ({ key, text }))
7684
+ }
7685
+
7686
+ /**
7687
+ * Which caller prop bag a spread forwards whole (`SpreadAttr.callerBag`):
7688
+ * its `expr` / `templateExpr` resolved through any alias hop
7689
+ * (`resolveRestSpreadOriginCore`). A name an enclosing loop row or callback
7690
+ * binds is that binding, not the component's bag (#3713: `items.map((props)
7691
+ * => <Tag {...props} />)`).
7692
+ */
7693
+ function callerBagOfSpread(value: SpreadAttr, ctx: TransformContext): 'props' | 'rest' | undefined {
7694
+ const constants = constantValuesByName(ctx)
7695
+ for (const name of new Set([value.expr, value.templateExpr])) {
7696
+ if (!name || ctx.scope.isBound(name)) continue
7697
+ const origin = resolveRestSpreadOriginCore(ctx.analyzer, constants, name)
7698
+ if (origin !== null) return origin
7699
+ }
7700
+ return undefined
7701
+ }
7702
+
7292
7703
  // Extract free identifiers from an attribute's initializer expression
7293
7704
  // (#1267). Returns undefined for boolean shorthand / string-literal attrs
7294
7705
  // that have no expression. Downstream callers can ask
@@ -7377,11 +7788,13 @@ function processAttributes(
7377
7788
  let ref: string | null = null
7378
7789
  let refExpr: ts.Expression | null = null
7379
7790
  let hasSpread = false
7791
+ const spreadPlan = staticSpreadPlan(attributes, ctx)
7792
+ const restPlan = closedRestFallbacks(spreadPlan.properties, spreadPlan.entries, ctx)
7380
7793
 
7381
- for (const attr of attributes.properties) {
7794
+ for (const attr of restPlan.properties) {
7382
7795
  if (ts.isJsxSpreadAttribute(attr)) {
7383
7796
  hasSpread = true
7384
- attrs.push(...expandSpreadAttribute(attr, ctx))
7797
+ attrs.push(...expandSpreadAttribute(attr, ctx, spreadPlan.entries.get(attr), restPlan.fallbacks.get(attr)))
7385
7798
  continue
7386
7799
  }
7387
7800
 
@@ -9033,8 +9446,10 @@ function processComponentProps(
9033
9446
  ctx: TransformContext
9034
9447
  ): IRProp[] {
9035
9448
  const props: IRProp[] = []
9449
+ const spreadPlan = staticSpreadPlan(attributes, ctx)
9450
+ const restPlan = closedRestFallbacks(spreadPlan.properties, spreadPlan.entries, ctx)
9036
9451
 
9037
- for (const attr of attributes.properties) {
9452
+ for (const attr of restPlan.properties) {
9038
9453
  if (ts.isJsxSpreadAttribute(attr)) {
9039
9454
  // `restExpandedKey` (#3057) is consumed only by the element-attribute
9040
9455
  // path (`collect-elements.ts`'s `attr.restExpandedKey` branch) — a
@@ -9043,7 +9458,7 @@ function processComponentProps(
9043
9458
  // rewrite, so `IRProp` declares no such field. Strip it here rather
9044
9459
  // than letting the shared helper's per-key marking leak into IRProp
9045
9460
  // as an inert flag nothing reads.
9046
- props.push(...expandSpreadAttribute(attr, ctx).map(({ restExpandedKey: _restExpandedKey, ...prop }) => markPropsObjectSpread(prop, ctx)))
9461
+ props.push(...expandSpreadAttribute(attr, ctx, spreadPlan.entries.get(attr), restPlan.fallbacks.get(attr)).map(({ restExpandedKey: _restExpandedKey, restFallback: _restFallback, ...prop }) => markPropsObjectSpread(prop)))
9047
9462
  continue
9048
9463
  }
9049
9464
 
@@ -9852,21 +10267,15 @@ function forwardsCallerRestProps(attrs: IRAttribute[], ctx: TransformContext): b
9852
10267
 
9853
10268
  /**
9854
10269
  * Mark a child-component spread of the component's own props object
9855
- * (`SpreadAttr.propsObject`, #3688). Resolved with the same rule — and the
9856
- * same `expr` / `templateExpr` pair — as `forwardsCallerRestProps`, narrowed
9857
- * to the `'props'` origin: a `{...rest}` bag leaves out the keys the
9858
- * component destructured, so it does not merge as the caller's props.
10270
+ * (`SpreadAttr.propsObject`, #3688): the `'props'` case of
10271
+ * `SpreadAttr.callerBag` (`callerBagOfSpread`). A `{...rest}` bag leaves out
10272
+ * the keys the component destructured, so it does not merge as the caller's
10273
+ * props.
9859
10274
  */
9860
- function markPropsObjectSpread<T extends { value: AttrValue }>(prop: T, ctx: TransformContext): T {
10275
+ function markPropsObjectSpread<T extends { value: AttrValue }>(prop: T): T {
9861
10276
  const value = prop.value
9862
- if (value.kind !== 'spread') return prop
9863
- const constants = constantValuesByName(ctx)
9864
- for (const name of new Set([value.expr, value.templateExpr])) {
9865
- if (name && resolveRestSpreadOriginCore(ctx.analyzer, constants, name) === 'props') {
9866
- return { ...prop, value: { ...value, propsObject: true } }
9867
- }
9868
- }
9869
- return prop
10277
+ if (value.kind !== 'spread' || value.callerBag !== 'props') return prop
10278
+ return { ...prop, value: { ...value, propsObject: true } }
9870
10279
  }
9871
10280
 
9872
10281
  /** `ctx.analyzer.localConstants` indexed by name → value text, memoized per component walk. */