question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`vue-tsc` shows error with css modules + `noPropertyAccessFromIndexSignature`

See original GitHub issue

After vue-tsc v0.33.3, the case below shows error when noPropertyAccessFromIndexSignature is true in tsconfig.

<template>
  <div :class="$style.foo">foo</div>
</template>

<style module>
.foo {
  color: red;
}
</style>

vue-tsc below v0.33.3 shows no error and also volar does not show any error with any version.

Reproduction

https://stackblitz.com/edit/vitejs-vite-g65tbc

Run npm run check (which will run vue-tsc --noEmit)

❯ npm run check
$ vue-tsc --noEmit
App.vue:2:23 - error TS4111: Property 'foo' comes from an index signature, so it must be accessed with ['foo'].

2   <div :class="$style.foo">foo</div>
                        ~~~


Found 1 error in App.vue:2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
johnsoncodehkcommented, Mar 21, 2022

@sapphi-red Thank you for your explanation! But since the work are a bit much, I’ll look at it later. I just change $style type to any for now.

0reactions
sapphi-redcommented, Mar 21, 2022

I digged down this a bit.

  • css module class names can get from the result of compileStyleAsync. Note that compileStyle cannot be used. But currently getCssClasses requires sync functions it is not possible to use.
  • getCssClasses is used to get class names not only for css modules. But compileStyleAsync can only get css module class names.

May be it needs to split getCssClasses into getCssModuleClasses and getCssRawClasses (not sure whether this is a proper name)? and then change getCssModuleClasses to accept async functions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error using css modules in typescript react with webpack config
Regarding to the typing, you can fix by removing namespace import since generated typing is now exporting default value.
Read more >
Features | Vite
CSS Modules #. Any CSS file ending with .module.css is considered a CSS modules file. Importing such a file will return the corresponding...
Read more >
vue-tsc | Yarn - Package Manager
vue-tsc. Install: npm i vue-tsc -D. Usage: vue-tsc --noEmit && vite build ... fix: auto complete randomly report [TS Error] { } and...
Read more >
Increasing the Value of CSS Modules with Typescript
CSS Modules are an excellent tool for isolating application styles to the components that use them. And with the power of Typescript, ...
Read more >
Getting Started with CSS Modules
js file we'll find an error when we run npm start again: That's the error that webpack will reveal if it can't find...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found