Every callback in the last lesson took a fixed number of arguments, and every call passed all of them. The fixture emails don’t work that way. Most fixtures are on the league’s main pitch, so a volunteer writing a subject line shouldn’t have to name it every time. A postponement notice goes to every team it affects, which can be two teams or six.
In this lesson, you’ll type parameters that callers can leave out and a parameter that collects any number of arguments. You’ll also write function types that describe both. Start with the pitch that most callers would rather skip.
Leave Out an Argument
Every parameter is required unless you mark it otherwise, so the checker reports any call that leaves one out. The fixture emails build their subject lines with a helper written in plain JavaScript. In your Riverside project, create a file called fixture-helpers.ts with that helper and two calls:
function subjectLine(team, kickoff, pitch) {
return `${team}: kickoff ${kickoff} at ${pitch}`;
}
console.log(subjectLine("Kestrel Park", "2026-09-12T10:30", "Pitch 2"));
console.log(subjectLine("Riverside Lions", "2026-09-12T12:00"));
The second call leaves out the pitch, as a volunteer would for a match on the main one. Node.js runs the file anyway and prints Riverside Lions: kickoff 2026-09-12T12:00 at undefined. Annotate the three parameters as strings so line 1 reads:
function subjectLine(team: string, kickoff: string, pitch: string) {
Then run npm run check to see what the checker makes of the two calls:
$ npm run check
> [email protected] check
> tsc --noEmit
fixture-helpers.ts:6:13 - error TS2554: Expected 3 arguments, but got 2.
6 console.log(subjectLine("Riverside Lions", "2026-09-12T12:00"));
~~~~~~~~~~~
fixture-helpers.ts:1:53 - An argument for 'pitch' was not provided.
1 function subjectLine(team: string, kickoff: string, pitch: string) {
~~~~~~~~~~~~~
Found 1 error in fixture-helpers.ts:6