Skip to content

Commit da07227

Browse files
committed
Fix #1667 multiline function arguments support in REPL
1 parent 20cbbf5 commit da07227

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/repl.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ const RECOVERY_CODES: Set<number> = new Set([
680680
1160, // "Unterminated template literal."
681681
1161, // "Unterminated regular expression literal."
682682
2355, // "A function whose declared type is neither 'void' nor 'any' must return a value."
683+
2391, // "Function implementation is missing or not immediately following the declaration."
684+
7010, // "Function, which lacks return-type annotation, implicitly has an 'any' return type."
683685
]);
684686

685687
/**

src/test/repl/repl.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,29 @@ test.suite(
424424
expect(stdout).toContain(":1:1'\n");
425425
}
426426
);
427+
428+
// Serial because it's timing-sensitive
429+
test.serial(
430+
'multiline function args declaration is supported',
431+
async (t) => {
432+
const script = `function myFn(
433+
a: string,
434+
b: string
435+
) {
436+
return a + ' ' + b
437+
}
438+
myFn('test', '!')
439+
`;
440+
441+
const { stdout, stderr } = await t.context.executeInRepl(script, {
442+
registerHooks: true,
443+
startInternalOptions: { useGlobal: false },
444+
waitPattern: 'done!',
445+
});
446+
expect(stderr).toBe('');
447+
expect(stdout).toContain(`'test !'`);
448+
}
449+
);
427450
}
428451
);
429452

0 commit comments

Comments
 (0)