Typescript: Spurious error: [ts] Duplicate function implementation

Created on 9 Sep 2016  路  10Comments  路  Source: microsoft/TypeScript

_From @garthk on September 9, 2016 1:37_

  • VSCode Version: 1.5.0-insider 4fc690be310dd02e0ab6529c0b9bf348a8b26a19
  • OS Version: macOS 10.11.6 (15G1004)

Steps to Reproduce:

  1. vscode-insiders .
  2. Edit src/big-file.ts, which is too long and stuffed with unrelated concerns
  3. vscode-insiders -r src/extracted-function.ts
  4. Cut a function out of src/big-file.ts
  5. Paste it into src/extracted-function.ts
  6. Observe red underline under the function name
  7. Select it
  8. Observe error: [ts] Duplicate function implementation.
  9. Close src/extracted-function.ts
  10. Re-open src/extracted-function.ts
  11. Observe no red underline under the function name

Perhaps unrelated to #9880.

_Copied from original issue: Microsoft/vscode#11733_

Most helpful comment

Got it working... As @mhegazy mentioned, just add tsconfig.json file to your project and done.

You can generate the file using a simple command. Open terminal and type "tsc -init".

All 10 comments

I can not reproduce this locally on latest. closing for now. please reopen if still an issue.

Still have that Problem with VSCODE 1.10.1 on MAC

happens when i copy paste the contents of greeter.ts from: https://www.typescriptlang.org/docs/tutorial.html

i selected the previous code and copy paste the next one into the same file. The error happens nearly every time and does not vanish with a git commit or push. only a restart of vscode fixes it. please open it again.

screen shot 2017-03-07 at 19 23 34

Having the same exact problem on OSX.

Version 1.10.2 (1.10.2)

image

Please advise

Add a tsconfig.json to the root of your project.

Can you help me with this, I m still facing the duplicate function implementation issue.
image

Got it working... As @mhegazy mentioned, just add tsconfig.json file to your project and done.

You can generate the file using a simple command. Open terminal and type "tsc -init".

I have added tsconfig.js to my project. Otherwise, the same problem still exists. why?

Ok, I've been able to reproduce this and find a workaround for fixing it:

To reproduce

  1. create a new .ts file with a trivial function
  2. compile the file
  3. open the COMPILED .JS file in the same editor window (e.g. in another tab)
  4. go back to the typescript tab and resume coding (e.g. add another few lines)
  5. now you should see the error

TO FIX

as mentioned before do tsc -init to initialize a tsconfig.json file in the same subfolder

thanks... this help

Creating tsconfig.js with the command line helped me too. Thank you! Gotta remember to initiate tsc project.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weswigham picture weswigham  路  3Comments

jbondc picture jbondc  路  3Comments

bgrieder picture bgrieder  路  3Comments

blendsdk picture blendsdk  路  3Comments

Antony-Jones picture Antony-Jones  路  3Comments