Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev tsserver complains about missing styles when @import in scss but the project build correctly #209

Closed
johhnsmmith198 opened this issue Mar 11, 2023 · 4 comments

Comments

@johhnsmmith198
Copy link

Describe the bug
I have a project setup with create-react-app template typescript and added scss support via this config:

{
  "compilerOptions": {
    "plugins": [{ "name": "typescript-plugin-css-modules" }],
    "target": "es6",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "baseUrl": "./src"
  },
  "include": [ "typings", "src" ],
  "exclude": [ "src/native", "src/ignore" ],
  "typeRoots": ["typings", "./node_modules/@types"]
}

My editor (nvim) is complaining about the styles variable missing styles.tilesInfo though it is defined in the scss.
NOTE: in this TilesInfo.module.scss I do @import "src/styles/colors"; first line in this file
Screenshot from 2023-03-11 12-52-26

I have other places in my code when my scss does not need to @import "src/styles/colors"; and those files don't show any error.
Screenshot from 2023-03-11 12-55-34

NOTE: running npm run build would build the project fine

To Reproduce
use @import in one of your scss

Expected behavior

Desktop (please complete the following information):
Ubuntu 22.04.1 LTS

Additional context
I tried to have my editor using the local typescript-language-server but it didn't change anything

return {
  cmd = { "./node_modules/.bin/typescript-language-server", "--stdio" }
}

I use the last version of everything:

    "typescript": "^4.9.5",
    "typescript-plugin-css-modules": "^4.2.2",

even though it says I dont need to deplace the type for module scss I still had to do:

declare module "*.scss" {
  const content: Record<string, string>;
  export default content;
}

and

  "include": [ "typings", "src" ],
@mrmckeb
Copy link
Owner

mrmckeb commented Mar 11, 2023

Hi @johhnsmmith198, thanks for checking out the plugin.

I had a recent question about neovim support which was resolved here: #206

Hopefully that helps.

NOTE: running npm run build would build the project fine

Unfortunately TypeScript doesn't run plugins during build, only in the IDE. I'm thinking about adding an ESLint plugin to cover that case.

@johhnsmmith198
Copy link
Author

It's funny though that it works on scss file that don't use @import

@johhnsmmith198
Copy link
Author

Same issue when refactoring to @use

Screenshot from 2023-03-12 06-56-16

@mrmckeb
Copy link
Owner

mrmckeb commented Apr 10, 2023

Again, because this plugin can't affect TypeScript outside of the IDE, this is likely configuration related. The steps here should help with that.
https://github.com/mrmckeb/typescript-plugin-css-modules#about-this-plugin

@mrmckeb mrmckeb closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants