diff --git a/index.js b/index.js index c1df2d3..bbc8afb 100644 --- a/index.js +++ b/index.js @@ -24,7 +24,7 @@ const getTypeMismatchError = ({ filename, expected, actual }) => { const cssModuleToInterface = (cssModuleKeys) => { const interfaceFields = cssModuleKeys .sort() - .map(key => ` '${key}': string;`) + .map(key => ` readonly '${key}': string;`) .join('\n'); return `interface CssExports {\n${interfaceFields}\n}`; diff --git a/test/emit-declaration/__snapshots__/emit-declaration.test.js.snap b/test/emit-declaration/__snapshots__/emit-declaration.test.js.snap index 1164931..c1f0bf6 100644 --- a/test/emit-declaration/__snapshots__/emit-declaration.test.js.snap +++ b/test/emit-declaration/__snapshots__/emit-declaration.test.js.snap @@ -4,10 +4,10 @@ exports[`Can emit valid declaration with sourceMap 1`] = ` "// This file is automatically generated. // Please do not change this file! interface CssExports { - 'composedClass': string; - 'otherClass': string; - 'someClass': string; - 'validClass': string; + readonly 'composedClass': string; + readonly 'otherClass': string; + readonly 'someClass': string; + readonly 'validClass': string; } export const cssExports: CssExports; export default cssExports; @@ -18,10 +18,10 @@ exports[`Can emit valid declaration without sourceMaps 1`] = ` "// This file is automatically generated. // Please do not change this file! interface CssExports { - 'composedClass': string; - 'otherClass': string; - 'someClass': string; - 'validClass': string; + readonly 'composedClass': string; + readonly 'otherClass': string; + readonly 'someClass': string; + readonly 'validClass': string; } export const cssExports: CssExports; export default cssExports; diff --git a/test/verify-invalid-declaration/__snapshots__/verify-invalid-declaration.test.js.snap b/test/verify-invalid-declaration/__snapshots__/verify-invalid-declaration.test.js.snap index 82df075..37d7a7a 100644 --- a/test/verify-invalid-declaration/__snapshots__/verify-invalid-declaration.test.js.snap +++ b/test/verify-invalid-declaration/__snapshots__/verify-invalid-declaration.test.js.snap @@ -6,9 +6,10 @@ 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; - + 'classInCssFile': string; + + readonly 'classInBothFiles': string; + + readonly 'classInCssFile': string; } export const cssExports: CssExports; export default cssExports; diff --git a/test/verify-valid-declaration/index.css.d.ts b/test/verify-valid-declaration/index.css.d.ts index 9dfd5bc..7df58d7 100644 --- a/test/verify-valid-declaration/index.css.d.ts +++ b/test/verify-valid-declaration/index.css.d.ts @@ -1,11 +1,11 @@ // This file is automatically generated. // Please do not change this file! interface CssExports { - 'hyphened-classname': string; - 'otherClass': string; - 'someClass': string; - 'underscored_classname': string; - 'validClass': string; + readonly 'hyphened-classname': string; + readonly 'otherClass': string; + readonly 'someClass': string; + readonly 'underscored_classname': string; + readonly 'validClass': string; } export const cssExports: CssExports; export default cssExports;