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
This commit is contained in:
Chen Junda
2018-02-27 07:35:26 -08:00
committed by Andy
parent 506d25b0c4
commit 75d01efe7e
4 changed files with 79 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
// Type definitions for react-svg 2.2
// Project: https://github.com/atomic-app/react-svg
// Definitions by: Chen Junda <https://github.com/viccrubs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import * as React from "react";
declare class ReactSVG extends React.Component<ReactSVG.ReactSVGProps> {}
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;
}
}
+14
View File
@@ -0,0 +1,14 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import ReactSVG = require("react-svg");
const complete = <ReactSVG
path={"atomic.svg"}
callback={svg => {}}
className="class-name"
wrapperClassName="wrapper-class-name"
evalScripts="once"
style={{}}
/>;
const minimal = <ReactSVG path={"test.svg"}/>;
+24
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }