Description
🔎 Search Terms
tsserver plugin typescript-plugin-css-modules typescript-plugin-yaml imports not resolving
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about plugins
I tried TS 5.1, 5.7, and 4.9.5
⏯ Playground Link
https://github.com/dgoldstein0/typescript-plugin-bug-repro
💻 Code
// 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;
}
🙁 Actual behavior
typescript-plugin-css-modules doesn't seem to work at all, or even be called after tsserver initializes it. If the yaml plugin is commented out, then the css import resolves and the yaml import (understandably) fails; if the order of the plugins is swapped, then the yaml import fails to resolve and the css module import start working
🙂 Expected behavior
expected: with the most up to date versions of the plugins installed (see the linked repository), both imports should resolve in an IDE using tsserver.
(also expected: tsc typechecking will need some other way to get declarations for yaml and css modules, as I understand plugins only affect tsserver)
Additional information about the issue
I added as much logging as I could think of to typescript-plugin-css-modules to see where it went wrong, and what I learned is that after the plugin is created, nothing seems to use the return value - I included my logging patch in the linked repo; it'll be installed by yarn. It's also notable that typescript-plugin-yaml is basically taking the same approach - the repo mentions that they copied from typescript-plugin-css-modules - but after reading the code I couldn't see how the plugins would conflict with each other. So I'm filing here because I suspect a tsserver bug rather than a bug with either plugin.
I did stumble over #52953 which suggests that yall might not approve of the current typescript-plugin-css-modules design - there's some conversation recommending overriding filesystem reading & writing instead, but that doesn't seem to have been adopted by the plugin maintainer.