sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

import MockHttpClient from './MockHttpClient'; given issues TS2306 file is not module.

Open gzhou2018 opened this issue 8 years ago • 3 comments

Any advise?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

gzhou2018 avatar Jun 25 '18 13:06 gzhou2018

This most likely indicates a typo in the file or placing the file in a wrong location. Would recommend checking example from https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/tutorials/tutorial-getting-started for seeing what's the difference. As we cannot reproduce the issue, closing this one.

VesaJuvonen avatar Aug 21 '18 10:08 VesaJuvonen

Vesa - I started afresh with a new laptop and new instance of the helloworld demo - I was following along with the documentation for the first time in over a year. I have the exact same problem as gzhou2018 listed above, which probably means it is a thing, but no idea why. And this is one of those stupid things you really hate as a developer, cos it is now working and I don't know why.

For over an hour I was getting this every time I saved the file. [15:25:00] Error - typescript - src\webparts\helloWorld\HelloWorldWebPart.ts(14,28): error TS2306: File 'C:/REpo/SPFx/helloworld-webpart/src/webparts/helloWorld/MockHttpClient.ts' is not a module. I deleted and recreated the MockHttpClient file with no success.

You're not going to believe this.........but......I went to the github site you listed above and found the MockHttpClient.js file, copied and pasted it into my code, the only difference I could see was code indentation. Magically it worked.......so thanks for the link, i think :)

I am now really annoyed that I cannot repeat it - no issues at all (facepalm)

Something screwy is there

markyroden avatar Aug 30 '18 20:08 markyroden

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 27 '20 06:01 msft-github-bot