@@ -551,7 +551,10 @@ export default testSuite(({ describe }) => {
551551 await using fixture = await createFixture ( fixtures . composedAndFlat ) ;
552552
553553 const { js } = await viteBuild ( fixture . path , {
554- plugins : [ patchCssModules ( { composedClassesMode : 'string' } ) ] ,
554+ plugins : [ patchCssModules ( {
555+ composedClassesMode : 'string' ,
556+ generateSourceTypes : true ,
557+ } ) ] ,
555558 build : {
556559 target : 'es2022' ,
557560 } ,
@@ -563,13 +566,19 @@ export default testSuite(({ describe }) => {
563566 composed : expect . stringMatching ( / _ c o m p o s e d _ \w + _ p l a i n _ \w + / ) ,
564567 } ,
565568 } ) ;
569+ const dts = await fixture . readFile ( 'style.module.css.d.ts' , 'utf8' ) ;
570+ expect ( dts ) . toMatch ( 'const plain: string;' ) ;
571+ expect ( dts ) . toMatch ( 'const composed: string;' ) ;
566572 } ) ;
567573
568574 test ( 'array' , async ( ) => {
569575 await using fixture = await createFixture ( fixtures . composedAndFlat ) ;
570576
571577 const { js } = await viteBuild ( fixture . path , {
572- plugins : [ patchCssModules ( { composedClassesMode : 'array' } ) ] ,
578+ plugins : [ patchCssModules ( {
579+ composedClassesMode : 'array' ,
580+ generateSourceTypes : true ,
581+ } ) ] ,
573582 build : {
574583 target : 'es2022' ,
575584 } ,
@@ -581,13 +590,19 @@ export default testSuite(({ describe }) => {
581590 composed : [ expect . stringMatching ( / _ c o m p o s e d _ \w + / ) , expect . stringMatching ( / _ p l a i n _ \w + / ) ] ,
582591 } ,
583592 } ) ;
593+ const dts = await fixture . readFile ( 'style.module.css.d.ts' , 'utf8' ) ;
594+ expect ( dts ) . toMatch ( 'const plain: string;' ) ;
595+ expect ( dts ) . toMatch ( 'const composed: string[];' ) ;
584596 } ) ;
585597
586598 test ( 'all-array' , async ( ) => {
587599 await using fixture = await createFixture ( fixtures . composedAndFlat ) ;
588600
589601 const { js } = await viteBuild ( fixture . path , {
590- plugins : [ patchCssModules ( { composedClassesMode : 'all-array' } ) ] ,
602+ plugins : [ patchCssModules ( {
603+ composedClassesMode : 'all-array' ,
604+ generateSourceTypes : true ,
605+ } ) ] ,
591606 build : {
592607 target : 'es2022' ,
593608 } ,
@@ -599,6 +614,9 @@ export default testSuite(({ describe }) => {
599614 composed : [ expect . stringMatching ( / _ c o m p o s e d _ \w + / ) , expect . stringMatching ( / _ p l a i n _ \w + / ) ] ,
600615 } ,
601616 } ) ;
617+ const dts = await fixture . readFile ( 'style.module.css.d.ts' , 'utf8' ) ;
618+ expect ( dts ) . toMatch ( 'const plain: string[];' ) ;
619+ expect ( dts ) . toMatch ( 'const composed: string[];' ) ;
602620 } ) ;
603621 } ) ;
604622
0 commit comments