typescript-plugin-css-modules: Lots of errors produced in WebStorm IDE with this plugin
Describe the bug
When including this plugin in my tsconfig.json
, the Intellij WebStorm IDE reports hundreds of errors that look like this:
Error:(54, 33) TS1155: 'const' declarations must be initialized.
When I remove this plugin, these errors go away.
To Reproduce
Steps to reproduce the behavior:
Use WebStorm in a project with this plugin. My tsconfig
using ts 3.9.5
:
{
"compilerOptions": {
"outDir": "build/dist",
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"baseUrl": ".",
"rootDir": ".",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"paths": {
"~/*": ["src/*"]
},
"importsNotUsedAsValues": "preserve",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"isolatedModules": true,
"plugins": [
{
"name": "typescript-plugin-css-modules",
"options": {
"customMatcher": "\\.css$"
}
}
]
},
"exclude": [
"./node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"src/setupTests.ts"
]
}
The TypeScript window in the IDE will call the TS service and find errors for you.
Expected behavior These errors wouldn’t show up.
Screenshots see above.
another very simple example:
Desktop (please complete the following information):
- OS: Mac OSX Catalina
Additional context We use CSS modules and some PostCSS features, though these errors seem to pop up in files that don’t do anything fancy like PostCSS’s nesting, too.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (14 by maintainers)
Commits related to this issue
- try let instead of const Debugging #97 with the suggestion here: https://github.com/mrmckeb/typescript-plugin-css-modules/issues/97#issuecomment-669133538 — committed to ekilah/typescript-plugin-css-modules by ekilah 4 years ago
- Use let instead of const Fixes #97 — committed to ekilah/typescript-plugin-css-modules by ekilah 4 years ago
- Use let instead of const Fixes #97 — committed to ekilah/typescript-plugin-css-modules by ekilah 4 years ago
- Use let instead of const Fixes #97 — committed to ekilah/typescript-plugin-css-modules by ekilah 4 years ago
@mrmckeb there is no issue. I was just showing it working.
@mrmckeb That fixed it for me in VS 2019. Everything seems to be working now! 👍
I do not receive the
TS2339
error like @ekilah does.Thanks for that.
Can you please try
v2.7.0
? I think it will solve the issue finally… I hope so!Sure, will do tomorrow.
@mrmckeb Sorry it took so long to try this out, been busy!
Yes, that change does seem to fix the issue (or at least, get rid of the errors). It’s annoying to test because it seems like I have to quit/restart Webstorm for it to decide to consume the changes in my
package.json
😛 , but I confirmed the hundreds of errors disappeared with this change.Added that to a PR: https://github.com/mrmckeb/typescript-plugin-css-modules/pull/100
I was just thinking about wha could cause this and it might be to do with this: https://github.com/mrmckeb/typescript-plugin-css-modules/blob/f9af73d1abe2bb3bca01310eb659c942bea9fbfb/src/helpers/createExports.ts#L42-L44
It seems to be only occurring in IntelliJ editors, so it might be to do with the way they use (or don’t use) the TypeScript Language Service.
As a quick test, could you edit the source code, so that it declares with
let
instead?