Go to declaration/auto-import doesn't work in certain situations
Repro 1:
Pull down https://github.com/graphql-nexus/examples
Open `plugin-prisma` package and install it's deps via npm or yarn
Open `plugin-prisma\api\graphql\User.ts`
Notice that the imported `schema` isn't recognized by webstorm (can't get hover info and can't `Go to declaration`) but also doesn't error.
Comment out the import statement for `schema`
Auto-import `schema`
Notice that the import incorrectly refers to `nexus/dist`
Note: If I add `"types": "dist"` to `node_modules/nexus/package.json` things start to work correctly. It seems like webstorm should be able to figure out the correct import for the `nexus` package since the `main` property in the nexus package.json points to `dist/index.js`
Repro 2:
Pull down https://github.com/graphql-nexus/examples
Open `plugin-prisma` package and install it's deps via npm or yarn
Open `plugin-prisma\api\graphql\User.ts`
Add a line `let user: User;` to the bottom of the file
Try to auto-import `User` and notice that it's not available
Add `import {User} from '@prisma/client'` to the top of the file
Notice that User is at least not erroring, but `Go to declaration` does not work
Ctrl+click on `'@prisma/client'` from the import
Ctrl+click on `'.prisma/client'`
Notice that User type is in `node_modules\.prisma\client\index.d.ts`
Note: It seems that webstorm has trouble following the re-export in `node_modules/@prisma/client/index.d.ts`
In VSCode, the only thing that doesn't work is auto-importing `User`
Please sign in to leave a comment.
1. the IDE used
"types"(or"typings") field to locate typings per https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html, this field can only be omitted if the main declaration file is namedindex.d.tsand lives at the root of the package2. Ctrl+click works fine for me if the plugin-prisma/node_modules/.prisma is included in indexing (you have to mark it un-excluded via the right-click menu)
Thanks for the tips. Auto-import still does not work after un-excluding the `.prisma` folder.
Also, any idea how vscode is figuring out the correct types on nexus in #1? It might be worth being on par with vscode. I submitted an issue to nexus: https://github.com/graphql-nexus/nexus/issues/1248
Elena's advice worked for me (I'm also using Prisma)
Thank you Elena, you are my hero.
You are my hero as well Elena Pogorelova!!! This has been annoying me for quite some time! Using Prisma with NestJS.