Skip to content

Commit

Permalink
feat: add compile-time checking for selectors that don't exist when u…
Browse files Browse the repository at this point in the history
…sing index signature syntax, ie. a['my-selector']
  • Loading branch information
silbinarywolf committed Oct 18, 2019
1 parent 88538d1 commit 487483c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const cssModuleToInterface = (cssModuleKeys) => {
.map(key => ` '${key}': string;`)
.join('\n');

return `interface CssExports {\n${interfaceFields}\n}`;
return `interface CssExports {\n [key: string]: void;\n${interfaceFields}\n}`;
};

const filenameToTypingsFilename = filename => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Can emit valid declaration with sourceMap 1`] = `
"// This file is automatically generated.
// Please do not change this file!
interface CssExports {
[key: string]: void;
'composedClass': string;
'otherClass': string;
'someClass': string;
Expand All @@ -18,6 +19,7 @@ exports[`Can emit valid declaration without sourceMaps 1`] = `
"// This file is automatically generated.
// Please do not change this file!
interface CssExports {
[key: string]: void;
'composedClass': string;
'otherClass': string;
'someClass': string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Can emit valid declaration without classes 1`] = `
"// This file is automatically generated.
// Please do not change this file!
interface CssExports {
[key: string]: void;
}
declare const cssExports: CssExports;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ exports[`Can error on invalid declaration 1`] = `
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
'classInBothFiles': string;
- 'classInBothFiles': string;
- 'classInTypeScriptFile': string;
- }
- declare const cssExports: CssExports;
- export = cssExports;
-
+ [key: string]: void;
+ 'classInBothFiles': string;
+ 'classInCssFile': string;
}
declare const cssExports: CssExports;
export = cssExports;
+ }
+ declare const cssExports: CssExports;
+ export = cssExports;
"
Expand Down
1 change: 1 addition & 0 deletions test/verify-valid-declaration/index.css.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
[key: string]: void;
'hyphened-classname': string;
'otherClass': string;
'someClass': string;
Expand Down

0 comments on commit 487483c

Please sign in to comment.