{"id":18920,"library":"vue-ts-morph","title":"Vue TS Morph","description":"A thin library that enables ts-morph (TypeScript compiler API wrapper) to understand Vue single-file components (.vue files). Current version 0.1.0 wraps ts-morph ^24.0.0. Unlike Volar or Vetur, which implement custom LanguageServiceHosts, vue-ts-morph works at the FileSystemHost level—creating virtual .vue.ts files that shadow real .vue files. This makes it the only option for using ts-morph's AST manipulation API (e.g., refactoring, code generation) directly on Vue SFCs without a full language server. Released as experimental (no stable release cadence). Not recommended for production; major limitations: no <template> support, no simultaneous <script setup> + <script> blocks.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install vue-ts-morph","lang":"bash","label":"npm"},{"cmd":"yarn add vue-ts-morph","lang":"bash","label":"yarn"},{"cmd":"pnpm add vue-ts-morph","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; vue-ts-morph extends ts-morph's Project with Vue file support. Must install separately.","package":"ts-morph","optional":false}],"imports":[{"note":"ESM-only; package ships TypeScript types. Default export not provided.","wrong":"const createVueFileSystemHost = require('vue-ts-morph')","symbol":"createVueFileSystemHost","correct":"import { createVueFileSystemHost } from 'vue-ts-morph'"},{"note":"Project comes from ts-morph, not vue-ts-morph.","wrong":"import { Project } from 'vue-ts-morph'","symbol":"Project","correct":"import { Project } from 'ts-morph'"},{"note":"Type import for TypeScript users; VueFileSystemHost is not a runtime export.","wrong":"import { VueFileSystemHost } from 'vue-ts-morph'","symbol":"type VueFileSystemHost","correct":"import type { VueFileSystemHost } from 'vue-ts-morph'"}],"quickstart":{"code":"import { createVueFileSystemHost } from 'vue-ts-morph';\nimport { Project } from 'ts-morph';\n\nconst project = new Project({\n  fileSystem: createVueFileSystemHost(),\n});\nproject.addSourceFilesFromTsConfig('tsconfig.json');\n\nconst sourceFile = project.getSourceFileOrThrow('src/App.vue');\n// Access TypeScript AST through the virtual .vue.ts file\nconst vueTsSourceFile = sourceFile.getExtension() === '.vue' ? project.getSourceFileOrThrow('src/App.vue.ts') : sourceFile;\nif (vueTsSourceFile) {\n  console.log('Classes:', vueTsSourceFile.getClasses().length);\n}","lang":"typescript","description":"Shows how to create a ts-morph Project that can read .vue files, add source files from tsconfig, then access the virtual .vue.ts file to query TypeScript AST."},"warnings":[{"fix":"Do not rely on template AST. Use a Vue compiler (e.g., @vue/compiler-sfc) separately if template analysis is needed.","message":"Cannot read <template> section; only <script> (and <script setup>) content is available.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Use only <script setup> or a single <script> block. Merge or split into separate files if both are needed.","message":"Simultaneous <script setup> and <script> blocks are not supported – only one script block per .vue file.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Always re-create the file system host (or project) after external modifications to .vue files.","message":"Virtual .vue.ts files are created on the fly; direct file system writes to .vue files may not be reflected without recreating the host.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Consider using Volar's language service API if you need production-grade Vue TypeScript support.","message":"Package is experimental with no stable release or active maintenance guarantee.","severity":"deprecated","affected_versions":"<1.0.0"}],"env_vars":null,"search_vec":"'0.1.0':27 '24.0.0':32 'api':14,73 'ast':71 'cadenc':93 'code':76 'compil':13 'compon':22 'creat':50 'current':25 'custom':39 'direct':78 'e.g':74 'enabl':8 'experiment':89 'file':21,24,53,58 'filesystemhost':48 'full':84 'generat':77 'implement':38 'languag':85 'languageservicehost':40 'level':49 'librari':6 'limit':99 'major':98 'make':60 'manipul':72 'morph':3,11,31,44,69 'option':64 'product':97 'real':56 'recommend':95 'refactor':75 'releas':87,92 'server':86 'sfcs':81 'shadow':55 'simultan':103 'singl':20 'single-fil':19 'stabl':91 'support':101 'thin':5 'ts':2,10,30,43,68 'ts-morph':9,29,67 'typescript':12 'understand':17 'unlik':33 'use':66 'version':26 'vetur':36 'virtual':51 'volar':34 'vue':1,18,23,42,57,80 'vue-ts-morph':41 'vue.ts':52 'without':82 'work':45 'wrap':28 'wrapper':15","created_at":"2026-04-25T07:40:50.070906+00:00","updated_at":"2026-04-25T07:40:50.070906+00:00","problems":[{"fix":"Use the provided createVueFileSystemHost() factory function instead of custom implementations.","cause":"Missing or incorrect file system host implementation.","error":"TypeError: fileSystem.readFileSync is not a function"},{"fix":"Run: npm install ts-morph@^24.0.0","cause":"Missing peer dependency ts-morph.","error":"Error: Cannot find module 'ts-morph'"},{"fix":"Retrieve the virtual file: const vueFile = project.getSourceFileOrThrow('src/App.vue.ts');","cause":"Accessing AST methods on the .vue source file instead of the virtual .vue.ts source file.","error":"TypeError: sourceFile.getClasses is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vue-ts-morph","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}