Skip to content

Commit c527c78

Browse files
committed
feat: add compile-time checking for selectors that don't exist when using index signature syntax, ie. a['my-selector'] (seek-oss#20)
1 parent 88538d1 commit c527c78

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const cssModuleToInterface = (cssModuleKeys) => {
2727
.map(key => ` '${key}': string;`)
2828
.join('\n');
2929

30-
return `interface CssExports {\n${interfaceFields}\n}`;
30+
return `interface CssExports {\n [key: string]: void;\n${interfaceFields}\n}`;
3131
};
3232

3333
const filenameToTypingsFilename = filename => {

test/emit-declaration/__snapshots__/emit-declaration.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports[`Can emit valid declaration with sourceMap 1`] = `
44
"// This file is automatically generated.
55
// Please do not change this file!
66
interface CssExports {
7+
[key: string]: void;
78
'composedClass': string;
89
'otherClass': string;
910
'someClass': string;
@@ -18,6 +19,7 @@ exports[`Can emit valid declaration without sourceMaps 1`] = `
1819
"// This file is automatically generated.
1920
// Please do not change this file!
2021
interface CssExports {
22+
[key: string]: void;
2123
'composedClass': string;
2224
'otherClass': string;
2325
'someClass': string;

test/emit-empty-declaration/__snapshots__/emit-empty-declaration.test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports[`Can emit valid declaration without classes 1`] = `
44
"// This file is automatically generated.
55
// Please do not change this file!
66
interface CssExports {
7+
[key: string]: void;
78
89
}
910
declare const cssExports: CssExports;

test/verify-invalid-declaration/__snapshots__/verify-invalid-declaration.test.js.snap

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ exports[`Can error on invalid declaration 1`] = `
66
// This file is automatically generated.
77
// Please do not change this file!
88
interface CssExports {
9-
'classInBothFiles': string;
9+
- 'classInBothFiles': string;
1010
- 'classInTypeScriptFile': string;
11+
- }
12+
- declare const cssExports: CssExports;
13+
- export = cssExports;
14+
-
15+
+ [key: string]: void;
16+
+ 'classInBothFiles': string;
1117
+ 'classInCssFile': string;
12-
}
13-
declare const cssExports: CssExports;
14-
export = cssExports;
18+
+ }
19+
+ declare const cssExports: CssExports;
20+
+ export = cssExports;
1521
1622
1723
"

test/verify-valid-declaration/index.css.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This file is automatically generated.
22
// Please do not change this file!
33
interface CssExports {
4+
[key: string]: void;
45
'hyphened-classname': string;
56
'otherClass': string;
67
'someClass': string;

0 commit comments

Comments
 (0)