ReviewOS

stacks/stx

vscode: the TypeScript server plugin loads but never sees .stx files (no languages in its contribution)

#2028
Closed chris opened this 9 days ago ·
9 days ago

Follow-up to #2026. The TypeScript server plugin now loads, but it never sees a .stx file, so it type-checks nothing in the editor.

VS Code sends a document to tsserver only when its language is one tsserver handles, or one a plugin claims through languages in its typescriptServerPlugins contribution. The stx contribution declares no languages, and getExternalFiles only returns .stx files that are already in the program, which they never are. So the tsserver log shows the plugin initialised and then never mentions a .stx path.

Checked in VS Code 1.128.1 against a scratch project with a <script server> block containing const count: number = "nope":

  • as contributed: no diagnostics on the file
  • with "languages": ["stx"] added: tsserver opens the file and the plugin reports Type 'string' is not assignable to type 'number'. on it

Not turned on in the #2026 fix, because it changes what every stx user sees. Run over 12 .stx files from a real app (campushq/resources), it also reported, on three components:

  • Cannot find module 'stx' or its corresponding type declarations. for import { defineProps, withDefaults } from 'stx'
  • Untyped function calls may not accept type arguments. on defineProps<Props>(), which follows from the first

So before enabling it, the virtual file needs to resolve the stx module the way stx typecheck does, and the editor and the CLI should agree on a sample of real apps. The unused stxTypescriptPlugin.enabled setting ("Enable TypeScript language features in stx files") is read nowhere, and could gate it.

Sign in to comment on this issue.