This repository demonstrates a common TypeScript error: passing an array to a function that expects a string. The bug occurs because the greeter
function is explicitly typed to accept a single string argument, while an array is passed.
The solution demonstrates how to correctly handle this scenario, either by modifying the function signature to accept an array or by iterating over the array and calling the function for each element.
- Clone this repository.
- Open
bug.ts
. - Run
tsc bug.ts
and thennode bug.js
. You'll see a compilation error because the array is being passed into the function expecting a string.
The solution is provided in bugSolution.ts