Skip to content

Commit

Permalink
Add types
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Nov 11, 2022
1 parent 3b36d65 commit 3a8ebd9
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/svgo-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
"svgo-jsx": "./svgo-jsx-bin.js"
},
"exports": "./svgo-jsx.js",
"types": "./svgo-jsx.d.ts",
"files": [
"svgo-jsx-bin.js",
"svgo-jsx-cli.js",
"svgo-jsx.js",
"svgo-jsx.d.ts",
"mappings.js"
],
"dependencies": {
Expand Down
47 changes: 47 additions & 0 deletions packages/svgo-jsx/svgo-jsx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { Config as SvgoConfig } from "svgo";

type Target = "react-dom" | "react-native-svg" | "preact" | "custom";

type SvgProps = Record<string, null | string>;

type Options = {
file: string;
svg: string;
target?: Target;
svgProps?: SvgProps;
plugins?: SvgoConfig["plugins"];
};

type Output = {
jsx: string;
components: string[];
};

export declare function convertSvgToJsx(options: Options): Output;

type TemplateOptions = {
target: Target;
sourceFile: string;
targetFile: string;
componentName: string;
jsx: string;
components: string[];
};

type AfterOptions = {
targets: Array<{
file: string;
componentName: string;
}>;
};

export type Config = {
inputDir: string;
outputDir: string;
target?: Target;
svgProps?: SvgProps;
plugins?: SvgoConfig["plugins"];
template?: (options: TemplateOptions) => string;
transformFilename?: (file: string) => string;
after?: AfterOptions;
};

0 comments on commit 3a8ebd9

Please sign in to comment.