Skip to content

Commit

Permalink
Fix #1667 multiline function arguments support in REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
d9k committed Mar 4, 2022
1 parent 20cbbf5 commit da07227
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,8 @@ const RECOVERY_CODES: Set<number> = new Set([
1160, // "Unterminated template literal."
1161, // "Unterminated regular expression literal."
2355, // "A function whose declared type is neither 'void' nor 'any' must return a value."
2391, // "Function implementation is missing or not immediately following the declaration."
7010, // "Function, which lacks return-type annotation, implicitly has an 'any' return type."
]);

/**
Expand Down
23 changes: 23 additions & 0 deletions src/test/repl/repl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,29 @@ test.suite(
expect(stdout).toContain(":1:1'\n");
}
);

// Serial because it's timing-sensitive
test.serial(
'multiline function args declaration is supported',
async (t) => {
const script = `function myFn(
a: string,
b: string
) {
return a + ' ' + b
}
myFn('test', '!')
`;

const { stdout, stderr } = await t.context.executeInRepl(script, {
registerHooks: true,
startInternalOptions: { useGlobal: false },
waitPattern: 'done!',
});
expect(stderr).toBe('');
expect(stdout).toContain(`'test !'`);
}
);
}
);

Expand Down

0 comments on commit da07227

Please sign in to comment.