@kubb/plugin-ts 5.0.0-alpha.27 → 5.0.0-alpha.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1747,7 +1747,8 @@ const functionPrinter = defineFunctionPrinter((options) => ({
1747
1747
  if (node.variant === "member") return `${node.base}['${node.key}']`;
1748
1748
  if (node.variant === "struct") return `{ ${node.properties.map((p) => {
1749
1749
  const typeStr = this.transform(p.type);
1750
- return p.optional ? `${p.name}?: ${typeStr}` : `${p.name}: ${typeStr}`;
1750
+ const key = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p.name) ? p.name : JSON.stringify(p.name);
1751
+ return p.optional ? `${key}?: ${typeStr}` : `${key}: ${typeStr}`;
1751
1752
  }).join("; ")} }`;
1752
1753
  if (node.variant === "reference") return node.name;
1753
1754
  return null;