1npm install typescript-plugin-css-modules --save-dev
2
3Or if you’re using Yarn, run:
4
5yarn add -D typescript-plugin-css-modules
6
7
8# Create a new file at the root of the project called styles.d.ts
9# (or something similar), and add the following code to it:
10
11// For CSS
12declare module "*.module.less" {
13 const classes: { [key: string]: string };
14 export default classes;
15}
16
17// For LESS
18declare module "*.module.less" {
19 const classes: { [key: string]: string };
20 export default classes;
21}
22
23// For SCSS
24declare module "*.module.scss" {
25 const classes: { [key: string]: string };
26 export default classes;
27}
1import styles from './Component.module.css'
2<Component className={styles.someClassInCssModule}/>