@barefootjs/go-template 0.31.1 → 0.31.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/adapter/go-template-adapter.d.ts +49 -41
  2. package/dist/adapter/go-template-adapter.d.ts.map +1 -1
  3. package/dist/adapter/index.js +167 -101
  4. package/dist/adapter/lib/types.d.ts +4 -1
  5. package/dist/adapter/lib/types.d.ts.map +1 -1
  6. package/dist/adapter/memo/memo-compute.d.ts +9 -0
  7. package/dist/adapter/memo/memo-compute.d.ts.map +1 -1
  8. package/dist/adapter/memo/memo-type.d.ts +2 -0
  9. package/dist/adapter/memo/memo-type.d.ts.map +1 -1
  10. package/dist/adapter/props/prop-types.d.ts +2 -1
  11. package/dist/adapter/props/prop-types.d.ts.map +1 -1
  12. package/dist/adapter/spread/spread-codegen.d.ts.map +1 -1
  13. package/dist/adapter/type/type-codegen.d.ts +22 -5
  14. package/dist/adapter/type/type-codegen.d.ts.map +1 -1
  15. package/dist/adapter/value/parsed-literal-to-go.d.ts +12 -0
  16. package/dist/adapter/value/parsed-literal-to-go.d.ts.map +1 -1
  17. package/dist/adapter/value/value-lowering.d.ts +3 -0
  18. package/dist/adapter/value/value-lowering.d.ts.map +1 -1
  19. package/dist/index.js +168 -104
  20. package/dist/render-divergences.d.ts +6 -0
  21. package/dist/render-divergences.d.ts.map +1 -1
  22. package/dist/vite.js +574 -193
  23. package/package.json +5 -5
  24. package/src/__tests__/go-template-adapter.test.ts +155 -10
  25. package/src/adapter/go-template-adapter.ts +213 -128
  26. package/src/adapter/lib/types.ts +4 -1
  27. package/src/adapter/memo/memo-compute.ts +21 -17
  28. package/src/adapter/memo/memo-type.ts +5 -5
  29. package/src/adapter/props/prop-types.ts +6 -5
  30. package/src/adapter/spread/spread-codegen.ts +12 -5
  31. package/src/adapter/type/type-codegen.ts +86 -25
  32. package/src/adapter/value/parsed-literal-to-go.ts +28 -10
  33. package/src/adapter/value/value-lowering.ts +65 -29
  34. package/src/render-divergences.ts +6 -15
  35. package/src/test-render.ts +6 -1
package/dist/vite.js CHANGED
@@ -4,8 +4,11 @@ import { resolve } from "node:path";
4
4
  import { barefoot as coreBarefoot } from "@barefootjs/vite";
5
5
  import { devModuleUrl, loadManifest, resolveDevOrigin, resolveScriptAssets, toPosixRelative } from "@barefootjs/vite";
6
6
 
7
+ // ../jsx/src/compiler.ts
8
+ import ts23 from "typescript";
9
+
7
10
  // ../jsx/src/analyzer.ts
8
- import ts8 from "typescript";
11
+ import ts9 from "typescript";
9
12
 
10
13
  // ../jsx/src/expression-parser.ts
11
14
  import ts from "typescript";
@@ -1920,6 +1923,29 @@ import ts5 from "typescript";
1920
1923
  // ../jsx/src/ir-to-client-js/utils.ts
1921
1924
  import ts3 from "typescript";
1922
1925
 
1926
+ // ../jsx/src/template-parts.ts
1927
+ function lookupPartToJsExpr(part, opts) {
1928
+ const key = opts?.useTemplate && part.templateKey ? part.templateKey : part.key;
1929
+ const obj = "{" + Object.entries(part.cases).map(([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v)}`).join(", ") + "}";
1930
+ const typed = opts?.typed ? " as Record<string, string>" : "";
1931
+ return `(${obj}${typed})[${key}]`;
1932
+ }
1933
+ function templatePartsToJsExpr(parts, opts) {
1934
+ let result = "`";
1935
+ for (const part of parts) {
1936
+ if (part.type === "string") {
1937
+ result += opts?.useTemplate && part.templateValue ? part.templateValue : part.value;
1938
+ } else if (part.type === "ternary") {
1939
+ const cond = opts?.useTemplate && part.templateCondition ? part.templateCondition : part.condition;
1940
+ result += `\${${cond} ? '${part.whenTrue}' : '${part.whenFalse}'}`;
1941
+ } else if (part.type === "lookup") {
1942
+ result += `\${${lookupPartToJsExpr(part, opts)}}`;
1943
+ }
1944
+ }
1945
+ result += "`";
1946
+ return result;
1947
+ }
1948
+
1923
1949
  // ../jsx/src/scanner/js-scanner.ts
1924
1950
  import ts2 from "typescript";
1925
1951
  function* iterateJsTokens(text, start = 0, end = text.length) {
@@ -2098,6 +2124,16 @@ function escapeHtml(text) {
2098
2124
  }
2099
2125
  // ../jsx/src/ir-to-client-js/csr-substitute.ts
2100
2126
  import ts4 from "typescript";
2127
+ function extractFreeIdentifiersFromText(text) {
2128
+ if (!text || text.trim().length === 0)
2129
+ return new Set;
2130
+ const sf = ts4.createSourceFile("__free_ids__.ts", `(${text});`, ts4.ScriptTarget.Latest, true, ts4.ScriptKind.TS);
2131
+ const stmt = sf.statements[0];
2132
+ if (!stmt || !ts4.isExpressionStatement(stmt))
2133
+ return new Set;
2134
+ const expr = ts4.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
2135
+ return extractFreeIdentifiersFromNode(expr);
2136
+ }
2101
2137
 
2102
2138
  // ../jsx/src/ir-to-client-js/html-template.ts
2103
2139
  var VOID_ELEMENTS = new Set([
@@ -2143,6 +2179,27 @@ var SKELETON_PATH_FORCE_CLOSE_GROUPS = [
2143
2179
  new Set(["li"])
2144
2180
  ];
2145
2181
 
2182
+ // ../jsx/src/props-binding.ts
2183
+ import ts6 from "typescript";
2184
+ function isIdentifierName(key) {
2185
+ if (key.length === 0)
2186
+ return false;
2187
+ for (let i = 0;i < key.length; ) {
2188
+ const cp = key.codePointAt(i);
2189
+ const ok = i === 0 ? ts6.isIdentifierStart(cp, ts6.ScriptTarget.Latest) : ts6.isIdentifierPart(cp, ts6.ScriptTarget.Latest);
2190
+ if (!ok)
2191
+ return false;
2192
+ i += cp > 65535 ? 2 : 1;
2193
+ }
2194
+ return true;
2195
+ }
2196
+ function propsDestructureBinding(p) {
2197
+ const callerKey = p.sourceName ?? p.name;
2198
+ const localName = p.name;
2199
+ const binding = callerKey === localName ? localName : `${isIdentifierName(callerKey) ? callerKey : JSON.stringify(callerKey)}: ${localName}`;
2200
+ return p.defaultValue ? `${binding} = ${p.defaultValue}` : binding;
2201
+ }
2202
+
2146
2203
  // ../jsx/src/instrumentation.ts
2147
2204
  var _counters = freshCounters();
2148
2205
  function freshCounters() {
@@ -2156,14 +2213,14 @@ function freshCounters() {
2156
2213
  }
2157
2214
 
2158
2215
  // ../jsx/src/analyzer-context.ts
2159
- import ts7 from "typescript";
2216
+ import ts8 from "typescript";
2160
2217
 
2161
2218
  // ../jsx/src/strip-types.ts
2162
- import ts6 from "typescript";
2219
+ import ts7 from "typescript";
2163
2220
 
2164
2221
  // ../jsx/src/analyzer-context.ts
2165
- var _typePrinter = ts7.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
2166
- var _blankTypeSourceFile = ts7.createSourceFile("__bf_types__.ts", "", ts7.ScriptTarget.Latest);
2222
+ var _typePrinter = ts8.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
2223
+ var _blankTypeSourceFile = ts8.createSourceFile("__bf_types__.ts", "", ts8.ScriptTarget.Latest);
2167
2224
 
2168
2225
  // ../jsx/src/errors.ts
2169
2226
  var ErrorCodes = {
@@ -2179,6 +2236,7 @@ var ErrorCodes = {
2179
2236
  JSX_IN_LOCAL_FUNCTION: "BF045",
2180
2237
  COMPONENT_REQUIRED_PROP_MISSING: "BF046",
2181
2238
  JSX_BRANCH_LOCAL_IN_CALLBACK: "BF047",
2239
+ SIBLING_COMPONENT_NOT_COMPILED: "BF048",
2182
2240
  SHARED_PROGRAM_REQUIRED: "BF050",
2183
2241
  WRONG_PACKAGE_IMPORT: "BF051",
2184
2242
  BUILTIN_REQUIRES_IMPORT: "BF054",
@@ -2208,6 +2266,7 @@ var errorMessages = {
2208
2266
  [ErrorCodes.JSX_IN_LOCAL_FUNCTION]: "Local function returns JSX but cannot be inlined. Extract it as a top-level PascalCase component or use a single return statement.",
2209
2267
  [ErrorCodes.COMPONENT_REQUIRED_PROP_MISSING]: "Built-in component is missing a required prop.",
2210
2268
  [ErrorCodes.JSX_BRANCH_LOCAL_IN_CALLBACK]: "JSX-typed local declared inside an `if`-block cannot be referenced from a callback body (ref / event handler). " + "Render it as a child instead: `<div ref={...}>{local}</div>`.",
2269
+ [ErrorCodes.SIBLING_COMPONENT_NOT_COMPILED]: "Referenced component did not compile to a template, so this reference would throw " + "`ReferenceError` at render time. Multi-return JSX dispatch (a `switch` or `if`/`else` " + "chain across multiple JSX-returning branches) cannot compile as a component in a " + `'use client' file. Extract it to a separate non-"use client" file (where it is preserved ` + "verbatim, see #932), or rewrite it as a single-return ternary/conditional chain so the " + "component pipeline can compile it.",
2211
2270
  [ErrorCodes.SHARED_PROGRAM_REQUIRED]: "Shared ts.Program required for type-based reactivity classification. This source imports a Reactive<T>-branded library (e.g. @barefootjs/form) whose getters cannot be classified by regex alone. Pass `options.program` (built via `createProgramForCorpus`) so the analyzer can resolve the brand through the TypeChecker.",
2212
2271
  [ErrorCodes.WRONG_PACKAGE_IMPORT]: "Import from wrong package.",
2213
2272
  [ErrorCodes.BUILTIN_REQUIRES_IMPORT]: "Built-in <Async> / <Region> must be imported from '@barefootjs/client'. " + "The compiler recognises these tags by their import (not by tag name), " + "so an unimported tag with this name is treated as an undeclared component.",
@@ -2381,6 +2440,54 @@ var CLIENT_EXPORTS = new Set([
2381
2440
  "Async",
2382
2441
  "Region"
2383
2442
  ]);
2443
+ function extractFreeIdentifiersFromNode(node) {
2444
+ const ids = new Set;
2445
+ const boundNames = new Set;
2446
+ function addBindingNames(name, out) {
2447
+ if (ts9.isIdentifier(name))
2448
+ out.push(name.text);
2449
+ else if (ts9.isObjectBindingPattern(name))
2450
+ name.elements.forEach((e) => addBindingNames(e.name, out));
2451
+ else if (ts9.isArrayBindingPattern(name))
2452
+ name.elements.forEach((e) => {
2453
+ if (!ts9.isOmittedExpression(e))
2454
+ addBindingNames(e.name, out);
2455
+ });
2456
+ }
2457
+ function visit(n) {
2458
+ if (ts9.isTypeNode(n))
2459
+ return;
2460
+ if (ts9.isIdentifier(n)) {
2461
+ const parent = n.parent;
2462
+ if (parent && ts9.isPropertyAccessExpression(parent) && parent.name === n)
2463
+ return;
2464
+ if (parent && ts9.isPropertyAssignment(parent) && parent.name === n)
2465
+ return;
2466
+ if (parent && ts9.isParameter(parent) && parent.name === n)
2467
+ return;
2468
+ if (parent && ts9.isVariableDeclaration(parent) && parent.name === n)
2469
+ return;
2470
+ if (boundNames.has(n.text))
2471
+ return;
2472
+ ids.add(n.text);
2473
+ return;
2474
+ }
2475
+ if (ts9.isArrowFunction(n)) {
2476
+ const params = [];
2477
+ for (const p of n.parameters)
2478
+ addBindingNames(p.name, params);
2479
+ for (const name of params)
2480
+ boundNames.add(name);
2481
+ ts9.forEachChild(n, visit);
2482
+ for (const name of params)
2483
+ boundNames.delete(name);
2484
+ return;
2485
+ }
2486
+ ts9.forEachChild(n, visit);
2487
+ }
2488
+ visit(node);
2489
+ return ids;
2490
+ }
2384
2491
  var BROWSER_ONLY_CLIENT_APIS = new Set([
2385
2492
  "useContext",
2386
2493
  "provideContext",
@@ -2399,7 +2506,7 @@ var REACTIVE_PRIMITIVES = new Set([
2399
2506
  ]);
2400
2507
 
2401
2508
  // ../jsx/src/jsx-to-ir.ts
2402
- import ts11 from "typescript";
2509
+ import ts12 from "typescript";
2403
2510
 
2404
2511
  // ../jsx/src/types.ts
2405
2512
  var SCOPE_FORBIDDEN = {
@@ -2481,10 +2588,10 @@ function findReachableNames(primaryRefs, declarations) {
2481
2588
  }
2482
2589
 
2483
2590
  // ../jsx/src/reactivity-checker.ts
2484
- import ts9 from "typescript";
2591
+ import ts10 from "typescript";
2485
2592
 
2486
2593
  // ../jsx/src/free-refs.ts
2487
- import ts10 from "typescript";
2594
+ import ts11 from "typescript";
2488
2595
  var _bindingMapCache = new WeakMap;
2489
2596
 
2490
2597
  // ../jsx/src/to-locale-date-lowering.ts
@@ -2802,6 +2909,83 @@ var toLocaleDatePlugin = {
2802
2909
  }
2803
2910
  };
2804
2911
 
2912
+ // ../jsx/src/scope/binding-scope.ts
2913
+ class BindingScope {
2914
+ frames;
2915
+ static EMPTY = new BindingScope([]);
2916
+ constructor(frames) {
2917
+ this.frames = frames;
2918
+ }
2919
+ enterLoopRow(loop) {
2920
+ const bindings = new Map;
2921
+ if (loop.paramBindings && loop.paramBindings.length > 0) {
2922
+ for (const b of loop.paramBindings)
2923
+ bindings.set(b.name, { source: "destructure" });
2924
+ } else {
2925
+ bindings.set(loop.param, { source: "item" });
2926
+ }
2927
+ if (loop.index != null)
2928
+ bindings.set(loop.index, { source: "index" });
2929
+ for (const name of loop.preamble?.declaredNames ?? [])
2930
+ bindings.set(name, { source: "preamble" });
2931
+ const frame = { kind: "loop-row", bindings };
2932
+ return new BindingScope([frame, ...this.frames]);
2933
+ }
2934
+ enterCallback(params) {
2935
+ const bindings = new Map;
2936
+ for (const name of params)
2937
+ bindings.set(name, { source: "param" });
2938
+ const frame = { kind: "callback", bindings };
2939
+ return new BindingScope([frame, ...this.frames]);
2940
+ }
2941
+ isBound(name) {
2942
+ for (const frame of this.frames) {
2943
+ if (frame.bindings.has(name))
2944
+ return true;
2945
+ }
2946
+ return false;
2947
+ }
2948
+ lookup(name) {
2949
+ for (let depth = 0;depth < this.frames.length; depth++) {
2950
+ const frame = this.frames[depth];
2951
+ const binding = frame.bindings.get(name);
2952
+ if (binding)
2953
+ return { depth, frame, binding };
2954
+ }
2955
+ return null;
2956
+ }
2957
+ boundNames() {
2958
+ if (this.boundNamesCache)
2959
+ return this.boundNamesCache;
2960
+ const names = new Set;
2961
+ for (const frame of this.frames) {
2962
+ for (const name of frame.bindings.keys())
2963
+ names.add(name);
2964
+ }
2965
+ this.boundNamesCache = names;
2966
+ return names;
2967
+ }
2968
+ boundNamesCache;
2969
+ valueBoundNamesCache;
2970
+ valueBoundNames() {
2971
+ if (this.valueBoundNamesCache)
2972
+ return this.valueBoundNamesCache;
2973
+ const names = new Set;
2974
+ for (const frame of this.frames) {
2975
+ for (const [name, binding] of frame.bindings) {
2976
+ if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
2977
+ names.add(name);
2978
+ }
2979
+ }
2980
+ }
2981
+ this.valueBoundNamesCache = names;
2982
+ return names;
2983
+ }
2984
+ asShadowPredicate() {
2985
+ return (name) => this.isBound(name);
2986
+ }
2987
+ }
2988
+
2805
2989
  // ../jsx/src/jsx-to-ir.ts
2806
2990
  var EMPTY_BOUND = new Set;
2807
2991
  var constInitializerCache = new WeakMap;
@@ -2898,13 +3082,13 @@ var KEYWORDS_AND_GLOBALS = new Set([
2898
3082
  ]);
2899
3083
 
2900
3084
  // ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
2901
- import ts12 from "typescript";
3085
+ import ts13 from "typescript";
2902
3086
 
2903
3087
  // ../jsx/src/value-references.ts
2904
- import ts13 from "typescript";
3088
+ import ts14 from "typescript";
2905
3089
 
2906
3090
  // ../jsx/src/relocate.ts
2907
- import ts14 from "typescript";
3091
+ import ts15 from "typescript";
2908
3092
 
2909
3093
  // ../jsx/src/lowering-registry.ts
2910
3094
  var plugins = [];
@@ -3100,10 +3284,10 @@ function formatDateLocalNames(metadata) {
3100
3284
  }
3101
3285
 
3102
3286
  // ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
3103
- import ts15 from "typescript";
3287
+ import ts16 from "typescript";
3104
3288
 
3105
3289
  // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
3106
- import ts16 from "typescript";
3290
+ import ts17 from "typescript";
3107
3291
  var NO_PREAMBLE = {
3108
3292
  lazySafe: true,
3109
3293
  facts: { declaredNames: new Set, freeNames: new Set }
@@ -3153,7 +3337,7 @@ var INERT_BINDING_GLOBALS = new Set([
3153
3337
  ]);
3154
3338
 
3155
3339
  // ../jsx/src/ir-to-client-js/emit-reactive.ts
3156
- import ts17 from "typescript";
3340
+ import ts18 from "typescript";
3157
3341
 
3158
3342
  // ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
3159
3343
  var NON_BUBBLING_EVENTS = new Set([
@@ -3168,7 +3352,7 @@ var NON_BUBBLING_EVENTS = new Set([
3168
3352
  ]);
3169
3353
 
3170
3354
  // ../jsx/src/ir-to-client-js/rewrite-props-object.ts
3171
- import ts18 from "typescript";
3355
+ import ts19 from "typescript";
3172
3356
 
3173
3357
  // ../jsx/src/ir-to-client-js/source-map.ts
3174
3358
  var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -3259,15 +3443,15 @@ class SourceMapGenerator {
3259
3443
  }
3260
3444
 
3261
3445
  // ../jsx/src/preprocess-inline-jsx-callbacks.ts
3262
- import ts19 from "typescript";
3446
+ import ts20 from "typescript";
3263
3447
 
3264
3448
  // ../jsx/src/ssr-defaults.ts
3265
- import ts20 from "typescript";
3449
+ import ts21 from "typescript";
3266
3450
  var UNRESOLVED = Symbol("unresolved");
3267
3451
  var NO_RETURN = Symbol("no-return");
3268
3452
 
3269
3453
  // ../jsx/src/augment-inherited-props.ts
3270
- import ts21 from "typescript";
3454
+ import ts22 from "typescript";
3271
3455
  function collectContextConsumers(metadata) {
3272
3456
  const constants = metadata.localConstants ?? [];
3273
3457
  const contextDefaults = new Map;
@@ -3299,47 +3483,47 @@ function collectContextConsumers(metadata) {
3299
3483
  }
3300
3484
  function parseUseContextArg(source) {
3301
3485
  const expr = parseSingleExpression(source);
3302
- if (!expr || !ts21.isCallExpression(expr))
3486
+ if (!expr || !ts22.isCallExpression(expr))
3303
3487
  return null;
3304
- if (!ts21.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
3488
+ if (!ts22.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
3305
3489
  return null;
3306
3490
  if (expr.arguments.length !== 1)
3307
3491
  return null;
3308
3492
  const arg = expr.arguments[0];
3309
- return ts21.isIdentifier(arg) ? arg.text : null;
3493
+ return ts22.isIdentifier(arg) ? arg.text : null;
3310
3494
  }
3311
3495
  function parseCreateContextDefault(source) {
3312
3496
  const expr = parseSingleExpression(source);
3313
- if (!expr || !ts21.isCallExpression(expr))
3497
+ if (!expr || !ts22.isCallExpression(expr))
3314
3498
  return null;
3315
3499
  if (expr.arguments.length === 0)
3316
3500
  return null;
3317
3501
  const arg = expr.arguments[0];
3318
- if (ts21.isStringLiteral(arg) || ts21.isNoSubstitutionTemplateLiteral(arg))
3502
+ if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg))
3319
3503
  return arg.text;
3320
- if (ts21.isNumericLiteral(arg))
3504
+ if (ts22.isNumericLiteral(arg))
3321
3505
  return Number(arg.text);
3322
- if (arg.kind === ts21.SyntaxKind.TrueKeyword)
3506
+ if (arg.kind === ts22.SyntaxKind.TrueKeyword)
3323
3507
  return true;
3324
- if (arg.kind === ts21.SyntaxKind.FalseKeyword)
3508
+ if (arg.kind === ts22.SyntaxKind.FalseKeyword)
3325
3509
  return false;
3326
3510
  return null;
3327
3511
  }
3328
3512
  function isObjectLiteralCreateContextDefault(source) {
3329
3513
  const expr = parseSingleExpression(source);
3330
- if (!expr || !ts21.isCallExpression(expr))
3514
+ if (!expr || !ts22.isCallExpression(expr))
3331
3515
  return false;
3332
3516
  if (expr.arguments.length === 0)
3333
3517
  return false;
3334
- return ts21.isObjectLiteralExpression(expr.arguments[0]);
3518
+ return ts22.isObjectLiteralExpression(expr.arguments[0]);
3335
3519
  }
3336
3520
  function parseSingleExpression(source) {
3337
- const sf = ts21.createSourceFile("__ctx.ts", `(${source})`, ts21.ScriptTarget.Latest, false);
3521
+ const sf = ts22.createSourceFile("__ctx.ts", `(${source})`, ts22.ScriptTarget.Latest, false);
3338
3522
  const stmt = sf.statements[0];
3339
- if (!stmt || !ts21.isExpressionStatement(stmt))
3523
+ if (!stmt || !ts22.isExpressionStatement(stmt))
3340
3524
  return null;
3341
3525
  let e = stmt.expression;
3342
- while (ts21.isParenthesizedExpression(e))
3526
+ while (ts22.isParenthesizedExpression(e))
3343
3527
  e = e.expression;
3344
3528
  return e;
3345
3529
  }
@@ -3364,25 +3548,25 @@ function augmentInheritedPropAccesses(ir) {
3364
3548
  const pinCoalesceLiterals = (s) => {
3365
3549
  if (!s || !s.includes(propsObj))
3366
3550
  return;
3367
- const sf = ts21.createSourceFile("__aug.ts", `(${s})`, ts21.ScriptTarget.Latest, false);
3551
+ const sf = ts22.createSourceFile("__aug.ts", `(${s})`, ts22.ScriptTarget.Latest, false);
3368
3552
  const visit = (n) => {
3369
- if (ts21.isBinaryExpression(n) && (n.operatorToken.kind === ts21.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts21.SyntaxKind.BarBarToken)) {
3553
+ if (ts22.isBinaryExpression(n) && (n.operatorToken.kind === ts22.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts22.SyntaxKind.BarBarToken)) {
3370
3554
  let left = n.left;
3371
- while (ts21.isParenthesizedExpression(left))
3555
+ while (ts22.isParenthesizedExpression(left))
3372
3556
  left = left.expression;
3373
- if (ts21.isPropertyAccessExpression(left) && ts21.isIdentifier(left.expression) && left.expression.text === propsObj) {
3557
+ if (ts22.isPropertyAccessExpression(left) && ts22.isIdentifier(left.expression) && left.expression.text === propsObj) {
3374
3558
  const name = left.name.text;
3375
3559
  let right = n.right;
3376
- while (ts21.isParenthesizedExpression(right))
3560
+ while (ts22.isParenthesizedExpression(right))
3377
3561
  right = right.expression;
3378
- if (ts21.isPrefixUnaryExpression(right))
3562
+ if (ts22.isPrefixUnaryExpression(right))
3379
3563
  right = right.operand;
3380
- const kind = ts21.isNumericLiteral(right) ? "number" : right.kind === ts21.SyntaxKind.TrueKeyword || right.kind === ts21.SyntaxKind.FalseKeyword ? "boolean" : ts21.isStringLiteralLike(right) ? "string" : null;
3564
+ const kind = ts22.isNumericLiteral(right) ? "number" : right.kind === ts22.SyntaxKind.TrueKeyword || right.kind === ts22.SyntaxKind.FalseKeyword ? "boolean" : ts22.isStringLiteralLike(right) ? "string" : null;
3381
3565
  if (kind && !coalesceLiteralTypes.has(name))
3382
3566
  coalesceLiteralTypes.set(name, kind);
3383
3567
  }
3384
3568
  }
3385
- ts21.forEachChild(n, visit);
3569
+ ts22.forEachChild(n, visit);
3386
3570
  };
3387
3571
  visit(sf);
3388
3572
  };
@@ -3493,33 +3677,33 @@ function augmentInheritedPropAccesses(ir) {
3493
3677
  }
3494
3678
  }
3495
3679
  function parseStaticStringConst(source) {
3496
- const sf = ts21.createSourceFile("__const.ts", `const __x = (${source});`, ts21.ScriptTarget.Latest, false);
3680
+ const sf = ts22.createSourceFile("__const.ts", `const __x = (${source});`, ts22.ScriptTarget.Latest, false);
3497
3681
  const stmt = sf.statements[0];
3498
- if (!stmt || !ts21.isVariableStatement(stmt))
3682
+ if (!stmt || !ts22.isVariableStatement(stmt))
3499
3683
  return null;
3500
3684
  let init = stmt.declarationList.declarations[0]?.initializer;
3501
- while (init && ts21.isParenthesizedExpression(init))
3685
+ while (init && ts22.isParenthesizedExpression(init))
3502
3686
  init = init.expression;
3503
3687
  if (!init)
3504
3688
  return null;
3505
- if (ts21.isStringLiteral(init) || ts21.isNoSubstitutionTemplateLiteral(init)) {
3689
+ if (ts22.isStringLiteral(init) || ts22.isNoSubstitutionTemplateLiteral(init)) {
3506
3690
  return init.text;
3507
3691
  }
3508
3692
  return evalStringArrayJoin(source);
3509
3693
  }
3510
3694
  function evalTemplateOfStringConsts(source, resolved) {
3511
- const sf = ts21.createSourceFile("__const.ts", `const __x = (${source});`, ts21.ScriptTarget.Latest, false);
3695
+ const sf = ts22.createSourceFile("__const.ts", `const __x = (${source});`, ts22.ScriptTarget.Latest, false);
3512
3696
  const stmt = sf.statements[0];
3513
- if (!stmt || !ts21.isVariableStatement(stmt))
3697
+ if (!stmt || !ts22.isVariableStatement(stmt))
3514
3698
  return null;
3515
3699
  let init = stmt.declarationList.declarations[0]?.initializer;
3516
- while (init && ts21.isParenthesizedExpression(init))
3700
+ while (init && ts22.isParenthesizedExpression(init))
3517
3701
  init = init.expression;
3518
- if (!init || !ts21.isTemplateExpression(init))
3702
+ if (!init || !ts22.isTemplateExpression(init))
3519
3703
  return null;
3520
3704
  let out = init.head.text;
3521
3705
  for (const span of init.templateSpans) {
3522
- if (!ts21.isIdentifier(span.expression))
3706
+ if (!ts22.isIdentifier(span.expression))
3523
3707
  return null;
3524
3708
  const value = resolved.get(span.expression.text);
3525
3709
  if (value === undefined)
@@ -3547,28 +3731,28 @@ function collectModuleStringConsts(constants) {
3547
3731
  return map;
3548
3732
  }
3549
3733
  function evalStringArrayJoin(source) {
3550
- const sf = ts21.createSourceFile("__join.ts", `const __x = (${source});`, ts21.ScriptTarget.Latest, false);
3734
+ const sf = ts22.createSourceFile("__join.ts", `const __x = (${source});`, ts22.ScriptTarget.Latest, false);
3551
3735
  const stmt = sf.statements[0];
3552
- if (!stmt || !ts21.isVariableStatement(stmt))
3736
+ if (!stmt || !ts22.isVariableStatement(stmt))
3553
3737
  return null;
3554
3738
  let node = stmt.declarationList.declarations[0]?.initializer;
3555
- while (node && ts21.isParenthesizedExpression(node))
3739
+ while (node && ts22.isParenthesizedExpression(node))
3556
3740
  node = node.expression;
3557
- if (!node || !ts21.isCallExpression(node))
3741
+ if (!node || !ts22.isCallExpression(node))
3558
3742
  return null;
3559
3743
  const callee = node.expression;
3560
- if (!ts21.isPropertyAccessExpression(callee))
3744
+ if (!ts22.isPropertyAccessExpression(callee))
3561
3745
  return null;
3562
3746
  if (callee.name.text !== "join")
3563
3747
  return null;
3564
3748
  let recv = callee.expression;
3565
- while (ts21.isParenthesizedExpression(recv))
3749
+ while (ts22.isParenthesizedExpression(recv))
3566
3750
  recv = recv.expression;
3567
- if (!ts21.isArrayLiteralExpression(recv))
3751
+ if (!ts22.isArrayLiteralExpression(recv))
3568
3752
  return null;
3569
3753
  const parts = [];
3570
3754
  for (const el of recv.elements) {
3571
- if (ts21.isStringLiteral(el) || ts21.isNoSubstitutionTemplateLiteral(el)) {
3755
+ if (ts22.isStringLiteral(el) || ts22.isNoSubstitutionTemplateLiteral(el)) {
3572
3756
  parts.push(el.text);
3573
3757
  } else {
3574
3758
  return null;
@@ -3577,7 +3761,7 @@ function evalStringArrayJoin(source) {
3577
3761
  let sep = ",";
3578
3762
  if (node.arguments.length >= 1) {
3579
3763
  const arg = node.arguments[0];
3580
- if (ts21.isStringLiteral(arg) || ts21.isNoSubstitutionTemplateLiteral(arg))
3764
+ if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg))
3581
3765
  sep = arg.text;
3582
3766
  else
3583
3767
  return null;
@@ -3585,11 +3769,11 @@ function evalStringArrayJoin(source) {
3585
3769
  return parts.join(sep);
3586
3770
  }
3587
3771
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
3588
- if (!ts21.isElementAccessExpression(val))
3772
+ if (!ts22.isElementAccessExpression(val))
3589
3773
  return null;
3590
3774
  const obj = val.expression;
3591
3775
  const arg = val.argumentExpression;
3592
- if (!ts21.isIdentifier(obj) || !ts21.isIdentifier(arg))
3776
+ if (!ts22.isIdentifier(obj) || !ts22.isIdentifier(arg))
3593
3777
  return null;
3594
3778
  let indexPropName;
3595
3779
  let defaultKey;
@@ -3605,35 +3789,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
3605
3789
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
3606
3790
  if (constInfo?.value === undefined)
3607
3791
  return null;
3608
- const sf = ts21.createSourceFile("__rec.ts", `(${constInfo.value})`, ts21.ScriptTarget.Latest, true);
3792
+ const sf = ts22.createSourceFile("__rec.ts", `(${constInfo.value})`, ts22.ScriptTarget.Latest, true);
3609
3793
  if (sf.statements.length !== 1)
3610
3794
  return null;
3611
3795
  const stmt = sf.statements[0];
3612
- if (!ts21.isExpressionStatement(stmt))
3796
+ if (!ts22.isExpressionStatement(stmt))
3613
3797
  return null;
3614
3798
  let parsed = stmt.expression;
3615
- while (ts21.isParenthesizedExpression(parsed))
3799
+ while (ts22.isParenthesizedExpression(parsed))
3616
3800
  parsed = parsed.expression;
3617
- if (!ts21.isObjectLiteralExpression(parsed))
3801
+ if (!ts22.isObjectLiteralExpression(parsed))
3618
3802
  return null;
3619
3803
  const entries = [];
3620
3804
  for (const prop of parsed.properties) {
3621
- if (!ts21.isPropertyAssignment(prop))
3805
+ if (!ts22.isPropertyAssignment(prop))
3622
3806
  return null;
3623
3807
  let key;
3624
- if (ts21.isIdentifier(prop.name)) {
3808
+ if (ts22.isIdentifier(prop.name)) {
3625
3809
  key = prop.name.text;
3626
- } else if (ts21.isStringLiteral(prop.name) || ts21.isNoSubstitutionTemplateLiteral(prop.name)) {
3810
+ } else if (ts22.isStringLiteral(prop.name) || ts22.isNoSubstitutionTemplateLiteral(prop.name)) {
3627
3811
  key = prop.name.text;
3628
3812
  } else {
3629
3813
  return null;
3630
3814
  }
3631
3815
  let v = prop.initializer;
3632
- while (ts21.isParenthesizedExpression(v))
3816
+ while (ts22.isParenthesizedExpression(v))
3633
3817
  v = v.expression;
3634
- if (ts21.isNumericLiteral(v)) {
3818
+ if (ts22.isNumericLiteral(v)) {
3635
3819
  entries.push({ key, value: { kind: "number", text: v.text } });
3636
- } else if (ts21.isStringLiteral(v) || ts21.isNoSubstitutionTemplateLiteral(v)) {
3820
+ } else if (ts22.isStringLiteral(v) || ts22.isNoSubstitutionTemplateLiteral(v)) {
3637
3821
  entries.push({ key, value: { kind: "string", text: v.text } });
3638
3822
  } else {
3639
3823
  return null;
@@ -3689,7 +3873,7 @@ function computeSsrSeedPlan(metadata) {
3689
3873
  // ../jsx/src/rich-type-refusal.ts
3690
3874
  var EMPTY_BINDINGS2 = new Map;
3691
3875
  // ../jsx/src/shared-program.ts
3692
- import ts22 from "typescript";
3876
+ import ts24 from "typescript";
3693
3877
  // ../jsx/src/adapters/interface.ts
3694
3878
  class BaseAdapter {
3695
3879
  renderChildren(children) {
@@ -3765,7 +3949,7 @@ class JsxAdapter extends BaseAdapter {
3765
3949
  }
3766
3950
  const rawInitialValue = preserveTypes ? signal.typedInitialValue ?? signal.initialValue : signal.initialValue;
3767
3951
  const initialValue = rawInitialValue.trim().startsWith("{") ? `(${rawInitialValue})` : rawInitialValue;
3768
- const needsTypeAssertion = preserveTypes && !signal.typedInitialValue && signal.type.kind !== "unknown" && signal.type.kind !== "primitive";
3952
+ const needsTypeAssertion = preserveTypes && !signal.typedInitialValue && signal.type.kind !== "unknown" && signal.type.kind !== "primitive" && signal.type.raw !== "object";
3769
3953
  if (needsTypeAssertion) {
3770
3954
  lines.push(` const ${signal.getter} = () => ${initialValue} as ${signal.type.raw}`);
3771
3955
  } else {
@@ -3784,12 +3968,16 @@ class JsxAdapter extends BaseAdapter {
3784
3968
  const computation = preserveTypes ? memo.typedComputation ?? memo.computation : memo.computation;
3785
3969
  lines.push(` const ${memo.name} = ${computation}`);
3786
3970
  }
3971
+ const moduleScopeNames = this.moduleScopeDeclarationNames(ir);
3787
3972
  for (const constant of ir.metadata.localConstants) {
3788
3973
  if (constant.isExported)
3789
3974
  continue;
3975
+ if (moduleScopeNames.has(constant.name))
3976
+ continue;
3790
3977
  const keyword = constant.declarationKind ?? "const";
3791
3978
  if (!constant.value) {
3792
- lines.push(` ${keyword} ${constant.name}`);
3979
+ const typeAnnotation = preserveTypes && (constant.typeAnnotation ?? constant.type) ? `: ${constant.typeAnnotation ?? constant.type?.raw}` : "";
3980
+ lines.push(` ${keyword} ${constant.name}${typeAnnotation}`);
3793
3981
  continue;
3794
3982
  }
3795
3983
  const value = constant.value.trim();
@@ -3798,9 +3986,12 @@ class JsxAdapter extends BaseAdapter {
3798
3986
  if (!reachable.has(constant.name))
3799
3987
  continue;
3800
3988
  const constValue = preserveTypes ? constant.typedValue ?? constant.value : constant.value;
3801
- lines.push(` ${keyword} ${constant.name} = ${constValue}`);
3989
+ const letTypeAnnotation = preserveTypes && keyword === "let" && constant.typeAnnotation ? `: ${constant.typeAnnotation}` : "";
3990
+ lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${constValue}`);
3802
3991
  }
3803
3992
  for (const func of localFunctions) {
3993
+ if (moduleScopeNames.has(func.name))
3994
+ continue;
3804
3995
  if (!reachable.has(func.name))
3805
3996
  continue;
3806
3997
  const params = preserveTypes && func.typedParams !== undefined ? func.typedParams : func.params.map(formatParamWithType).join(", ");
@@ -3810,6 +4001,127 @@ class JsxAdapter extends BaseAdapter {
3810
4001
  lines.push(` ${asyncKw}function ${func.name}(${params})${returnAnnotation} ${body}`);
3811
4002
  }
3812
4003
  return lines.join(`
4004
+ `);
4005
+ }
4006
+ moduleScopeNamesCache = new WeakMap;
4007
+ moduleScopeDeclarationNames(ir) {
4008
+ const cached = this.moduleScopeNamesCache.get(ir);
4009
+ if (cached)
4010
+ return cached;
4011
+ const componentScope = new Set;
4012
+ for (const sig of ir.metadata.signals) {
4013
+ if (sig.isModule)
4014
+ continue;
4015
+ componentScope.add(sig.getter);
4016
+ if (sig.setter)
4017
+ componentScope.add(sig.setter);
4018
+ }
4019
+ for (const memo of ir.metadata.memos) {
4020
+ if (!memo.isModule)
4021
+ componentScope.add(memo.name);
4022
+ }
4023
+ for (const p of ir.metadata.propsParams)
4024
+ componentScope.add(p.name);
4025
+ if (ir.metadata.propsObjectName)
4026
+ componentScope.add(ir.metadata.propsObjectName);
4027
+ if (ir.metadata.restPropsName)
4028
+ componentScope.add(ir.metadata.restPropsName);
4029
+ for (const c of ir.metadata.localConstants) {
4030
+ if (!c.isModule)
4031
+ componentScope.add(c.name);
4032
+ }
4033
+ for (const f of ir.metadata.localFunctions) {
4034
+ if (!f.isModule)
4035
+ componentScope.add(f.name);
4036
+ }
4037
+ const exported = new Set;
4038
+ const candidates = new Map;
4039
+ for (const c of ir.metadata.localConstants) {
4040
+ if (!c.isModule)
4041
+ continue;
4042
+ if (c.isJsx || c.isJsxFunction)
4043
+ continue;
4044
+ if (c.isExported) {
4045
+ exported.add(c.name);
4046
+ continue;
4047
+ }
4048
+ candidates.set(c.name, c.freeIdentifiers ?? extractFreeIdentifiersFromText(c.value ?? ""));
4049
+ }
4050
+ for (const f of ir.metadata.localFunctions) {
4051
+ if (!f.isModule)
4052
+ continue;
4053
+ if (f.isJsxFunction || f.isMultiReturnJsxHelper)
4054
+ continue;
4055
+ if (f.isExported) {
4056
+ exported.add(f.name);
4057
+ continue;
4058
+ }
4059
+ const params = f.typedParams !== undefined ? f.typedParams : f.params.map(formatParamWithType).join(", ");
4060
+ candidates.set(f.name, extractFreeIdentifiersFromText(`(${params}) => ${f.body}`));
4061
+ }
4062
+ const referencesAny = (refs, names) => {
4063
+ for (const ref of refs) {
4064
+ if (names.has(ref))
4065
+ return true;
4066
+ }
4067
+ return false;
4068
+ };
4069
+ let changed = true;
4070
+ while (changed) {
4071
+ changed = false;
4072
+ for (const [name, refs] of candidates) {
4073
+ if (referencesAny(refs, componentScope)) {
4074
+ candidates.delete(name);
4075
+ componentScope.add(name);
4076
+ changed = true;
4077
+ }
4078
+ }
4079
+ }
4080
+ const result = new Set([...exported, ...candidates.keys()]);
4081
+ this.moduleScopeNamesCache.set(ir, result);
4082
+ return result;
4083
+ }
4084
+ generateModuleScopeDeclarations(ir) {
4085
+ const { preserveTypes } = this.jsxConfig;
4086
+ const moduleNames = this.moduleScopeDeclarationNames(ir);
4087
+ const entries = [];
4088
+ for (const t of ir.metadata.typeDefinitions) {
4089
+ entries.push({ line: t.loc.start.line, text: t.definition });
4090
+ }
4091
+ for (const c of ir.metadata.localConstants) {
4092
+ if (!c.isModule || !moduleNames.has(c.name))
4093
+ continue;
4094
+ const keyword = c.declarationKind ?? "const";
4095
+ const exportKw = c.isExported ? "export " : "";
4096
+ if (!c.value) {
4097
+ const typeAnnotation = preserveTypes && (c.typeAnnotation ?? c.type) ? `: ${c.typeAnnotation ?? c.type?.raw}` : "";
4098
+ entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${typeAnnotation}` });
4099
+ continue;
4100
+ }
4101
+ const trimmed = c.value.trim();
4102
+ if (/^new WeakMap\b/.test(trimmed))
4103
+ continue;
4104
+ if (c.isExported && /^createContext\b/.test(trimmed))
4105
+ continue;
4106
+ const value = preserveTypes ? c.typedValue ?? c.value : c.value;
4107
+ const letTypeAnnotation = preserveTypes && keyword === "let" && c.typeAnnotation ? `: ${c.typeAnnotation}` : "";
4108
+ entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${letTypeAnnotation} = ${value}` });
4109
+ }
4110
+ for (const f of ir.metadata.localFunctions) {
4111
+ if (!f.isModule || !moduleNames.has(f.name))
4112
+ continue;
4113
+ const params = preserveTypes && f.typedParams !== undefined ? f.typedParams : f.params.map(formatParamWithType).join(", ");
4114
+ const returnAnnotation = preserveTypes && f.typedReturnType ? `: ${f.typedReturnType}` : "";
4115
+ const body = preserveTypes ? f.typedBody ?? f.body : f.body;
4116
+ const asyncKw = f.isAsync ? "async " : "";
4117
+ const exportKw = f.isExported ? "export " : "";
4118
+ entries.push({
4119
+ line: f.loc.start.line,
4120
+ text: `${exportKw}${asyncKw}function ${f.name}(${params})${returnAnnotation} ${body}`
4121
+ });
4122
+ }
4123
+ entries.sort((a, b) => a.line - b.line);
4124
+ return entries.map((e) => e.text).join(`
3813
4125
  `);
3814
4126
  }
3815
4127
  renderNodeRaw(node) {
@@ -3821,6 +4133,15 @@ class JsxAdapter extends BaseAdapter {
3821
4133
  }
3822
4134
  return this.renderNode(node);
3823
4135
  }
4136
+ renderTemplatePartsAsJs(parts) {
4137
+ return templatePartsToJsExpr(parts, { typed: this.jsxConfig.preserveTypes });
4138
+ }
4139
+ expressionValueToJs(value) {
4140
+ if (this.jsxConfig.preserveTypes && value.parts && value.expr === templatePartsToJsExpr(value.parts)) {
4141
+ return this.renderTemplatePartsAsJs(value.parts);
4142
+ }
4143
+ return value.expr;
4144
+ }
3824
4145
  renderScopeMarker(instanceIdExpr) {
3825
4146
  return `${BF_SCOPE}={${instanceIdExpr}}`;
3826
4147
  }
@@ -3888,6 +4209,7 @@ class TestAdapter extends JsxAdapter {
3888
4209
  generate(ir) {
3889
4210
  this.componentName = ir.metadata.componentName;
3890
4211
  const imports = this.generateImports(ir);
4212
+ const moduleConstants = this.generateModuleScopeDeclarations(ir);
3891
4213
  const types = this.generateTypes(ir);
3892
4214
  const component = this.generateComponent(ir);
3893
4215
  const defaultExport = ir.metadata.hasDefaultExport ? `
@@ -3896,9 +4218,11 @@ export default ${this.componentName}` : "";
3896
4218
  imports,
3897
4219
  types: types || "",
3898
4220
  component,
3899
- defaultExport
4221
+ defaultExport,
4222
+ moduleConstants,
4223
+ moduleConstantsIncludeExports: true
3900
4224
  };
3901
- const template = [imports, types, component].filter(Boolean).join(`
4225
+ const template = [imports, moduleConstants, types, component].filter(Boolean).join(`
3902
4226
 
3903
4227
  `) + defaultExport;
3904
4228
  return {
@@ -3929,9 +4253,6 @@ export default ${this.componentName}` : "";
3929
4253
  }
3930
4254
  generateTypes(ir) {
3931
4255
  const lines = [];
3932
- for (const typeDef of ir.metadata.typeDefinitions) {
3933
- lines.push(typeDef.definition);
3934
- }
3935
4256
  const propsTypeName = ir.metadata.propsType?.raw;
3936
4257
  if (propsTypeName && !ir.metadata.propsObjectName) {
3937
4258
  lines.push("");
@@ -3954,7 +4275,7 @@ export default ${this.componentName}` : "";
3954
4275
  const bodyRefText = [jsxBody, signalInits, scopeIdLine].join(`
3955
4276
  `);
3956
4277
  const bfScopeAlias = /\b__bfScope\b/.test(bodyRefText) ? "__bfScope" : "__bfScope: _bfScope";
3957
- const propsParams = ir.metadata.propsParams.map((p) => p.defaultValue ? `${p.name} = ${p.defaultValue}` : p.name).join(", ");
4278
+ const propsParams = ir.metadata.propsParams.map((p) => propsDestructureBinding(p)).join(", ");
3958
4279
  const restPropsName = ir.metadata.restPropsName;
3959
4280
  const hydrationProps = `__instanceId, ${bfScopeAlias}`;
3960
4281
  const parts = [];
@@ -4101,13 +4422,7 @@ export default ${this.componentName}` : "";
4101
4422
  }
4102
4423
  flattenTemplate(value) {
4103
4424
  const v = value;
4104
- return "`" + v.parts.map((p) => {
4105
- if (p.type === "string")
4106
- return p.value;
4107
- if (p.type === "ternary")
4108
- return `\${${p.condition} ? '${p.whenTrue}' : '${p.whenFalse}'}`;
4109
- return `\${(${JSON.stringify(p.cases)})[${p.key}]}`;
4110
- }).join("") + "`";
4425
+ return this.renderTemplatePartsAsJs(v.parts);
4111
4426
  }
4112
4427
  renderComponentProps(comp) {
4113
4428
  const parts = [];
@@ -4575,7 +4890,7 @@ function dangerousInnerHtmlDiagnostic(expr, loc, reason) {
4575
4890
  };
4576
4891
  }
4577
4892
  // ../jsx/src/combine-client-js.ts
4578
- import ts23 from "typescript";
4893
+ import ts25 from "typescript";
4579
4894
  // ../jsx/src/loop-destructure.ts
4580
4895
  function isLowerableLoopDestructure(loop) {
4581
4896
  const bindings = loop.paramBindings;
@@ -4715,9 +5030,9 @@ function escapeRe(s) {
4715
5030
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4716
5031
  }
4717
5032
  // ../jsx/src/debug.ts
4718
- import ts24 from "typescript";
5033
+ import ts26 from "typescript";
4719
5034
  // ../jsx/src/profiler.ts
4720
- import ts25 from "typescript";
5035
+ import ts27 from "typescript";
4721
5036
 
4722
5037
  // ../jsx/src/index.ts
4723
5038
  registerBuiltinLoweringPlugins();
@@ -5647,15 +5962,43 @@ function collapseLiteralUnion(typeInfo) {
5647
5962
  }
5648
5963
  return { kind: "primitive", raw: typeInfo.raw, primitive: first };
5649
5964
  }
5650
- function typeInfoToGo(ctx, _typeInfo, defaultValue) {
5965
+ function literalNumberValue(expr) {
5966
+ if (expr.kind === "literal" && expr.literalType === "number" && typeof expr.value === "number") {
5967
+ return expr.value;
5968
+ }
5969
+ if (expr.kind === "unary" && expr.op === "-" && expr.argument.kind === "literal" && expr.argument.literalType === "number" && typeof expr.argument.value === "number") {
5970
+ return -expr.argument.value;
5971
+ }
5972
+ return null;
5973
+ }
5974
+ function inferGoTypeFromParsed(expr) {
5975
+ const n = literalNumberValue(expr);
5976
+ if (n !== null)
5977
+ return Number.isInteger(n) ? "int" : "float64";
5978
+ if (expr.kind === "literal") {
5979
+ if (expr.literalType === "boolean")
5980
+ return "bool";
5981
+ if (expr.literalType === "string")
5982
+ return "string";
5983
+ return null;
5984
+ }
5985
+ if (expr.kind === "array-literal")
5986
+ return "[]interface{}";
5987
+ return null;
5988
+ }
5989
+ function typeInfoToGo(ctx, _typeInfo, defaultValue, preParsed) {
5651
5990
  const typeInfo = collapseLiteralUnion(_typeInfo);
5652
5991
  switch (typeInfo.kind) {
5653
5992
  case "primitive":
5654
5993
  switch (typeInfo.primitive) {
5655
5994
  case "string":
5656
5995
  return "string";
5657
- case "number":
5996
+ case "number": {
5997
+ const n = preParsed ? literalNumberValue(preParsed) : null;
5998
+ if (n !== null)
5999
+ return Number.isInteger(n) ? "int" : "float64";
5658
6000
  return defaultValue !== undefined ? numberPrimitiveGoType(defaultValue) : "int";
6001
+ }
5659
6002
  case "boolean":
5660
6003
  return "bool";
5661
6004
  default:
@@ -5678,30 +6021,21 @@ function typeInfoToGo(ctx, _typeInfo, defaultValue) {
5678
6021
  return resolved;
5679
6022
  }
5680
6023
  return "interface{}";
5681
- case "unknown":
6024
+ case "unknown": {
6025
+ const inferred = preParsed ? inferGoTypeFromParsed(preParsed) : null;
6026
+ if (inferred)
6027
+ return inferred;
5682
6028
  if (defaultValue !== undefined) {
5683
6029
  return inferTypeFromValue(defaultValue);
5684
6030
  }
5685
6031
  return "interface{}";
6032
+ }
5686
6033
  default:
5687
6034
  return "interface{}";
5688
6035
  }
5689
6036
  }
5690
6037
  function tsTypeStringToGo(ctx, tsType) {
5691
6038
  const t = tsType.trim();
5692
- if (t === "number")
5693
- return "int";
5694
- if (t === "string")
5695
- return "string";
5696
- if (t === "boolean" || t === "bool")
5697
- return "bool";
5698
- if (t.endsWith("[]")) {
5699
- const elem = t.slice(0, -2);
5700
- return `[]${tsTypeStringToGo(ctx, elem)}`;
5701
- }
5702
- const arrayMatch = t.match(/^Array<(.+)>$/);
5703
- if (arrayMatch)
5704
- return `[]${tsTypeStringToGo(ctx, arrayMatch[1])}`;
5705
6039
  if (ctx.state.localStructFields.has(t) || ctx.state.localTypeAliases.has(t))
5706
6040
  return t;
5707
6041
  return "interface{}";
@@ -5745,16 +6079,25 @@ function bakeInlineObjectAsGoMap(ctx, expr) {
5745
6079
  }
5746
6080
  return `map[string]interface{}{${entries.join(", ")}}`;
5747
6081
  }
5748
- function parsedLiteralToGo(ctx, expr, typeInfo) {
6082
+ function numberLiteralRawGo(expr) {
5749
6083
  if (expr.kind === "unary" && expr.op === "-" && expr.argument.kind === "literal" && expr.argument.literalType === "number") {
5750
6084
  return expr.argument.raw !== undefined ? `-${expr.argument.raw}` : null;
5751
6085
  }
6086
+ if (expr.kind === "literal" && expr.literalType === "number") {
6087
+ return expr.raw ?? null;
6088
+ }
6089
+ return null;
6090
+ }
6091
+ function parsedLiteralToGo(ctx, expr, typeInfo) {
6092
+ const numberGo = numberLiteralRawGo(expr);
6093
+ if (numberGo !== null)
6094
+ return numberGo;
5752
6095
  if (expr.kind === "literal") {
5753
6096
  switch (expr.literalType) {
5754
6097
  case "string":
5755
6098
  return JSON.stringify(expr.value);
5756
6099
  case "number":
5757
- return expr.raw ?? null;
6100
+ return null;
5758
6101
  case "boolean":
5759
6102
  return expr.value ? "true" : "false";
5760
6103
  case "null":
@@ -5806,10 +6149,10 @@ function parsedLiteralToGo(ctx, expr, typeInfo) {
5806
6149
 
5807
6150
  // src/adapter/value/value-lowering.ts
5808
6151
  var EMPTY_PROP_FALLBACK_VARS = new Map;
5809
- function nillableAwarePropRef(ctx, propName, expectedType) {
5810
- const fieldRef = `in.${capitalizeFieldName(propName)}`;
6152
+ function nillableAwarePropRef(ctx, param, expectedType) {
6153
+ const fieldRef = `in.${capitalizeFieldName(param.sourceName ?? param.name)}`;
5811
6154
  const scalar = expectedType.kind === "primitive" ? expectedType : expectedType.kind === "union" && expectedType.unionTypes?.length === 2 ? expectedType.unionTypes.find((t) => t.primitive !== "undefined" && t.primitive !== "null") : undefined;
5812
- if (ctx.state.nillablePropNames.has(propName) && scalar?.kind === "primitive") {
6155
+ if (ctx.state.nillablePropNames.has(param.name) && scalar?.kind === "primitive") {
5813
6156
  const goType = scalar.primitive === "boolean" ? "bool" : scalar.primitive === "number" ? "float64" : scalar.primitive === "string" ? "string" : null;
5814
6157
  if (goType) {
5815
6158
  const zero = goType === "bool" ? "false" : goType === "string" ? '""' : "0";
@@ -5820,21 +6163,29 @@ function nillableAwarePropRef(ctx, propName, expectedType) {
5820
6163
  }
5821
6164
  function convertInitialValue(ctx, value, _typeInfo, propsParams, preParsed) {
5822
6165
  const typeInfo = collapseLiteralUnion(_typeInfo);
5823
- const propRef = (propName2) => nillableAwarePropRef(ctx, propName2, typeInfo);
6166
+ const propRef = (param2) => nillableAwarePropRef(ctx, param2, typeInfo);
5824
6167
  if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(value)) {
5825
- if (propsParams?.some((p) => p.name === value)) {
5826
- return propRef(value);
6168
+ const param2 = propsParams?.find((p) => p.name === value);
6169
+ if (param2) {
6170
+ return propRef(param2);
5827
6171
  }
5828
6172
  }
5829
6173
  const propName = ctx.extractPropNameFromInitialValue(value, preParsed);
5830
- if (propName && propsParams?.some((p) => p.name === propName)) {
5831
- return propRef(propName);
6174
+ const param = propName ? propsParams?.find((p) => p.name === propName) : undefined;
6175
+ if (param) {
6176
+ return propRef(param);
5832
6177
  }
5833
6178
  if (typeInfo.kind === "primitive") {
5834
6179
  if (typeInfo.primitive === "boolean") {
6180
+ if (preParsed?.kind === "literal" && preParsed.literalType === "boolean" && typeof preParsed.value === "boolean") {
6181
+ return preParsed.value ? "true" : "false";
6182
+ }
5835
6183
  return value === "true" ? "true" : "false";
5836
6184
  }
5837
6185
  if (typeInfo.primitive === "number") {
6186
+ const numGo = preParsed ? numberLiteralRawGo(preParsed) : null;
6187
+ if (numGo !== null)
6188
+ return numGo;
5838
6189
  if (/^-?\d+$/.test(value))
5839
6190
  return value;
5840
6191
  if (/^-?\d+\.\d+$/.test(value))
@@ -5842,7 +6193,10 @@ function convertInitialValue(ctx, value, _typeInfo, propsParams, preParsed) {
5842
6193
  return "0";
5843
6194
  }
5844
6195
  if (typeInfo.primitive === "string") {
5845
- if (value.startsWith("'") || value.endsWith("'")) {
6196
+ if (preParsed?.kind === "literal" && preParsed.literalType === "string" && typeof preParsed.value === "string") {
6197
+ return JSON.stringify(preParsed.value);
6198
+ }
6199
+ if (value.startsWith("'") && value.endsWith("'")) {
5846
6200
  return value.replace(/'/g, '"');
5847
6201
  }
5848
6202
  if (value.startsWith('"') && value.endsWith('"')) {
@@ -5904,19 +6258,21 @@ function objectLiteralToGoMap(ctx, expr) {
5904
6258
  return `map[string]interface{}{${entries.join(", ")}}`;
5905
6259
  }
5906
6260
  function getSignalInitialValueAsGo(ctx, initialValue, propsParams, propFallbackVars = EMPTY_PROP_FALLBACK_VARS, signalType) {
5907
- const propRef = (propName2) => signalType ? nillableAwarePropRef(ctx, propName2, signalType) : `in.${capitalizeFieldName(propName2)}`;
5908
- if (propsParams.some((p) => p.name === initialValue)) {
6261
+ const propRef = (param2) => signalType ? nillableAwarePropRef(ctx, param2, signalType) : `in.${capitalizeFieldName(param2.sourceName ?? param2.name)}`;
6262
+ const directParam = propsParams.find((p) => p.name === initialValue);
6263
+ if (directParam) {
5909
6264
  const hoisted = propFallbackVars.get(initialValue);
5910
6265
  if (hoisted)
5911
6266
  return hoisted.varName;
5912
- return propRef(initialValue);
6267
+ return propRef(directParam);
5913
6268
  }
5914
6269
  const propName = ctx.extractPropNameFromInitialValue(initialValue);
5915
- if (propName && propsParams.some((p) => p.name === propName)) {
6270
+ const param = propName ? propsParams.find((p) => p.name === propName) : undefined;
6271
+ if (param) {
5916
6272
  const hoisted = propFallbackVars.get(propName);
5917
6273
  if (hoisted)
5918
6274
  return hoisted.varName;
5919
- return propRef(propName);
6275
+ return propRef(param);
5920
6276
  }
5921
6277
  if (/^-?\d+$/.test(initialValue)) {
5922
6278
  return initialValue;
@@ -5950,8 +6306,9 @@ function resolveMapJoinBaseAsGo(ctx, object, signals, propsParams) {
5950
6306
  }
5951
6307
  }
5952
6308
  const propName = object.kind === "member" && !object.computed && object.object.kind === "identifier" && object.object.name === "props" ? object.property : object.kind === "identifier" ? object.name : null;
5953
- if (propName && propsParams.some((p) => p.name === propName)) {
5954
- return `in.${capitalizeFieldName(propName)}`;
6309
+ const param = propName ? propsParams.find((p) => p.name === propName) : undefined;
6310
+ if (param) {
6311
+ return `in.${capitalizeFieldName(param.sourceName ?? param.name)}`;
5955
6312
  }
5956
6313
  if (object.kind === "array-literal") {
5957
6314
  if (object.elements.length === 0)
@@ -5982,11 +6339,12 @@ function mapJoinChainToGo(ctx, chain, signals, propsParams, propFallbackVars) {
5982
6339
  for (const name of freeVars) {
5983
6340
  const sig = signals.find((s) => s.getter === name);
5984
6341
  let goExpr = null;
6342
+ const freeVarParam = propsParams.find((p) => p.name === name);
5985
6343
  if (sig) {
5986
6344
  goExpr = getSignalInitialValueAsGo(ctx, sig.initialValue, propsParams, propFallbackVars, sig.type);
5987
- } else if (propsParams.some((p) => p.name === name)) {
6345
+ } else if (freeVarParam) {
5988
6346
  const hoisted = propFallbackVars.get(name);
5989
- goExpr = hoisted ? hoisted.varName : `in.${capitalizeFieldName(name)}`;
6347
+ goExpr = hoisted ? hoisted.varName : `in.${capitalizeFieldName(freeVarParam.sourceName ?? name)}`;
5990
6348
  }
5991
6349
  if (goExpr === null)
5992
6350
  return null;
@@ -6028,14 +6386,14 @@ function isBooleanMemo(ctx, memo, signals, propsParamMap) {
6028
6386
  return true;
6029
6387
  if (/\?\?\s*(true|false)\b/.test(sig.initialValue))
6030
6388
  return true;
6031
- const propName = ctx.extractPropNameFromInitialValue(sig.initialValue) ?? sig.initialValue;
6389
+ const propName = ctx.extractPropNameFromInitialValue(sig.initialValue, sig.parsed) ?? sig.initialValue;
6032
6390
  const prop2 = propsParamMap.get(propName);
6033
- if (prop2 && typeInfoToGo(ctx, prop2.type, prop2.defaultValue) === "bool")
6391
+ if (prop2 && typeInfoToGo(ctx, prop2.type, prop2.defaultValue, prop2.parsed) === "bool")
6034
6392
  return true;
6035
6393
  return false;
6036
6394
  }
6037
6395
  const prop = propsParamMap.get(name);
6038
- return !!prop && typeInfoToGo(ctx, prop.type, prop.defaultValue) === "bool";
6396
+ return !!prop && typeInfoToGo(ctx, prop.type, prop.defaultValue, prop.parsed) === "bool";
6039
6397
  };
6040
6398
  const ternary = c.match(/=>\s*\w+\(\)\s*\?\s*(\w+)\(\)\s*:\s*(\w+)\(\)/);
6041
6399
  if (ternary) {
@@ -6305,7 +6663,7 @@ function computeObjectMemoInitialValue(ctx, memo) {
6305
6663
  }
6306
6664
 
6307
6665
  // src/adapter/memo/template-interp.ts
6308
- import ts26 from "typescript";
6666
+ import ts28 from "typescript";
6309
6667
  function computeTemplateLiteralMemoInitialValue(ctx, memo, propsParams) {
6310
6668
  const localKeyBindings = new Map;
6311
6669
  let templateValue;
@@ -6528,7 +6886,8 @@ function memoInitialFromParsedBody(ctx, body, signals, propsParams, propFallback
6528
6886
  const hoisted = propFallbackVars.get(propName);
6529
6887
  if (hoisted)
6530
6888
  return hoisted.varName;
6531
- return `in.${capitalizeFieldName(propName)}`;
6889
+ const param = propsParams.find((p) => p.name === propName);
6890
+ return `in.${capitalizeFieldName(param?.sourceName ?? propName)}`;
6532
6891
  };
6533
6892
  const envGetKey = (e) => {
6534
6893
  if (e.kind !== "call" || e.callee.kind !== "member" || e.callee.computed)
@@ -6620,7 +6979,7 @@ function memoInitialFromParsedBody(ctx, body, signals, propsParams, propFallback
6620
6979
  const param = propsParams.find((p) => p.name === propName);
6621
6980
  if (param && ctx.state.nillablePropNames.has(propName)) {
6622
6981
  const isNe = body.op === "!==" || body.op === "!=";
6623
- return `in.${capitalizeFieldName(propName)} ${isNe ? "!=" : "=="} nil`;
6982
+ return `in.${capitalizeFieldName(param.sourceName ?? propName)} ${isNe ? "!=" : "=="} nil`;
6624
6983
  }
6625
6984
  }
6626
6985
  }
@@ -6692,7 +7051,7 @@ function memoInitialFromParsedBody(ctx, body, signals, propsParams, propFallback
6692
7051
  return `${hoisted.varName} ${operator} ${operand}`;
6693
7052
  const fieldName = capitalizeFieldName(propName);
6694
7053
  if (param.type) {
6695
- const goType = typeInfoToGo(ctx, param.type, param.defaultValue);
7054
+ const goType = typeInfoToGo(ctx, param.type, param.defaultValue, param.parsed);
6696
7055
  if (goType === "interface{}")
6697
7056
  return `in.${fieldName}.(int) ${operator} ${operand}`;
6698
7057
  }
@@ -6703,9 +7062,9 @@ function memoInitialFromParsedBody(ctx, body, signals, propsParams, propFallback
6703
7062
  const varName = body.left.name;
6704
7063
  const param = propsParams.find((p) => p.name === varName);
6705
7064
  if (param) {
6706
- const fieldName = capitalizeFieldName(varName);
7065
+ const fieldName = capitalizeFieldName(param.sourceName ?? varName);
6707
7066
  if (param.type) {
6708
- const goType = typeInfoToGo(ctx, param.type, param.defaultValue);
7067
+ const goType = typeInfoToGo(ctx, param.type, param.defaultValue, param.parsed);
6709
7068
  if (goType === "interface{}")
6710
7069
  return `in.${fieldName}.(int) ${operator} ${operand}`;
6711
7070
  }
@@ -6729,7 +7088,7 @@ function memoInitialFromParsedBody(ctx, body, signals, propsParams, propFallback
6729
7088
  if (body.kind === "identifier") {
6730
7089
  const param = propsParams.find((p) => p.name === body.name);
6731
7090
  if (param)
6732
- return `in.${capitalizeFieldName(body.name)}`;
7091
+ return `in.${capitalizeFieldName(param.sourceName ?? body.name)}`;
6733
7092
  }
6734
7093
  if (body.kind === "binary" && body.op === "+") {
6735
7094
  const concatGo = resolveStringConcatChainGo(ctx, body, signals, propsParams, propFallbackVars, propRef);
@@ -6791,7 +7150,8 @@ function resolveGetterValueAsGo(ctx, name, signals, propsParams, propFallbackVar
6791
7150
  const stripped = memo.computation.replace(/^\(\)\s*=>\s*/, "");
6792
7151
  const fb = ctx.extractPropFallback(stripped);
6793
7152
  if (fb && capitalizeFieldName(fb.propName) === capitalizeFieldName(memo.name)) {
6794
- const field = `in.${capitalizeFieldName(fb.propName)}`;
7153
+ const fbParam = propsParams.find((p) => p.name === fb.propName);
7154
+ const field = `in.${capitalizeFieldName(fbParam?.sourceName ?? fb.propName)}`;
6795
7155
  return `func() interface{} { v := interface{}(${field}); if v == nil || v == "" { return ${fb.goFallback} }; return v }()`;
6796
7156
  }
6797
7157
  return computeMemoInitialValueOrNull(ctx, memo, signals, propsParams, propFallbackVars, new Set([...resolving, memo.name]));
@@ -6799,7 +7159,7 @@ function resolveGetterValueAsGo(ctx, name, signals, propsParams, propFallbackVar
6799
7159
  const param = propsParams.find((p) => p.name === name);
6800
7160
  if (param) {
6801
7161
  const hoisted = propFallbackVars.get(name);
6802
- return hoisted ? hoisted.varName : `in.${capitalizeFieldName(name)}`;
7162
+ return hoisted ? hoisted.varName : `in.${capitalizeFieldName(param.sourceName ?? name)}`;
6803
7163
  }
6804
7164
  return null;
6805
7165
  }
@@ -6934,7 +7294,7 @@ function collectPropsReadByCtorInit(body, propsObjectName, propNames) {
6934
7294
  }
6935
7295
 
6936
7296
  // src/adapter/spread/spread-codegen.ts
6937
- import ts27 from "typescript";
7297
+ import ts29 from "typescript";
6938
7298
  function collectSpreadSlots(ctx, node) {
6939
7299
  const result = [];
6940
7300
  collectSpreadSlotsRecursive(ctx, node, result);
@@ -7059,10 +7419,10 @@ function buildSpreadInitializer(ctx, spreadExpr, ir, parsed) {
7059
7419
  if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(trimmed)) {
7060
7420
  const param = ir.metadata.propsParams.find((p) => p.name === trimmed);
7061
7421
  if (param) {
7062
- return `in.${capitalizeFieldName(param.name)}`;
7422
+ return `in.${capitalizeFieldName(param.sourceName ?? param.name)}`;
7063
7423
  }
7064
7424
  if (ir.metadata.propsObjectName === trimmed) {
7065
- const entries = ir.metadata.propsParams.map((p) => `${JSON.stringify(p.name)}: in.${capitalizeFieldName(p.name)}`);
7425
+ const entries = ir.metadata.propsParams.map((p) => `${JSON.stringify(p.sourceName ?? p.name)}: in.${capitalizeFieldName(p.sourceName ?? p.name)}`);
7066
7426
  return `map[string]any{${entries.join(", ")}}`;
7067
7427
  }
7068
7428
  if (ir.metadata.restPropsName === trimmed) {
@@ -7116,7 +7476,7 @@ function conditionToGoBool(condition, ir) {
7116
7476
  const param = ir.metadata.propsParams.find((p) => p.name === node.name);
7117
7477
  if (!param)
7118
7478
  return null;
7119
- const field = `in.${capitalizeFieldName(param.name)}`;
7479
+ const field = `in.${capitalizeFieldName(param.sourceName ?? param.name)}`;
7120
7480
  const prim = param.type.kind === "primitive" ? param.type.primitive : undefined;
7121
7481
  let truthy;
7122
7482
  if (prim === "boolean") {
@@ -7154,7 +7514,7 @@ function objectLiteralToGoSpreadMap(ctx, obj, ir) {
7154
7514
  const param = ir.metadata.propsParams.find((p) => p.name === val.name);
7155
7515
  if (!param)
7156
7516
  return null;
7157
- goVal = `in.${capitalizeFieldName(param.name)}`;
7517
+ goVal = `in.${capitalizeFieldName(param.sourceName ?? param.name)}`;
7158
7518
  } else {
7159
7519
  const indexed = recordIndexAccessToGoMap(ctx, val, ir);
7160
7520
  if (indexed === null)
@@ -7169,7 +7529,7 @@ function recordIndexAccessToGoMap(ctx, val, ir) {
7169
7529
  if (val.kind !== "index-access" || val.object.kind !== "identifier" || val.index.kind !== "identifier") {
7170
7530
  return null;
7171
7531
  }
7172
- const tsVal = ts27.factory.createElementAccessExpression(ts27.factory.createIdentifier(val.object.name), ts27.factory.createIdentifier(val.index.name));
7532
+ const tsVal = ts29.factory.createElementAccessExpression(ts29.factory.createIdentifier(val.object.name), ts29.factory.createIdentifier(val.index.name));
7173
7533
  const parsed = parseRecordIndexAccess(tsVal, ir.metadata.localConstants ?? [], ir.metadata.propsParams);
7174
7534
  if (!parsed)
7175
7535
  return null;
@@ -7178,7 +7538,8 @@ function recordIndexAccessToGoMap(ctx, val, ir) {
7178
7538
  return `${JSON.stringify(e.key)}: ${mapVal}`;
7179
7539
  });
7180
7540
  ctx.state.usesFmt = true;
7181
- const field = `in.${capitalizeFieldName(parsed.indexPropName)}`;
7541
+ const indexParam = ir.metadata.propsParams.find((p) => p.name === parsed.indexPropName);
7542
+ const field = `in.${capitalizeFieldName(indexParam?.sourceName ?? parsed.indexPropName)}`;
7182
7543
  return `map[string]any{${entries.join(", ")}}[fmt.Sprint(${field})]`;
7183
7544
  }
7184
7545
 
@@ -7194,9 +7555,9 @@ function buildPropTypeOverrides(ctx, ir) {
7194
7555
  const param = ir.metadata.propsParams.find((p) => p.name === propName);
7195
7556
  if (!param)
7196
7557
  continue;
7197
- const propGoType = typeInfoToGo(ctx, param.type, param.defaultValue);
7558
+ const propGoType = typeInfoToGo(ctx, param.type, param.defaultValue, param.parsed);
7198
7559
  if (propGoType.includes("interface{}")) {
7199
- const signalGoType = typeInfoToGo(ctx, signal.type, signal.initialValue);
7560
+ const signalGoType = typeInfoToGo(ctx, signal.type, signal.initialValue, signal.parsed);
7200
7561
  if (!signalGoType.includes("interface{}")) {
7201
7562
  overrides.set(propName, signalGoType);
7202
7563
  }
@@ -7207,7 +7568,7 @@ function buildPropTypeOverrides(ctx, ir) {
7207
7568
  const param = ir.metadata.propsParams.find((p) => p.name === propName);
7208
7569
  if (!param)
7209
7570
  continue;
7210
- const resolved = overrides.get(propName) ?? typeInfoToGo(ctx, param.type, param.defaultValue);
7571
+ const resolved = overrides.get(propName) ?? typeInfoToGo(ctx, param.type, param.defaultValue, param.parsed);
7211
7572
  if (resolved === "int") {
7212
7573
  overrides.set(propName, "float64");
7213
7574
  }
@@ -7377,7 +7738,7 @@ function collectPresenceCheckedPropNames(ctx, ir) {
7377
7738
  return names;
7378
7739
  }
7379
7740
  function resolvePropGoType(ctx, param, propTypeOverrides) {
7380
- const base = propTypeOverrides.get(param.name) ?? typeInfoToGo(ctx, param.type, param.defaultValue);
7741
+ const base = propTypeOverrides.get(param.name) ?? typeInfoToGo(ctx, param.type, param.defaultValue, param.parsed);
7381
7742
  if (param.optional && ctx.state.localStructFields.has(base)) {
7382
7743
  return "map[string]interface{}";
7383
7744
  }
@@ -7764,6 +8125,18 @@ ${scriptRegistrations}${templateBody}
7764
8125
  nonCollidingContextConsumers(taken) {
7765
8126
  return this.state.contextConsumers.filter((c) => !taken.has(this.contextFieldName(c)));
7766
8127
  }
8128
+ isNestedArrayShadowed(param, nestedArrayFields) {
8129
+ return nestedArrayFields.has(capitalizeFieldName(param.name)) || nestedArrayFields.has(capitalizeFieldName(param.sourceName ?? param.name));
8130
+ }
8131
+ propParamFieldNamesUnion(params) {
8132
+ return params.flatMap((p) => [capitalizeFieldName(p.name), capitalizeFieldName(p.sourceName ?? p.name)]);
8133
+ }
8134
+ claimJsonTag(desired, taken) {
8135
+ if (taken.has(desired))
8136
+ return "-";
8137
+ taken.add(desired);
8138
+ return desired;
8139
+ }
7767
8140
  generateTypes(ir) {
7768
8141
  this.state.usesHtmlTemplate = false;
7769
8142
  this.state.usesFmt = false;
@@ -7794,13 +8167,16 @@ ${scriptRegistrations}${templateBody}
7794
8167
  if (!this.childDerivedFieldDeps.has(componentName))
7795
8168
  return;
7796
8169
  const nestedArrayFields = new Set(nestedComponents.map((n) => `${n.name}s`));
7797
- const params = (ir.metadata.propsParams ?? []).filter((p) => !nestedArrayFields.has(capitalizeFieldName(p.name)));
7798
- const takenInput = new Set((ir.metadata.propsParams ?? []).map((p) => capitalizeFieldName(p.name)));
8170
+ const params = (ir.metadata.propsParams ?? []).filter((p) => !this.isNestedArrayShadowed(p, nestedArrayFields));
8171
+ const takenInput = new Set(this.propParamFieldNamesUnion(ir.metadata.propsParams ?? []));
7799
8172
  const eligible = nestedComponents.every((n) => n.isDynamic && !n.isPropDerived) && spreadSlots.length === 0 && !ir.metadata.restPropsName && this.nonCollidingContextConsumers(takenInput).length === 0;
7800
8173
  if (!eligible)
7801
8174
  return;
7802
8175
  this.childRepropsReady.set(componentName, {
7803
- params: params.map((p) => capitalizeFieldName(p.name)),
8176
+ params: params.map((p) => ({
8177
+ propsField: capitalizeFieldName(p.name),
8178
+ inputField: capitalizeFieldName(p.sourceName ?? p.name)
8179
+ })),
7804
8180
  usesSearchParams: this.usesSearchParams(ir)
7805
8181
  });
7806
8182
  }
@@ -7836,17 +8212,17 @@ ${scriptRegistrations}${templateBody}
7836
8212
  lines.push("\t\t\tBfMount: b.BfMount,");
7837
8213
  if (usesSearchParams)
7838
8214
  lines.push("\t\t\tSearchParams: b.SearchParams,");
7839
- for (const field of params) {
7840
- lines.push(` ${field}: b.${field},`);
8215
+ for (const { propsField, inputField } of params) {
8216
+ lines.push(` ${inputField}: b.${propsField},`);
7841
8217
  }
7842
8218
  lines.push("\t\t}");
7843
8219
  lines.push("\t\tfor i := 0; i < len(kv); i += 2 {");
7844
8220
  lines.push("\t\t\tname, _ := kv[i].(string)");
7845
8221
  lines.push("\t\t\tvar err error");
7846
8222
  lines.push("\t\t\tswitch name {");
7847
- for (const field of params) {
7848
- lines.push(` case ${JSON.stringify(field)}:`);
7849
- lines.push(` err = bf.RepropsAssign(${q}, ${JSON.stringify(field)}, &in.${field}, kv[i+1])`);
8223
+ for (const { propsField, inputField } of params) {
8224
+ lines.push(` case ${JSON.stringify(propsField)}:`);
8225
+ lines.push(` err = bf.RepropsAssign(${q}, ${JSON.stringify(propsField)}, &in.${inputField}, kv[i+1])`);
7850
8226
  }
7851
8227
  lines.push("\t\t\tdefault:");
7852
8228
  lines.push(` err = bf.RepropsUnknownFieldError(${q}, name)`);
@@ -7984,6 +8360,7 @@ ${goFields.join(`
7984
8360
  return false;
7985
8361
  const taken = new Set([
7986
8362
  ...ir.metadata.propsParams.map((p) => capitalizeFieldName(p.name)),
8363
+ ...ir.metadata.propsParams.map((p) => capitalizeFieldName(p.sourceName ?? p.name)),
7987
8364
  ...ir.metadata.signals.filter((s) => !s.envReader).map((s) => capitalizeFieldName(s.getter)),
7988
8365
  ...ir.metadata.memos.map((m) => capitalizeFieldName(m.name)),
7989
8366
  ...this.state.contextConsumers.map((c) => this.contextFieldName(c))
@@ -8006,8 +8383,8 @@ ${goFields.join(`
8006
8383
  const inputNested = nestedComponents.filter((n) => !n.isDynamic || n.isPropDerived);
8007
8384
  const nestedArrayFields = new Set(nestedComponents.map((n) => `${n.name}s`));
8008
8385
  for (const param of ir.metadata.propsParams) {
8009
- const fieldName = capitalizeFieldName(param.name);
8010
- if (nestedArrayFields.has(fieldName))
8386
+ const fieldName = capitalizeFieldName(param.sourceName ?? param.name);
8387
+ if (this.isNestedArrayShadowed(param, nestedArrayFields))
8011
8388
  continue;
8012
8389
  const goType = resolvePropGoType(this.emitCtx, param, propTypeOverrides);
8013
8390
  lines.push(` ${fieldName} ${goType}`);
@@ -8017,7 +8394,7 @@ ${goFields.join(`
8017
8394
  continue;
8018
8395
  lines.push(` ${nested.name}s []${nested.name}Input`);
8019
8396
  }
8020
- const takenInput = new Set(ir.metadata.propsParams.map((p) => capitalizeFieldName(p.name)));
8397
+ const takenInput = new Set(this.propParamFieldNamesUnion(ir.metadata.propsParams));
8021
8398
  for (const c of this.nonCollidingContextConsumers(takenInput)) {
8022
8399
  lines.push(` ${this.contextFieldName(c)} ${this.contextConsumerGoType(c)}`);
8023
8400
  }
@@ -8041,8 +8418,9 @@ ${goFields.join(`
8041
8418
  generatePropsStruct(lines, ir, componentName, nestedComponents, propTypeOverrides, spreadSlots) {
8042
8419
  const propsTypeName = `${componentName}Props`;
8043
8420
  this.emitPropsStructHeader(lines, ir, propsTypeName, componentName);
8044
- this.emitPropsDataFields(lines, ir, nestedComponents, propTypeOverrides);
8045
- this.emitPropsAuxFields(lines, ir, componentName, nestedComponents, spreadSlots);
8421
+ const takenJsonTags = new Set;
8422
+ this.emitPropsDataFields(lines, ir, nestedComponents, propTypeOverrides, takenJsonTags);
8423
+ this.emitPropsAuxFields(lines, ir, componentName, nestedComponents, spreadSlots, takenJsonTags);
8046
8424
  lines.push("}");
8047
8425
  lines.push("");
8048
8426
  }
@@ -8079,7 +8457,7 @@ ${goFields.join(`
8079
8457
  resolveLoopDatumFields(itemType) {
8080
8458
  if (!itemType)
8081
8459
  return [];
8082
- const typeName = itemType.raw?.replace(/\[\]$/, "") ?? itemType.raw;
8460
+ const typeName = itemType.kind === "array" ? itemType.elementType?.raw ?? itemType.raw : itemType.raw;
8083
8461
  if (!typeName)
8084
8462
  return [];
8085
8463
  for (const td of this.state.currentTypeDefinitions) {
@@ -8242,7 +8620,8 @@ ${goFields.join(`
8242
8620
  const propFieldNames = new Set;
8243
8621
  for (const param of ir.metadata.propsParams) {
8244
8622
  const fieldName = capitalizeFieldName(param.name);
8245
- if (nestedArrayFields.has(fieldName))
8623
+ const inputField = capitalizeFieldName(param.sourceName ?? param.name);
8624
+ if (this.isNestedArrayShadowed(param, nestedArrayFields))
8246
8625
  continue;
8247
8626
  const hoisted = propFallbackVars.get(param.name);
8248
8627
  if (hoisted) {
@@ -8251,13 +8630,13 @@ ${goFields.join(`
8251
8630
  const paramDefault = goPropDefault(param.defaultValue);
8252
8631
  const memoFold = memoFallbacks.get(fieldName);
8253
8632
  if (paramDefault !== null) {
8254
- lines.push(` ${fieldName}: ${applyGoFallback(`in.${fieldName}`, paramDefault)},`);
8633
+ lines.push(` ${fieldName}: ${applyGoFallback(`in.${inputField}`, paramDefault)},`);
8255
8634
  } else if (memoFold !== undefined && memoFold.goType === "string") {
8256
- lines.push(` ${fieldName}: ${applyGoFallback(`in.${fieldName}`, memoFold.goFallback)},`);
8635
+ lines.push(` ${fieldName}: ${applyGoFallback(`in.${inputField}`, memoFold.goFallback)},`);
8257
8636
  } else if (memoFold !== undefined) {
8258
- lines.push(` ${fieldName}: func() interface{} { v := interface{}(in.${fieldName}); if v == nil || v == "" { return ${memoFold.goFallback} }; return v }(),`);
8637
+ lines.push(` ${fieldName}: func() interface{} { v := interface{}(in.${inputField}); if v == nil || v == "" { return ${memoFold.goFallback} }; return v }(),`);
8259
8638
  } else {
8260
- lines.push(` ${fieldName}: in.${fieldName},`);
8639
+ lines.push(` ${fieldName}: in.${inputField},`);
8261
8640
  }
8262
8641
  }
8263
8642
  propFieldNames.add(fieldName);
@@ -8310,7 +8689,7 @@ ${goFields.join(`
8310
8689
  lines.push(` ${f.name}: ${f.init},`);
8311
8690
  }
8312
8691
  const takenInit = new Set([
8313
- ...ir.metadata.propsParams.map((p) => capitalizeFieldName(p.name)),
8692
+ ...this.propParamFieldNamesUnion(ir.metadata.propsParams),
8314
8693
  ...ir.metadata.signals.map((s) => capitalizeFieldName(s.getter)),
8315
8694
  ...ir.metadata.memos.map((m) => capitalizeFieldName(m.name))
8316
8695
  ]);
@@ -8349,7 +8728,7 @@ ${goFields.join(`
8349
8728
  }
8350
8729
  if (jsxName.includes("-"))
8351
8730
  return;
8352
- const fieldName = this.childPropFieldNames.get(child.name)?.get(jsxName) ?? capitalizeFieldName(jsxName);
8731
+ const fieldName = capitalizeFieldName(jsxName);
8353
8732
  lines.push(` ${fieldName}: ${goValue},`);
8354
8733
  };
8355
8734
  for (const prop of child.props) {
@@ -8718,15 +9097,15 @@ ${goFields.join(`
8718
9097
  lines.push('\tSearchParams bf.SearchParams `json:"-"`');
8719
9098
  }
8720
9099
  }
8721
- emitPropsDataFields(lines, ir, nestedComponents, propTypeOverrides) {
9100
+ emitPropsDataFields(lines, ir, nestedComponents, propTypeOverrides, takenJsonTags) {
8722
9101
  const nestedArrayFields = new Set(nestedComponents.map((n) => `${n.name}s`));
8723
9102
  const propFieldNames = new Set;
8724
9103
  for (const param of ir.metadata.propsParams) {
8725
9104
  const fieldName = capitalizeFieldName(param.name);
8726
- if (nestedArrayFields.has(fieldName))
9105
+ if (this.isNestedArrayShadowed(param, nestedArrayFields))
8727
9106
  continue;
8728
9107
  const goType = resolvePropGoType(this.emitCtx, param, propTypeOverrides);
8729
- const jsonTag = param.name === "children" ? "-" : this.toJsonTag(param.name);
9108
+ const jsonTag = param.name === "children" ? "-" : this.claimJsonTag(this.toJsonTag(param.sourceName ?? param.name), takenJsonTags);
8730
9109
  lines.push(` ${fieldName} ${goType} \`json:"${jsonTag}"\``);
8731
9110
  propFieldNames.add(fieldName);
8732
9111
  }
@@ -8737,7 +9116,7 @@ ${goFields.join(`
8737
9116
  const fieldName = capitalizeFieldName(signal.getter);
8738
9117
  if (propFieldNames.has(fieldName))
8739
9118
  continue;
8740
- const jsonTag = this.toJsonTag(signal.getter);
9119
+ const jsonTag = this.claimJsonTag(this.toJsonTag(signal.getter), takenJsonTags);
8741
9120
  const synthType = this.state.synthStructTypes.get(signal.getter);
8742
9121
  if (synthType) {
8743
9122
  lines.push(` ${fieldName} ${typeInfoToGo(this.emitCtx, synthType)} \`json:"${jsonTag}"\``);
@@ -8746,13 +9125,13 @@ ${goFields.join(`
8746
9125
  let goType;
8747
9126
  let referencedProp = propsParamMap.get(signal.initialValue);
8748
9127
  if (!referencedProp) {
8749
- const propName = this.extractPropNameFromInitialValue(signal.initialValue);
9128
+ const propName = this.extractPropNameFromInitialValue(signal.initialValue, signal.parsed);
8750
9129
  if (propName)
8751
9130
  referencedProp = propsParamMap.get(propName);
8752
9131
  }
8753
9132
  if (referencedProp) {
8754
- const propGoType = typeInfoToGo(this.emitCtx, referencedProp.type, referencedProp.defaultValue);
8755
- const signalGoType = typeInfoToGo(this.emitCtx, signal.type, signal.initialValue);
9133
+ const propGoType = typeInfoToGo(this.emitCtx, referencedProp.type, referencedProp.defaultValue, referencedProp.parsed);
9134
+ const signalGoType = typeInfoToGo(this.emitCtx, signal.type, signal.initialValue, signal.parsed);
8756
9135
  if (propGoType.includes("interface{}")) {
8757
9136
  goType = signalGoType;
8758
9137
  } else if (!signalGoType.includes("interface{}") && signalGoType !== propGoType) {
@@ -8761,7 +9140,7 @@ ${goFields.join(`
8761
9140
  goType = propGoType;
8762
9141
  }
8763
9142
  } else {
8764
- goType = typeInfoToGo(this.emitCtx, signal.type, signal.initialValue);
9143
+ goType = typeInfoToGo(this.emitCtx, signal.type, signal.initialValue, signal.parsed);
8765
9144
  }
8766
9145
  lines.push(` ${fieldName} ${goType} \`json:"${jsonTag}"\``);
8767
9146
  }
@@ -8769,12 +9148,12 @@ ${goFields.join(`
8769
9148
  const fieldName = capitalizeFieldName(memo.name);
8770
9149
  if (propFieldNames.has(fieldName))
8771
9150
  continue;
8772
- const jsonTag = this.toJsonTag(memo.name);
9151
+ const jsonTag = this.claimJsonTag(this.toJsonTag(memo.name), takenJsonTags);
8773
9152
  const goType = this.inferMemoType(memo, ir.metadata.signals, propsParamMap);
8774
9153
  lines.push(` ${fieldName} ${goType} \`json:"${jsonTag}"\``);
8775
9154
  }
8776
9155
  }
8777
- emitPropsAuxFields(lines, ir, componentName, nestedComponents, spreadSlots) {
9156
+ emitPropsAuxFields(lines, ir, componentName, nestedComponents, spreadSlots, takenJsonTags) {
8778
9157
  const takenForDerivedConsts = new Set([
8779
9158
  ...ir.metadata.propsParams.map((p) => capitalizeFieldName(p.name)),
8780
9159
  ...ir.metadata.signals.map((s) => capitalizeFieldName(s.getter)),
@@ -8784,12 +9163,12 @@ ${goFields.join(`
8784
9163
  lines.push(` ${f.name} string \`json:"-"\``);
8785
9164
  }
8786
9165
  const takenProps = new Set([
8787
- ...ir.metadata.propsParams.map((p) => capitalizeFieldName(p.name)),
9166
+ ...this.propParamFieldNamesUnion(ir.metadata.propsParams),
8788
9167
  ...ir.metadata.signals.map((s) => capitalizeFieldName(s.getter)),
8789
9168
  ...ir.metadata.memos.map((m) => capitalizeFieldName(m.name))
8790
9169
  ]);
8791
9170
  for (const c of this.nonCollidingContextConsumers(takenProps)) {
8792
- const jsonTag = this.toJsonTag(c.localName);
9171
+ const jsonTag = this.claimJsonTag(this.toJsonTag(c.localName), takenJsonTags);
8793
9172
  lines.push(` ${this.contextFieldName(c)} ${this.contextConsumerGoType(c)} \`json:"${jsonTag}"\``);
8794
9173
  }
8795
9174
  for (const nested of nestedComponents) {
@@ -8797,7 +9176,7 @@ ${goFields.join(`
8797
9176
  if (nested.isDynamic && !nested.isPropDerived) {
8798
9177
  lines.push(` ${nested.name}s []${elemType} \`json:"-"\``);
8799
9178
  } else {
8800
- const jsonTag = this.toJsonTag(`${nested.name.charAt(0).toLowerCase()}${nested.name.slice(1)}s`);
9179
+ const jsonTag = this.claimJsonTag(this.toJsonTag(`${nested.name.charAt(0).toLowerCase()}${nested.name.slice(1)}s`), takenJsonTags);
8801
9180
  lines.push(` ${nested.name}s []${elemType} \`json:"${jsonTag}"\``);
8802
9181
  }
8803
9182
  }
@@ -8806,7 +9185,7 @@ ${goFields.join(`
8806
9185
  lines.push(` ${child.fieldName} ${child.name}Props \`json:"-"\``);
8807
9186
  }
8808
9187
  for (const slot of spreadSlots) {
8809
- const jsonTag = this.toJsonTag(slot.slotId);
9188
+ const jsonTag = this.claimJsonTag(this.toJsonTag(slot.slotId), takenJsonTags);
8810
9189
  lines.push(` ${slot.slotId} map[string]any \`json:"${jsonTag}"\``);
8811
9190
  }
8812
9191
  }
@@ -8982,8 +9361,9 @@ ${goFields.join(`
8982
9361
  return literal;
8983
9362
  if (node.kind === "logical" && node.op === "??" && node.right.kind === "object-literal" && node.right.properties.length === 0 && node.left.kind === "member" && !node.left.computed && node.left.object.kind === "identifier" && node.left.object.name === this.state.propsObjectName) {
8984
9363
  const propName = node.left.property;
8985
- if (propsParams.some((param) => param.name === propName)) {
8986
- const fieldRef = `in.${capitalizeFieldName(propName)}`;
9364
+ const matchedParam = propsParams.find((param) => param.name === propName);
9365
+ if (matchedParam) {
9366
+ const fieldRef = `in.${capitalizeFieldName(matchedParam.sourceName ?? matchedParam.name)}`;
8987
9367
  return `func() map[string]interface{} { ` + `if m := bf.AsMap(${fieldRef}); m != nil { return m }; ` + `return map[string]interface{}{} }()`;
8988
9368
  }
8989
9369
  }
@@ -9001,7 +9381,7 @@ ${goFields.join(`
9001
9381
  const param = propsParams.find((p) => p.name === keyExpr);
9002
9382
  if (!param)
9003
9383
  return null;
9004
- const fieldName = capitalizeFieldName(keyExpr);
9384
+ const fieldName = capitalizeFieldName(param.sourceName ?? keyExpr);
9005
9385
  const caseEntries = Object.entries(part.cases);
9006
9386
  if (caseEntries.length === 0) {
9007
9387
  segments.push('""');
@@ -9064,8 +9444,9 @@ ${goFields.join(`
9064
9444
  const localConst = this.state.localConstants.find((c) => c.name === passthroughName);
9065
9445
  const isPropsDestructureAlias = localConst !== undefined && propsObjectName !== null && localConst.value === `${propsObjectName}.${passthroughName}`;
9066
9446
  const shadowedByLocal = passthroughName !== null && (localConst !== undefined && !isPropsDestructureAlias || this.state.localHelperNames.has(passthroughName));
9067
- if (passthroughName && !shadowedByLocal && propsParams.some((p) => p.name === passthroughName)) {
9068
- return `in.${capitalizeFieldName(passthroughName)}`;
9447
+ const passthroughParam = passthroughName && !shadowedByLocal ? propsParams.find((p) => p.name === passthroughName) : undefined;
9448
+ if (passthroughParam) {
9449
+ return `in.${capitalizeFieldName(passthroughParam.sourceName ?? passthroughParam.name)}`;
9069
9450
  }
9070
9451
  return null;
9071
9452
  }
@@ -9080,17 +9461,17 @@ ${goFields.join(`
9080
9461
  if (signal) {
9081
9462
  let referencedProp = propsParamMap.get(signal.initialValue);
9082
9463
  if (!referencedProp) {
9083
- const propName = this.extractPropNameFromInitialValue(signal.initialValue);
9464
+ const propName = this.extractPropNameFromInitialValue(signal.initialValue, signal.parsed);
9084
9465
  if (propName)
9085
9466
  referencedProp = propsParamMap.get(propName);
9086
9467
  }
9087
9468
  if (referencedProp) {
9088
- const propType = typeInfoToGo(this.emitCtx, referencedProp.type, referencedProp.defaultValue);
9469
+ const propType = typeInfoToGo(this.emitCtx, referencedProp.type, referencedProp.defaultValue, referencedProp.parsed);
9089
9470
  if (propType === "int" || propType === "float64") {
9090
9471
  return "int";
9091
9472
  }
9092
9473
  }
9093
- const signalType = typeInfoToGo(this.emitCtx, signal.type, signal.initialValue);
9474
+ const signalType = typeInfoToGo(this.emitCtx, signal.type, signal.initialValue, signal.parsed);
9094
9475
  if (signalType === "int" || signalType === "float64") {
9095
9476
  return "int";
9096
9477
  }
@@ -9127,8 +9508,8 @@ ${goFields.join(`
9127
9508
  continue;
9128
9509
  if (goPropDefault(param.defaultValue) !== null)
9129
9510
  continue;
9130
- const fieldName = capitalizeFieldName(match.propName);
9131
- const concreteType = propTypeOverrides.get(param.name) ?? typeInfoToGo(this.emitCtx, param.type, param.defaultValue);
9511
+ const fieldName = capitalizeFieldName(param.sourceName ?? match.propName);
9512
+ const concreteType = propTypeOverrides.get(param.name) ?? typeInfoToGo(this.emitCtx, param.type, param.defaultValue, param.parsed);
9132
9513
  const nullishLowered = NULLISH_SCALAR_GO_TYPES.has(concreteType) && resolvePropGoType(this.emitCtx, param, propTypeOverrides) === "interface{}";
9133
9514
  let zeroLiteral;
9134
9515
  if (match.goFallback === "true" || match.goFallback === "false") {