Skip to content

Commit daf70fd

Browse files
committed
fix(ts-wrappers): fix TypeScript wrappers generation for messages with single quote
Fixes #972
1 parent 229ce26 commit daf70fd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/bindings/writeTypescript.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,12 @@ export function writeTypescript(
352352
r.message.text !== null &&
353353
r.message.text !== undefined
354354
) {
355-
receivers.push(`'${r.message.text}'`);
355+
// since we are using single quotes, escape them in the message name
356+
const escaped = r.message.text.replace(
357+
/'/g,
358+
"\\'",
359+
);
360+
receivers.push(`'${escaped}'`);
356361
} else {
357362
receivers.push(`string`);
358363
}
@@ -419,9 +424,12 @@ export function writeTypescript(
419424
});
420425
w.append(`}`);
421426
} else {
422-
w.append(
423-
`if (message === '${msg.text}') {`,
427+
// since we are using single quotes, escape them in the message name
428+
const escaped = msg.text.replace(
429+
/'/g,
430+
"\\'",
424431
);
432+
w.append(`if (message === '${escaped}') {`);
425433
w.inIndent(() => {
426434
w.append(
427435
`body = beginCell().storeUint(0, 32).storeStringTail(message).endCell();`,

0 commit comments

Comments
 (0)