Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With some files, VS Code cannot find modules that exist #10391

Closed
jankalfus opened this issue Aug 10, 2016 · 8 comments
Closed

With some files, VS Code cannot find modules that exist #10391

jankalfus opened this issue Aug 10, 2016 · 8 comments

Comments

@jankalfus
Copy link

Sometimes when I open my project, VS Code is unable to find imported external modules. I've got typings for the modules installed, all files in the project compiles fine using tsc, but I get red squiggly lines in the editor. The weird thing is that I get the squiggly lines only for some .tsx files, while it works for others.

The file src/web/App.tsx is fine:
web

While I get squiggly lines for the file src/native/App.tsx:
native

My tsconfig.json content is the following:

{
    "compilerOptions": {
        "allowSyntheticDefaultImports": false,
        "jsx": "react",
        "noImplicitAny": true,
        "experimentalDecorators": true,
        "module": "commonjs",
        "target": "es5",
        "rootDir": "src"
    },
    "exclude": [
        "node_modules",
        "src/native",
        "app",
        "app-native",
        "tools",
        "test"
    ]
}

Both react and react-native are installed as global typings.

Unfortunately, I cannot post the source code right now, but basically, the structure of the source files is as following:

src
 |-- common
 |-- native
       |-- index.ts
       |-- App.tsx
 |-- web
       |-- App.tsx
 |-- index.ts (this one is for web)
  • VSCode Version: 1.4.0
  • OS Version: Windows 10

Any ideas?

@jankalfus
Copy link
Author

jankalfus commented Aug 10, 2016

I have noticed that if I use File -> Close folder and then File -> Open Folder... and open the project folder again, the errors are gone. If I just restart VS Code instead, I keep getting the errors. I presume that some internal cache gets cleared?

@jankalfus
Copy link
Author

More to this issue: I get the errors every time I create a new folder and ts/tsx file inside. Unfortunately, the workaround I've suggested in the previous comment doesn't work.

@jankalfus
Copy link
Author

I've published the source code. To reproduce this issue:

  1. Go to https://github.com/gina-system/react-starter
  2. Use the steps in the quick start section of the readme
  3. Open the src/native/App.tsx file.

@dbaeumer dbaeumer assigned waderyan and unassigned dbaeumer Aug 11, 2016
@dbaeumer
Copy link
Member

@waderyan let me know when you need assistance

@waderyan
Copy link

I have reproduced this per @jankalfus's instructions.

I'm seeing a "Cannot Find Module" when I hover over react-native

image

Developer shows a seemingly unrelated error.

image

It seems like typings directory is configured correctly.

image

@waderyan
Copy link

Ok this is strange... I reopened the project to grab another screen shot and this is what I saw.

image

Everything looks good now.

I retraced my steps.

  1. re-cloned https://github.com/gina-system/react-starter in a separate dir.
  2. followed the README steps (npm install, typings install)

Looks good again.

Ping @dbaeumer please advise what to try next.

@dbaeumer
Copy link
Member

@waderyan there is not much you can do. I would move it to the TS team since at the end of the day the error message is generated by the tsserver.

@waderyan
Copy link

Moved to TypeScript

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants