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

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.cjs CHANGED
@@ -1771,7 +1771,8 @@ const functionPrinter = defineFunctionPrinter((options) => ({
1771
1771
  if (node.variant === "member") return `${node.base}['${node.key}']`;
1772
1772
  if (node.variant === "struct") return `{ ${node.properties.map((p) => {
1773
1773
  const typeStr = this.transform(p.type);
1774
- return p.optional ? `${p.name}?: ${typeStr}` : `${p.name}: ${typeStr}`;
1774
+ const key = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p.name) ? p.name : JSON.stringify(p.name);
1775
+ return p.optional ? `${key}?: ${typeStr}` : `${key}: ${typeStr}`;
1775
1776
  }).join("; ")} }`;
1776
1777
  if (node.variant === "reference") return node.name;
1777
1778
  return null;