Just diving into the world of TypeScript and currently following along with the tutorial titled TypeScript in 5 minutes. As I progress through the guide, an intriguing issue arises when I hover over the greeter
function name in Visual Studio Code. A peculiar warning message pops up, as depicted in the image below:
[ts] Duplicate function implementation.
function greeter(person: Person): string (+1 overload)
https://i.sstatic.net/i2brP.png
Despite my single file containing only one implementation of this particular function, the error persists when I run tsc greeter.ts
, eventually generating the expected js file.
The entirety of the greeter.ts
contents can be found below:
interface Person {
firstName: string;
lastName: string;
}
function greeter(person: Person) {
return "Hello, " + person.firstName + " " + person.lastName;
}
var user = { firstName: "Jane", lastName: "User" };
console.log(greeter(user));
What could be causing this unexpected alert? Is there a solution to resolve it? While I did come across this question, I don't think it's relevant to my situation.