Skip to content

@volar/typescript mistakenly processes VS Code's untitled files as TypeScript code #286

@mizdra

Description

@mizdra

I am developing a TypeScript Language Service Plugin that loads CSS files using @volar/typescript.

In VS Code, you can create a new file via "New File...". Immediately after creation, it is not yet saved to the file system, and this state is called "untitled".

@volar/typescript appears unable to handle these untitled files correctly.

How to reproduce

minimum reproduction: https://github.com/mizdra/repro-volar-untitled-non-ts-file

  1. Run commands in your terminal
    git clone [email protected]:mizdra/repro-volar-untitled-non-ts-file.git
    cd repro-volar-untitled-non-ts-file
    npm i
  2. Open the workspace in VS Code
  3. Run "Start extension in VS Code" debug task (F5)
  4. Create untitle file by Command+N
  5. Type .foo {} in the file
  6. Change language mode CSS
2025-08-26.22.42.14.mov

Additional information

tsserver.log:

...
Info 112  [22:51:56.697] Loading typescript-plugin-css-modules from /Users/mizdra/src/localhost/gomi/repro-volar-untitled-non-ts-file/packages/vscode (resolved to /Users/mizdra/src/localhost/gomi/repro-volar-untitled-non-ts-file/packages/vscode/node_modules)
Info 113  [22:51:56.697] Plugin validation succeeded
Info 114  [22:51:56.698] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
Err 115   [22:51:56.698] languageId not found for ^/untitled/ts-nul-authority/Untitled-1
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions