Skip to content

Commit 3a8ebd9

Browse files
committed
Add types
1 parent 3b36d65 commit 3a8ebd9

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

packages/svgo-jsx/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
"svgo-jsx": "./svgo-jsx-bin.js"
1414
},
1515
"exports": "./svgo-jsx.js",
16+
"types": "./svgo-jsx.d.ts",
1617
"files": [
1718
"svgo-jsx-bin.js",
1819
"svgo-jsx-cli.js",
1920
"svgo-jsx.js",
21+
"svgo-jsx.d.ts",
2022
"mappings.js"
2123
],
2224
"dependencies": {

packages/svgo-jsx/svgo-jsx.d.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import type { Config as SvgoConfig } from "svgo";
2+
3+
type Target = "react-dom" | "react-native-svg" | "preact" | "custom";
4+
5+
type SvgProps = Record<string, null | string>;
6+
7+
type Options = {
8+
file: string;
9+
svg: string;
10+
target?: Target;
11+
svgProps?: SvgProps;
12+
plugins?: SvgoConfig["plugins"];
13+
};
14+
15+
type Output = {
16+
jsx: string;
17+
components: string[];
18+
};
19+
20+
export declare function convertSvgToJsx(options: Options): Output;
21+
22+
type TemplateOptions = {
23+
target: Target;
24+
sourceFile: string;
25+
targetFile: string;
26+
componentName: string;
27+
jsx: string;
28+
components: string[];
29+
};
30+
31+
type AfterOptions = {
32+
targets: Array<{
33+
file: string;
34+
componentName: string;
35+
}>;
36+
};
37+
38+
export type Config = {
39+
inputDir: string;
40+
outputDir: string;
41+
target?: Target;
42+
svgProps?: SvgProps;
43+
plugins?: SvgoConfig["plugins"];
44+
template?: (options: TemplateOptions) => string;
45+
transformFilename?: (file: string) => string;
46+
after?: AfterOptions;
47+
};

0 commit comments

Comments
 (0)