I'm currently working on a mono-repo project setup with an isolated library package in TypeScript and another web UI package that combines TypeScript and React.
To import the compiled library package into the consumer (web UI) package, I'm using yarn to link the packages and parcel to generate distribution files for the library package. Parcel automatically generates a d.ts
file in the library package's dist
folder.
When I open the consumer package's file in VS Code that imports and uses the library, the IDE doesn't recognize the types declared in the library package's d.ts
file.
The structure of the packages is as follows:
rootPackage
|- library
|- web-ui
In the library
package, there's a types.ts
file along with an index.ts
file where only one type is being exported:
export type ParamType = "a" | "b" | "c";
I use parcel watch
in this package to automatically refresh the dist
files whenever changes are made. Parcel successfully generates the main.d.ts
file which is referenced by the package.json
's types
attribute.
However, when trying to use the ParamType
type in the web-ui
package's code, I encounter an error in the IDE:
Cannot find name 'ParamType'.ts(2304)
Although running parcel in the web-ui
package compiles without issues and loads in the browser fine, it seems to be a problem specific to Visual Studio Code that I'm struggling to resolve.
Edit 1
To showcase this issue, I've set up a public repository on GitHub. If you have any solutions or suggestions for how to fix this issue, please feel free to create a pull request - any help would be greatly appreciated.