- pnpm monorepos setup
- packages are in
packages/ - packages are setup with
"composite": trueintsconfig.json
- packages are in
@my/apppackage (inpackages/app) references@my/lib(inpackages/lib)- As a workspace dependency in
package.json; and - A project reference in
packages/app/tsconfig.json
- As a workspace dependency in
@my/libhas a path alias set up inpackages/lib/tsconfig.jsonwhich points~/*tosrc/*(via thebaseUrl)@my/libhas two classesFooandBarBarextendsFoo- The
importstatement inbar.tsuses the~path alias to avoid..in../../other/subpath/foo.ts
- in
@my/appwe usevite-tsconfig-pathsto allowviteto understand path aliases fromtsconfig.json
- Use Volar in Take Over mode
- Navigate VS Code to
packages/app/src/main.ts - Mouseover on
@my/libon line 5. Volar complains:Output file 'blah/volar-path-alias/packages/lib/src/index.d.ts' has not been built from source file 'blah/volar-path-alias/packages/lib/src/index.ts'.ts(6305) - Try setting
noProjectReferencestotrueinvolar-path-alias.code-workspaceand reload the window - The error has gone away and
foois now correctly typed on mouseover asFoo, butbaris typed asany- I think the reason why
Foois correctly typed is because it doesn't use the~path alias in its import/export chain, whilstBaris incorrectly typed because it does use the~path alias.
- I think the reason why
- Turn off Take Over mode by enabling the builtin Typescript language features and reload the window
- Note that
fooandbarare correctly typed when you mouseover them now, implying that the builtin Typescript is correctly understanding the project reference and path alias
Original README from pnpm create vite
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.
- VS Code + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:
- Disable the built-in TypeScript Extension
- Run
Extensions: Show Built-in Extensionsfrom VSCode's command palette - Find
TypeScript and JavaScript Language Features, right click and selectDisable (Workspace)
- Run
- Reload the VSCode window by running
Developer: Reload Windowfrom the command palette.