From 53e22caeffdee0f151d13a49320cf05eea3c3a4d Mon Sep 17 00:00:00 2001 From: Nick McCurdy Date: Thu, 17 Jan 2019 04:15:15 -0500 Subject: [PATCH] Extract react-inlinesvg type declarations from MyCrypto UI --- types/react-inlinesvg/index.d.ts | 38 +++++++++++++++++++ .../react-inlinesvg/react-inlinesvg-tests.tsx | 19 ++++++++++ types/react-inlinesvg/tsconfig.json | 24 ++++++++++++ types/react-inlinesvg/tslint.json | 1 + 4 files changed, 82 insertions(+) create mode 100644 types/react-inlinesvg/index.d.ts create mode 100644 types/react-inlinesvg/react-inlinesvg-tests.tsx create mode 100644 types/react-inlinesvg/tsconfig.json create mode 100644 types/react-inlinesvg/tslint.json diff --git a/types/react-inlinesvg/index.d.ts b/types/react-inlinesvg/index.d.ts new file mode 100644 index 0000000000..6af53676ba --- /dev/null +++ b/types/react-inlinesvg/index.d.ts @@ -0,0 +1,38 @@ +// Type definitions for react-inlinesvg 0.8.3 +// Project: https://github.com/gilbarbara/react-inlinesvg#readme +// Definitions by: MyCrypto +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { ComponentType, ReactNode } from 'react'; + +export interface RequestError extends Error { + isHttpError: boolean; + status: number; +} + +export interface InlineSVGError extends Error { + name: 'InlineSVGError'; + isSupportedBrowser: boolean; + isConfigurationError: boolean; + isUnsupportedBrowserError: boolean; + message: string; +} + +export interface Props { + baseURL?: string; + cacheGetRequests?: boolean; + children?: ReactNode; + className?: string; + preloader?: ReactNode; + src: URL | string; + style?: object; + uniqueHash?: string; + uniquifyIDs?: boolean; + onError?(error: RequestError | InlineSVGError): void; + onLoad?(src: URL | string, isCached: boolean): void; + supportTest?(): void; + wrapper?(): ReactNode; +} + +declare const InlineSVG: ComponentType; +export default InlineSVG; diff --git a/types/react-inlinesvg/react-inlinesvg-tests.tsx b/types/react-inlinesvg/react-inlinesvg-tests.tsx new file mode 100644 index 0000000000..a7d90e0d86 --- /dev/null +++ b/types/react-inlinesvg/react-inlinesvg-tests.tsx @@ -0,0 +1,19 @@ +import * as React from "react"; +import SVG from 'react-inlinesvg'; + +function Loader() { + return null; +} + +function myOnLoadHandler(src: string | URL) { +} + +} + onLoad={(src) => { + myOnLoadHandler(src); + }} +> + +; diff --git a/types/react-inlinesvg/tsconfig.json b/types/react-inlinesvg/tsconfig.json new file mode 100644 index 0000000000..d8efae284d --- /dev/null +++ b/types/react-inlinesvg/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-inlinesvg-tests.tsx" + ] +} diff --git a/types/react-inlinesvg/tslint.json b/types/react-inlinesvg/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-inlinesvg/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }