Skip to content

Commit 383421b

Browse files
committed
Implement types
1 parent 16443b5 commit 383421b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/plugin/generate-esm.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,19 @@ const dtsComment = `
141141

142142
export const generateTypes = (
143143
exports: Exports,
144+
composedClassesMode: ComposedClassesMode,
144145
allowArbitraryNamedExports = false,
145146
) => {
146147
const variables = new Set<string>();
147148
const exportedVariables = Object.entries(exports).flatMap(
148-
([exportName, { exportAs }]) => {
149+
([exportName, { exportAs, code: value }]) => {
149150
const jsVariable = makeLegalIdentifier(exportName);
150-
variables.add(`const ${jsVariable}: string;`);
151+
152+
if (composedClassesMode === 'string' || (composedClassesMode === 'array' && !value.includes(' '))) {
153+
variables.add(`const ${jsVariable}: string;`);
154+
} else {
155+
variables.add(`const ${jsVariable}: string[];`);
156+
}
151157

152158
return Array.from(exportAs).map((exportAsName) => {
153159
const exportNameSafe = makeLegalIdentifier(exportAsName);

src/plugin/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ export const cssModules = (
318318
if (fileExists) {
319319
await writeFile(
320320
`${id}.d.ts`,
321-
generateTypes(exports, allowArbitraryNamedExports),
321+
generateTypes(exports, composedClassesMode, allowArbitraryNamedExports),
322322
);
323323
}
324324
}

0 commit comments

Comments
 (0)