DenoDDeno
Powered by
Old3nO
Denoβ€’15mo ago
Old3n

Is it possible to import styles and use them in a Typescript React component when using Vite+Deno?

deno check
deno check
always complains when I try to do things like
import { styles }  from './MyComponent.module.css'
import { styles }  from './MyComponent.module.css'
and then use them like
className={styles.myHeader}
className={styles.myHeader}
.

When I do
import * as styles from './MainHeader.module.css'
import * as styles from './MainHeader.module.css'
it stops complaining about the import but then complains when I use properties like
className={styles.myHeader}
className={styles.myHeader}
and says that
myHeader
myHeader
doesn't belong there.

This is for CSS modules but I guess I'd have the same issue without modules, as long as I try to access properties in component.

The app can work thanks to vite but not without deno linter /
deno check
deno check
issues.

I've tried to add things like this but it didn't help in the end.
declare module "*.module.css" {
  export const styles: {
    readonly [key: string]: string
  }
}
declare module "*.module.css" {
  export const styles: {
    readonly [key: string]: string
  }
}


Is there officially no way to make this work without linter issues?
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Is there a way to use the import alias @/ using deno and vite?
AnxiousAverageAAnxiousAverage / help
17mo ago