mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-25 12:00:02 +08:00
A Vue component's <script lang="tsx"> went to the JavaScript grammar:
the Vue extractor knew only lang="ts" and "typescript". That grammar
stops at the first type. A script holding only
withDefaults(defineProps<{ title?: string }>(), ...) was reported as
"parse produced no symbols", and a script with any other code failed the
same way without a warning, because the warning fires only when nothing
survives: its interfaces and type aliases were missing, a typed arrow
function was indexed as a constant, error recovery made nodes named after
a type or a keyword (a constant "CSSProperties", a function "if"), and
calls were credited to the component instead of the function they are in.
Fix:
- sfcScriptLanguage (sfc-script.ts) reads a block's grammar from its
attributes: ts or typescript is TypeScript, a Vue tsx block is TSX, and
anything else JavaScript, whose grammar reads lang="jsx" already. The
Vue and Svelte extractors and the viewer's syntax regions all ask it, so
the viewer highlights a component with the grammar it was indexed with.
- A Vue project preloads the TSX grammar (expandGrammarLanguages). It came
along only with a .tsx or .js file in the project; without it a
lang="tsx" file is never parsed, and nothing of it is stored.
Validation:
- vue-tsx-script.test.ts indexes a project of .vue files only. On main 4
of its 5 tests fail; with only the preload reverted 3 fail (two because
the files are not stored at all), with only the extractor reverted 2,
with only the viewer reverted 1. 19 related test files, 879 tests, pass.
- A/B against main 628f69e2, kernel on, natural-key dumps and a site-keyed
edge diff. Byte-identical: vue-vben-admin (2,014 files, no tsx blocks),
elk and nuxt/movies, and the controls svelte-realworld and shadcn-svelte's
registry (Svelte, which shares the new helper) and gin (Go).
- Changed only in lang="tsx" files, in node and edge counts added/removed:
vue-element-plus-admin (3 such files) 0/1 and 1/3; a Vue and TS only
folder of ant-design-x-vue's docs (91; TSX loads there only through the
preload) 112/15 and 151/7; ant-design-x-vue (122) 143/27 and 293/26;
a tiny-vue workspace subset (39) 26/59 and 119/93; element-plus (10)
43/16 and 55/13. Every removal and retarget was read, the additions
sampled: new nodes are the scripts' types, interfaces, typed constants
and functions; removed ones are error-recovery debris, duplicates of
Options API methods among them; moved calls now start in the function
they are written in. ant-design-x-vue's src/bubble/loading.vue loses its
"no symbols" warning.
- Index time unchanged within noise, medians of 3 interleaved runs, main
then fix: element-plus 14.8 s and 13.5 s, ant-design-x-vue 2.94 s and
2.95 s, the docs folder that now preloads TSX 1.83 s and 1.82 s.
Fixes #2570
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>