-
-
Notifications
You must be signed in to change notification settings - Fork 489
Description
We want to import API types from the api project into the app project in a monorepos without having to build the .d.ts files. We use project references so that path mappings in the api project can be resolved when imported into the app project. Without using project references (in app) the types are imported as any.
When using Volar in takeover mode, we get:
Output file '/fleetseer/packages/api/lib/index.d.ts' has not been built from source file '/fleetseer/packages/api/src/index.ts'. in our app project, when importing @fleetseer/api.
However, this use case appears to be supported by the built-in VS Code TypeScript support. If we turn on TypeScript and JavaScript Language Features in VS Code, the types are correctly resolved by the built-in thing for *.ts files (but no change for *.vue files, as expected).
This may be related / a duplicate of #1815
Activating the workspace setting "Volar > Vueserver: No Project References" makes the "Output file has not been built" error go away, however the path mappings in api don't resolve correctly.
- One workaround here without project references is to use relative paths in
api(e.g.../../../../my-api-thing.tsin some cases) which is quite painful
Notes:
- Using Volar 1.0.24 in VS Code in takeover mode
- Using Typescript project references in a PNPM monorepos
@fleetseer/apiis a added as a pnpm workspace dependency (i.e. inpackage.json:"@fleetseer/api": "workspace:*") to theappproject.- The
apiproject is acomposite: trueproject referred to by theappproject - This error appears for both
*.tsand*.vuefiles in theappproject - In
apiwe have a path mapping intsconfig.jsonto map"~/*": ["./*"]with"baseUrl": "./src"
Also both vite (using vite-tsconfig-paths) and esbuild (using @esbuild-plugins/tsconfig-paths) seem to be able to resolve the ~/* alias correctly on build, with the help of the plugins - perhaps there's a similar plugin for Volar?
In the end, I think we either:
A. Resolve the reason why the project references don't resolve the same way as the built-in TS services; or
B. Find a way to get the path mapping (e.g. ~/*) in depended projects (i.e. api in our case) to work without using project references, as a workaround (perhaps using something like a tsconfig-paths plugin?)
Versions
- Typescript 4.9.4
- Volar 1.0.24
- Vue 3.2.45
- VS Code 1.74.2
- Windows 11 (WSL Debian)