Skip to content

Commit

Permalink
refactor(codegen): simplify return value hints
Browse files Browse the repository at this point in the history
  • Loading branch information
jonambas committed Apr 7, 2024
1 parent dc1734f commit 6222224
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const codegen = (
const ctDtsFile: ArtifactContent = {
file: 'ct.d.ts',
code: `${serializeMapTypes(map)}
\nexport const ct: <T extends keyof typeof pluginCtMap>(alias: T) => typeof pluginCtMap[T];`,
\nexport const ct: <T extends keyof PluginCtMapType>(alias: T) => PluginCtMapType[T];`,
};

cssFn.files.push(ctFile, ctDtsFile);
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const serializeValue = (value: any) => {
};

export const serializeMapTypes = (map: Map<any, any>) => {
let code = 'const pluginCtMap = {';
let code = 'type PluginCtMapType = {';
for (const [key, value] of map.entries()) {
code += `\n '${key}': ${serializeValue(value)},`;
}
code += '\n} as const;';
code += '\n}';
return code;
};

0 comments on commit 6222224

Please sign in to comment.