In my setup, I have a repository/module specifically designed to export TypeScript types into another project. Both of these projects are using TypeScript with ECMAScript modules. The relevant part of the tsconfig.json
configuration is as follows:
"target": "es2020",
"lib": ["es2020"],
"module": "esnext",
"moduleResolution": "NodeNext",
Additionally, both package.json
files are set to include
"type": "module"
.
Although all my imports are functioning correctly, I am looking to organize my types by placing them in a separate folder called "master type":
export * as GraphQL from './types/graphql.js' // Example: "GQLType"
export * from './types/foo.js' // Example: FooType
export * from './types/bar.js' // Example: BarType
When importing this types module into the main one, I expect to be able to import them like this:
import { FooType, BarType, GraphQL } from '...themodule"
For instance, I would use GraphQL
as GraphQL.GQLType
.
However, when encountering a reference to say "GQLType" in my code, the VSCode suggestion for a quick fix is not:
Add import from "GraphQL"
Instead, it suggests:
Add import from "themodule/dist/graphql.js"
I have tried adjusting the exports
field in the types module without success.
Is there a way to make VSCode's quick fix feature smarter in providing correct import suggestions? I particularly rely on the "Add all missing imports" function.
I came across a similar issue discussed here: VSCode not showing correct import suggestions for a local linked package, but no definitive answer was provided.