File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed
Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -37,14 +37,14 @@ describe('codegen', () => {
3737 "file": "ct.mjs",
3838 },
3939 {
40- "code": "const pluginCtMap = {
40+ "code": "type PluginCtMapType = {
4141 'foo.100': '#fff',
4242 'foo.200': {"base":"#000","lg":"#111"},
4343 'bar.100': 'red',
4444 'bar.200': 'blue',
45- } as const;
45+ }
4646
47- export const ct: <T extends keyof typeof pluginCtMap >(alias: T) => typeof pluginCtMap [T];",
47+ export const ct: <T extends keyof PluginCtMapType >(alias: T) => PluginCtMapType [T];",
4848 "file": "ct.d.ts",
4949 },
5050 ],
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export const codegen = (
3232 const ctDtsFile : ArtifactContent = {
3333 file : 'ct.d.ts' ,
3434 code : `${ serializeMapTypes ( map ) }
35- \nexport const ct: <T extends keyof typeof pluginCtMap >(alias: T) => typeof pluginCtMap [T];` ,
35+ \nexport const ct: <T extends keyof PluginCtMapType >(alias: T) => PluginCtMapType [T];` ,
3636 } ;
3737
3838 cssFn . files . push ( ctFile , ctDtsFile ) ;
Original file line number Diff line number Diff line change @@ -15,10 +15,10 @@ export const serializeValue = (value: any) => {
1515} ;
1616
1717export const serializeMapTypes = ( map : Map < any , any > ) => {
18- let code = 'const pluginCtMap = {' ;
18+ let code = 'type PluginCtMapType = {' ;
1919 for ( const [ key , value ] of map . entries ( ) ) {
2020 code += `\n '${ key } ': ${ serializeValue ( value ) } ,` ;
2121 }
22- code += '\n} as const; ' ;
22+ code += '\n}' ;
2323 return code ;
2424} ;
You can’t perform that action at this time.
0 commit comments