Skip to content

Commit daccbec

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat/option-to-disable-locals-generation
2 parents 000b532 + a8fe7ee commit daccbec

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

src/utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,24 @@ const filenameToTypingsFilename = filename => {
5050
const generateGenericExportInterface = (cssModuleKeys, pascalCaseFileName, disableLocalsExport) => {
5151
const interfaceName = `I${pascalCaseFileName}`;
5252
const moduleName = `${pascalCaseFileName}Module`;
53+
const namespaceName = `${pascalCaseFileName}Namespace`;
5354

5455
const localsExportType = disableLocalsExport ? `` : ` & {
5556
/** WARNING: Only available when \`css-loader\` is used without \`style-loader\` or \`mini-css-extract-plugin\` */
56-
locals: ${moduleName}.${interfaceName};
57+
locals: ${namespaceName}.${interfaceName};
5758
}`;
5859

5960
const interfaceProperties = cssModuleToTypescriptInterfaceProperties(
6061
cssModuleKeys,
6162
" "
6263
);
63-
return `declare namespace ${moduleName} {
64+
return `declare namespace ${namespaceName} {
6465
export interface I${pascalCaseFileName} {
6566
${interfaceProperties}
6667
}
6768
}
6869
69-
declare const ${moduleName}: ${moduleName}.${interfaceName}${localsExportType};
70+
declare const ${moduleName}: ${namespaceName}.${interfaceName}${localsExportType};
7071
7172
export = ${moduleName};`;
7273
};

test/__snapshots__/index.test.js.snap

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`default options 1`] = `
4-
"declare namespace ExampleCssModule {
4+
"declare namespace ExampleCssNamespace {
55
export interface IExampleCss {
66
\\"bar-baz\\": string;
77
composed: string;
88
foo: string;
99
}
1010
}
1111
12-
declare const ExampleCssModule: ExampleCssModule.IExampleCss & {
12+
declare const ExampleCssModule: ExampleCssNamespace.IExampleCss & {
1313
/** WARNING: Only available when \`css-loader\` is used without \`style-loader\` or \`mini-css-extract-plugin\` */
14-
locals: ExampleCssModule.IExampleCss;
14+
locals: ExampleCssNamespace.IExampleCss;
1515
};
1616
1717
export = ExampleCssModule;
1818
"
1919
`;
2020

2121
exports[`localsConvention asIs 1`] = `
22-
"declare namespace ExampleCssModule {
22+
"declare namespace ExampleCssNamespace {
2323
export interface IExampleCss {
2424
\\"bar-baz\\": string;
2525
composed: string;
2626
foo: string;
2727
}
2828
}
2929
30-
declare const ExampleCssModule: ExampleCssModule.IExampleCss & {
30+
declare const ExampleCssModule: ExampleCssNamespace.IExampleCss & {
3131
/** WARNING: Only available when \`css-loader\` is used without \`style-loader\` or \`mini-css-extract-plugin\` */
32-
locals: ExampleCssModule.IExampleCss;
32+
locals: ExampleCssNamespace.IExampleCss;
3333
};
3434
3535
export = ExampleCssModule;
3636
"
3737
`;
3838

3939
exports[`localsConvention camelCase 1`] = `
40-
"declare namespace ExampleCssModule {
40+
"declare namespace ExampleCssNamespace {
4141
export interface IExampleCss {
4242
\\"bar-baz\\": string;
4343
barBaz: string;
@@ -46,9 +46,9 @@ exports[`localsConvention camelCase 1`] = `
4646
}
4747
}
4848
49-
declare const ExampleCssModule: ExampleCssModule.IExampleCss & {
49+
declare const ExampleCssModule: ExampleCssNamespace.IExampleCss & {
5050
/** WARNING: Only available when \`css-loader\` is used without \`style-loader\` or \`mini-css-extract-plugin\` */
51-
locals: ExampleCssModule.IExampleCss;
51+
locals: ExampleCssNamespace.IExampleCss;
5252
};
5353
5454
export = ExampleCssModule;
@@ -57,85 +57,85 @@ export = ExampleCssModule;
5757

5858
exports[`with banner 1`] = `
5959
"// autogenerated by typings-for-css-modules-loader
60-
declare namespace ExampleCssModule {
60+
declare namespace ExampleCssNamespace {
6161
export interface IExampleCss {
6262
\\"bar-baz\\": string;
6363
composed: string;
6464
foo: string;
6565
}
6666
}
6767
68-
declare const ExampleCssModule: ExampleCssModule.IExampleCss & {
68+
declare const ExampleCssModule: ExampleCssNamespace.IExampleCss & {
6969
/** WARNING: Only available when \`css-loader\` is used without \`style-loader\` or \`mini-css-extract-plugin\` */
70-
locals: ExampleCssModule.IExampleCss;
70+
locals: ExampleCssNamespace.IExampleCss;
7171
};
7272
7373
export = ExampleCssModule;
7474
"
7575
`;
7676

7777
exports[`with locals export disabled 1`] = `
78-
"declare namespace ExampleCssModule {
78+
"declare namespace ExampleCssNamespace {
7979
export interface IExampleCss {
8080
\\"bar-baz\\": string;
8181
composed: string;
8282
foo: string;
8383
}
8484
}
8585
86-
declare const ExampleCssModule: ExampleCssModule.IExampleCss;
86+
declare const ExampleCssModule: ExampleCssNamespace.IExampleCss;
8787
8888
export = ExampleCssModule;
8989
"
9090
`;
9191

9292
exports[`with no formatter 1`] = `
93-
"declare namespace ExampleCssModule {
93+
"declare namespace ExampleCssNamespace {
9494
export interface IExampleCss {
9595
'bar-baz': string;
9696
'composed': string;
9797
'foo': string;
9898
}
9999
}
100100
101-
declare const ExampleCssModule: ExampleCssModule.IExampleCss & {
101+
declare const ExampleCssModule: ExampleCssNamespace.IExampleCss & {
102102
/** WARNING: Only available when \`css-loader\` is used without \`style-loader\` or \`mini-css-extract-plugin\` */
103-
locals: ExampleCssModule.IExampleCss;
103+
locals: ExampleCssNamespace.IExampleCss;
104104
};
105105
106106
export = ExampleCssModule;"
107107
`;
108108

109109
exports[`with prettier 1`] = `
110-
"declare namespace ExampleCssModule {
110+
"declare namespace ExampleCssNamespace {
111111
export interface IExampleCss {
112112
\\"bar-baz\\": string;
113113
composed: string;
114114
foo: string;
115115
}
116116
}
117117
118-
declare const ExampleCssModule: ExampleCssModule.IExampleCss & {
118+
declare const ExampleCssModule: ExampleCssNamespace.IExampleCss & {
119119
/** WARNING: Only available when \`css-loader\` is used without \`style-loader\` or \`mini-css-extract-plugin\` */
120-
locals: ExampleCssModule.IExampleCss;
120+
locals: ExampleCssNamespace.IExampleCss;
121121
};
122122
123123
export = ExampleCssModule;
124124
"
125125
`;
126126

127127
exports[`with sourcemap 1`] = `
128-
"declare namespace ExampleCssModule {
128+
"declare namespace ExampleCssNamespace {
129129
export interface IExampleCss {
130130
\\"bar-baz\\": string;
131131
composed: string;
132132
foo: string;
133133
}
134134
}
135135
136-
declare const ExampleCssModule: ExampleCssModule.IExampleCss & {
136+
declare const ExampleCssModule: ExampleCssNamespace.IExampleCss & {
137137
/** WARNING: Only available when \`css-loader\` is used without \`style-loader\` or \`mini-css-extract-plugin\` */
138-
locals: ExampleCssModule.IExampleCss;
138+
locals: ExampleCssNamespace.IExampleCss;
139139
};
140140
141141
export = ExampleCssModule;

0 commit comments

Comments
 (0)