Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  16] [ 4]  / answers: 1 / hits: 27200  / 7 Years ago, fri, may 26, 2017, 12:00:00

I'm getting started with TypeScript and at moment I'm following the TypeScript in 5 minutes guide. I'm receiving a strange warning in Visual Studio Code when I hover the mouse over the greeter function name, as shown in the below image. The alert is:




[ts] Duplicate function implementation.



function greeter(person: Person): string (+1 overload)




Duplicate



But there is no other implementation of this unique function in my single file! When I run tsc greeter.ts all works fine and the js file is generated.



The complete greeter.ts file:



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));


Why am I receiving this alert? How to solve it? I took a look in this question, but I believe it isn't related.


More From » typescript

 Answers
64

Looks like this is a bug in Visual Studio Code. There are a few issues on GitHub about this, such as here and here. The comments on the issues imply that it was an issue, then was fixed, and has just become an issue again in v1.12.1.



It looks as if the solution is to run tsc --init to initialize the tsconfig.json in the folder.


[#57657] Tuesday, May 23, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ericmaximilianz

Total Points: 252
Total Questions: 118
Total Answers: 87

Location: Virgin Islands (U.S.)
Member since Tue, Jul 7, 2020
4 Years ago
;