Skip to content

This plugin is incompatible with plugins based on the exact same approach. #283

Open
@dgoldstein0

Description

@dgoldstein0

Describe the bug

I found a plugin, typescript-plugin-yaml, which basically copy pasted your code and changed it to make a plugin that supports yaml in TSServer. I reported this to typescript (microsoft/TypeScript#61231), but they aren't interested in it as they don't want to take responsibility for troubleshooting plugins. (Bit of context: typescript-plugin-yaml is defacto unmaintained, but I'm considering publishing and maintaining a fork)

To Reproduce

Repo with reproduction, https://github.com/dgoldstein0/typescript-plugin-bug-repro - including some extra logging that may help narrow down the problem.

// index.ts
import * as classes from "./foo.module.css";
import * as yamlData from "./data.yaml";

// It can help to have a typecheck error to see that tsserver
// has initialized and is doing normal typechecking
//const bar: 3 = 2;

export { classes, yamlData };

// tsconfig.json
{
  "compilerOptions": {
    "plugins": [
      {
        "name": "typescript-plugin-css-modules"
      },
      {
        "name": "typescript-plugin-yaml"
      }
    ],
    // I've tried multiple different moduleResolutions and all have the problem
    "moduleResolution": "node16"
  }
}

// data.yaml
foo: bar
bar: baz
someIntegers: [1, 2, 3]

// foo.module.css
.foo {
    color: black;
}

Basically: this repo uses both typescript-plugin-css-modules and the most-recent typescript-plugin-yaml with TS 5 fixes. Despite both of the plugins being enabled in the tsconfig.json, only the last one enabled ever seems to work. I have no idea why, but logging I've done showed both plugins initialized and then only the last one got it's functions called.

In an IDE that integrates with tsserver (I've tried vim & vscode), when index.ts, one of the imports errors - corresponding to whichever plugin is currently first in the tsconfig.json.

Expected behavior
In an IDE that integrates with tsserver (I've tried vim & vscode), when index.ts is open both imports should resolve.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] Happens both on vscode under Windows 11 and on vim on Ubuntu 22.04.5
  • Browser [e.g. chrome, safari] - Not relevant, this is an IDE bug
  • Version [e.g. 22] (of what?)

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions