Skip to content

Commit 7daff50

Browse files
committed
fix: type exports
1 parent 75b1d25 commit 7daff50

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

.changeset/ninety-bars-sit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rhds/tokens": patch
3+
---
4+
Fix typescript type exports
5+

lib/actions/write-es-map-declaration.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,18 @@ const rel = (path: string) => new URL(path, import.meta.url);
77
const files = new Map([
88
[
99
rel('../../js/tokens.d.ts'),
10-
'export declare const tokens: Map<`--rh-${string}`, string|number>;',
10+
/* ts */`\
11+
import { ValuesMap } from './types.js';
12+
export type * from './types.js';
13+
export declare const tokens: ValuesMap;
14+
`,
1115
],
1216
[
1317
rel('../../js/meta.d.ts'),
14-
`interface DesignToken {
15-
value?: any;
16-
$value?: any;
17-
type?: string;
18-
$type?: string;
19-
$description?: string;
20-
name?: string;
21-
comment?: string;
22-
themeable?: boolean;
23-
attributes?: Record<string, unknown>;
24-
[key: string]: any;
25-
}
26-
27-
export declare const tokens: Map<\`--rh-\${string}\`, DesignToken>;
18+
/* ts */`\
19+
import { ValuesMap } from './types.js';
20+
export type * from './types.js';
21+
export declare const tokens: DesignTokensMap;
2822
`,
2923
],
3024
]);
@@ -45,5 +39,3 @@ export const writeEsMapDeclaration: Action = {
4539
}
4640
},
4741
};
48-
49-

lib/types.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,22 @@ export interface Color {
2020
a: number;
2121
};
2222
}
23+
24+
// copied from style-dictionary
25+
/* eslint-disable @typescript-eslint/no-explicit-any */
26+
export interface DesignToken {
27+
value?: any;
28+
$value?: any;
29+
type?: string;
30+
$type?: string;
31+
$description?: string;
32+
name?: string;
33+
comment?: string;
34+
themeable?: boolean;
35+
attributes?: Record<string, unknown>;
36+
[key: string]: any;
37+
}
38+
/* eslint-enable @typescript-eslint/no-explicit-any */
39+
40+
export type DesignTokensMap = Map<`--rh-${string}`, DesignToken>;
41+
export type ValuesMap = Map<`--rh-${string}`, string | number>;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"type": "module",
1616
"main": "js/tokens.cjs",
1717
"module": "js/tokens.js",
18+
"types": "js/types.d.ts",
1819
"exports": {
1920
".": {
2021
"import": "./js/tokens.js",

0 commit comments

Comments
 (0)