fix(resolution): Vue, Svelte and Astro calls follow the JS/TS rules

Merged
CO
2mo ago
+189-20

Problem

Refs in .vue, .svelte and .astro files carry language vue/svelte/astro, so the JS/TS resolution rules from #2120 skipped them. On halo, t('…') from useI18n() linked to an interface property t (562 made-up callers) and ref(…) from vue to an unrelated local ref (523).

Adding those languages alone exposed a weakness in how #2120 decides a binding is "from outside the repo": it treated any import the resolver couldn't place as outside. That also misclassified SvelteKit's $lib/…, a nested Nuxt app's ~/… and per-app @/… aliases. Calls to those bindings dropped in .ts files too, since #2120.

Change

  • JS_FAMILY includes vue, svelte, astro.

  • "Outside the repository" now means one of:

    • a package declared by the importing file's package.json chain (dependencies / dev / peer / optional) or by a Deno deno.json(c) import map entry that points at jsr: / npm: / a URL;
    • a Node built-in, node: / bun: / jsr: / npm: / URL specifiers, or @std/…;
    • SvelteKit $app / $env or Astro astro:…, unless the repository is that framework.

    An unknown alias stays project code. workspace: / file: / link: / portal: dependencies are in-repo.

  • SFC files get the JS built-ins list (fetch, Error, Map, …). A file's own import of a built-in's name (import Map from './Map.svelte') is the import, for TS too.

  • Untyped 3-segment chains (api.groupReports.getAll()) keep resolving in SFCs. The TS/JS guard from #1862 stays TS/JS-only. In the Vue repos these edges reached their API client class ~66 times against ~10 wrong.

Measured (wasm, main vs this branch, every loss/gain classified by source line)

repoedgesnotes
halo−1153 / +25−562 t, −523 ref, cross-component locals; gains are per-app @/ imports in .ts
element-plus−162 / +0dayjs/lodash/@vueuse → props & test mocks, cross-component locals
mealie−38 / +3new Error() → an enum member; destructured-composable calls (same as TS today)
kit−15 / +230new Error → a +page.svelte; gains: kit's own $app/server etc. (repo is SvelteKit)
shadcn-svelte−3 / +14$lib/… calls in .ts restored
svelte.dev−17 / +23new Map() → a Map.svelte component; $lib gains
elk, astrowind, starlight≤15built-in confirm/props
excalidraw, trpc, bulletproof-react, hono, zod, typeorm, react-redux-realworld, axios0 / ≤1unchanged

Every arm's init exited 0.

Follow-ups found on the way, tracked separately: a non-exported ES-module binding (kit's if (DEV) { const fetch }) is still reachable from other files. And const { f } = useX() doesn't reach the f inside useX, for TS as well as SFCs.

Tests

__tests__/js-member-guessing.test.ts adds Vue/Svelte/nested-app/Deno/workspace/Map cases. It fails on main. The full suite passes (5574).

🤖 Generated with Claude Code