@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.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/printers/functionPrinter.ts +2 -1
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
|
-
|
|
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;
|