Extract react-inlinesvg type declarations from MyCrypto UI

This commit is contained in:
Nick McCurdy
2019-01-17 04:15:15 -05:00
parent b524207965
commit 53e22caeff
4 changed files with 82 additions and 0 deletions

38
types/react-inlinesvg/index.d.ts vendored Normal file
View File

@@ -0,0 +1,38 @@
// Type definitions for react-inlinesvg 0.8.3
// Project: https://github.com/gilbarbara/react-inlinesvg#readme
// Definitions by: MyCrypto <https://github.com/MyCryptoHQ>
// 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<Props>;
export default InlineSVG;

View File

@@ -0,0 +1,19 @@
import * as React from "react";
import SVG from 'react-inlinesvg';
function Loader() {
return null;
}
function myOnLoadHandler(src: string | URL) {
}
<SVG
src="/path/to/myfile.svg"
preloader={<Loader />}
onLoad={(src) => {
myOnLoadHandler(src);
}}
>
<img src="/path/to/myfile.png" />
</SVG>;

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }