From 75d01efe7edf13c145fa9e5c0f6f924552bece64 Mon Sep 17 00:00:00 2001 From: Chen Junda Date: Tue, 27 Feb 2018 23:35:26 +0800 Subject: [PATCH] Adds definitions for react-svg (#23905) * adds definition for react-svg * changed typescript version to 2.6 * make it work with require * fixed lint error --- types/react-svg/index.d.ts | 40 +++++++++++++++++++++++++++++ types/react-svg/react-svg-tests.tsx | 14 ++++++++++ types/react-svg/tsconfig.json | 24 +++++++++++++++++ types/react-svg/tslint.json | 1 + 4 files changed, 79 insertions(+) create mode 100644 types/react-svg/index.d.ts create mode 100644 types/react-svg/react-svg-tests.tsx create mode 100644 types/react-svg/tsconfig.json create mode 100644 types/react-svg/tslint.json diff --git a/types/react-svg/index.d.ts b/types/react-svg/index.d.ts new file mode 100644 index 0000000000..31a4533f57 --- /dev/null +++ b/types/react-svg/index.d.ts @@ -0,0 +1,40 @@ +// Type definitions for react-svg 2.2 +// Project: https://github.com/atomic-app/react-svg +// Definitions by: Chen Junda +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as React from "react"; + +declare class ReactSVG extends React.Component {} + +export = ReactSVG; + +declare namespace ReactSVG { + interface ReactSVGProps { + /** + * Path to the SVG. + */ + path: string; + /** + * Function to call after the SVG is injected. Receives the newly injected SVG DOM element as a parameter. Defaults to null. + */ + callback?: (dom: SVGSVGElement) => void; + /** + * Class name to be added to the SVG. Defaults to ''. + */ + className?: string; + /** + * Class name to be added to the wrapping div. Defaults to ''. + */ + wrapperClassName?: string; + /** + * Run any script blocks found in the SVG (always, once, or never). Defaults to never. + */ + evalScripts?: 'always' | 'once' | 'never'; + /** + * Inline styles to be added to the SVG. Defaults to {}. + */ + style?: any; + } +} diff --git a/types/react-svg/react-svg-tests.tsx b/types/react-svg/react-svg-tests.tsx new file mode 100644 index 0000000000..338698b036 --- /dev/null +++ b/types/react-svg/react-svg-tests.tsx @@ -0,0 +1,14 @@ +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; +import ReactSVG = require("react-svg"); + +const complete = {}} + className="class-name" + wrapperClassName="wrapper-class-name" + evalScripts="once" + style={{}} + />; + +const minimal = ; diff --git a/types/react-svg/tsconfig.json b/types/react-svg/tsconfig.json new file mode 100644 index 0000000000..43b8246d54 --- /dev/null +++ b/types/react-svg/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "jsx": "react", + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-svg-tests.tsx" + ] +} diff --git a/types/react-svg/tslint.json b/types/react-svg/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-svg/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }