From f7fac83320cf049f1fc690a6f609a47c4f019e17 Mon Sep 17 00:00:00 2001 From: "UCLES\\smithd" Date: Mon, 17 Sep 2018 16:05:01 +0100 Subject: [PATCH 1/9] Added typings for react-image-fallback package --- types/react-image-fallback/index.d.ts | 28 +++++++++++++ .../react-image-fallback-tests.tsx | 39 +++++++++++++++++++ types/react-image-fallback/tsconfig.json | 23 +++++++++++ types/react-image-fallback/tslint.json | 1 + 4 files changed, 91 insertions(+) create mode 100644 types/react-image-fallback/index.d.ts create mode 100644 types/react-image-fallback/react-image-fallback-tests.tsx create mode 100644 types/react-image-fallback/tsconfig.json create mode 100644 types/react-image-fallback/tslint.json diff --git a/types/react-image-fallback/index.d.ts b/types/react-image-fallback/index.d.ts new file mode 100644 index 0000000000..94cefd3dd8 --- /dev/null +++ b/types/react-image-fallback/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for react-image-fallback 8.0 +// Project: https://github.com/socialtables/react-image-fallback +// Definitions by: Ben Smith +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "react-image-fallback" { + import * as React from "react" + + class ReactImageFallback extends React.Component< + ReactImageFallbackProps & + React.DetailedHTMLProps< + React.ImgHTMLAttributes, + HTMLImageElement + >, + any + > { } + + export interface ReactImageFallbackProps { + src: string + fallbackImage: string | React.ReactElement | any[] + initialImage?: string | React.ReactElement + onLoad?: (event: React.SyntheticEvent) => void + onError?: (event: React.SyntheticEvent) => void + initialTimeout?: number + } + + export default ReactImageFallback +} diff --git a/types/react-image-fallback/react-image-fallback-tests.tsx b/types/react-image-fallback/react-image-fallback-tests.tsx new file mode 100644 index 0000000000..963c34b619 --- /dev/null +++ b/types/react-image-fallback/react-image-fallback-tests.tsx @@ -0,0 +1,39 @@ +import * as React from 'react'; +import ReactImageFallback, { ReactImageFallbackProps } from 'react-image-fallback'; + +class ReactImageFallbackSimple extends React.Component { + render() { + return ; + } +} + +class ReactImageFallbackWithOptionals extends React.Component { + onLoad(event: React.SyntheticEvent) { + } + + onError(event: React.SyntheticEvent) { + } + + render() { + return ; + } +} + +class ReactImageFallbackWithImageTagProps extends React.Component { + render() { + return ; + } +} diff --git a/types/react-image-fallback/tsconfig.json b/types/react-image-fallback/tsconfig.json new file mode 100644 index 0000000000..b0a490fd54 --- /dev/null +++ b/types/react-image-fallback/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-image-fallback-tests.tsx" + ] +} \ No newline at end of file diff --git a/types/react-image-fallback/tslint.json b/types/react-image-fallback/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-image-fallback/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b2d6067bdb5d3e6132e4f0d46c79c578de0712ce Mon Sep 17 00:00:00 2001 From: "UCLES\\smithd" Date: Mon, 17 Sep 2018 16:24:21 +0100 Subject: [PATCH 2/9] Specified typescript version --- types/react-image-fallback/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-image-fallback/index.d.ts b/types/react-image-fallback/index.d.ts index 94cefd3dd8..cd07d708ce 100644 --- a/types/react-image-fallback/index.d.ts +++ b/types/react-image-fallback/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/socialtables/react-image-fallback // Definitions by: Ben Smith // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 declare module "react-image-fallback" { import * as React from "react" From 279639474cf56deca7401af433007db98a885d1e Mon Sep 17 00:00:00 2001 From: "UCLES\\smithd" Date: Mon, 17 Sep 2018 16:33:45 +0100 Subject: [PATCH 3/9] require strictFunctionTypes --- types/react-image-fallback/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-image-fallback/tsconfig.json b/types/react-image-fallback/tsconfig.json index b0a490fd54..503d6a0c45 100644 --- a/types/react-image-fallback/tsconfig.json +++ b/types/react-image-fallback/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From eabb7a683d8250dfffef3b1e21a4363a349f373d Mon Sep 17 00:00:00 2001 From: "UCLES\\smithd" Date: Mon, 17 Sep 2018 16:47:19 +0100 Subject: [PATCH 4/9] Change to conform to required standards --- types/react-image-fallback/index.d.ts | 36 ++++++++++++--------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/types/react-image-fallback/index.d.ts b/types/react-image-fallback/index.d.ts index cd07d708ce..960a8c2c26 100644 --- a/types/react-image-fallback/index.d.ts +++ b/types/react-image-fallback/index.d.ts @@ -4,26 +4,22 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -declare module "react-image-fallback" { - import * as React from "react" +import * as React from "react"; - class ReactImageFallback extends React.Component< - ReactImageFallbackProps & - React.DetailedHTMLProps< - React.ImgHTMLAttributes, - HTMLImageElement - >, - any - > { } +export class ReactImageFallback extends React.Component< + ReactImageFallbackProps & + React.DetailedHTMLProps< + React.ImgHTMLAttributes, + HTMLImageElement + >, + any + > { } - export interface ReactImageFallbackProps { - src: string - fallbackImage: string | React.ReactElement | any[] - initialImage?: string | React.ReactElement - onLoad?: (event: React.SyntheticEvent) => void - onError?: (event: React.SyntheticEvent) => void - initialTimeout?: number - } - - export default ReactImageFallback +export interface ReactImageFallbackProps { + src: string; + fallbackImage: string | React.ReactElement | any[]; + initialImage?: string | React.ReactElement; + onLoad?: (event: React.SyntheticEvent) => void; + onError?: (event: React.SyntheticEvent) => void; + initialTimeout?: number; } From 83d3ce88e7ab49db50b071aab21cd7f68be5044e Mon Sep 17 00:00:00 2001 From: "UCLES\\smithd" Date: Mon, 17 Sep 2018 17:04:06 +0100 Subject: [PATCH 5/9] set default export --- types/react-image-fallback/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-image-fallback/index.d.ts b/types/react-image-fallback/index.d.ts index 960a8c2c26..8a70085214 100644 --- a/types/react-image-fallback/index.d.ts +++ b/types/react-image-fallback/index.d.ts @@ -6,7 +6,7 @@ import * as React from "react"; -export class ReactImageFallback extends React.Component< +export default class ReactImageFallback extends React.Component< ReactImageFallbackProps & React.DetailedHTMLProps< React.ImgHTMLAttributes, From 5733698c23fc947d0322cac3104dc8a0445b3e89 Mon Sep 17 00:00:00 2001 From: "UCLES\\smithd" Date: Mon, 17 Sep 2018 17:13:44 +0100 Subject: [PATCH 6/9] Replaced any[] with more specific requirements --- types/react-image-fallback/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-image-fallback/index.d.ts b/types/react-image-fallback/index.d.ts index 8a70085214..237649d735 100644 --- a/types/react-image-fallback/index.d.ts +++ b/types/react-image-fallback/index.d.ts @@ -17,7 +17,7 @@ export default class ReactImageFallback extends React.Component< export interface ReactImageFallbackProps { src: string; - fallbackImage: string | React.ReactElement | any[]; + fallbackImage: string | React.ReactElement | string[] | React.ReactElement[]; initialImage?: string | React.ReactElement; onLoad?: (event: React.SyntheticEvent) => void; onError?: (event: React.SyntheticEvent) => void; From caa398c255805f35f1ef463c115ccfea839db0ae Mon Sep 17 00:00:00 2001 From: "UCLES\\smithd" Date: Mon, 17 Sep 2018 17:20:08 +0100 Subject: [PATCH 7/9] Fixed another lint issue --- types/react-image-fallback/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-image-fallback/index.d.ts b/types/react-image-fallback/index.d.ts index 237649d735..207e2cb479 100644 --- a/types/react-image-fallback/index.d.ts +++ b/types/react-image-fallback/index.d.ts @@ -17,7 +17,7 @@ export default class ReactImageFallback extends React.Component< export interface ReactImageFallbackProps { src: string; - fallbackImage: string | React.ReactElement | string[] | React.ReactElement[]; + fallbackImage: string | React.ReactElement | Array | React.ReactElement[]; initialImage?: string | React.ReactElement; onLoad?: (event: React.SyntheticEvent) => void; onError?: (event: React.SyntheticEvent) => void; From 1f1d30dbc8508485890c5a19d556bd8cf1d2bb6c Mon Sep 17 00:00:00 2001 From: "UCLES\\smithd" Date: Tue, 18 Sep 2018 00:49:44 +0100 Subject: [PATCH 8/9] Changed array def to keep lint happy --- types/react-image-fallback/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-image-fallback/index.d.ts b/types/react-image-fallback/index.d.ts index 207e2cb479..3e4b4d4b84 100644 --- a/types/react-image-fallback/index.d.ts +++ b/types/react-image-fallback/index.d.ts @@ -17,7 +17,7 @@ export default class ReactImageFallback extends React.Component< export interface ReactImageFallbackProps { src: string; - fallbackImage: string | React.ReactElement | Array | React.ReactElement[]; + fallbackImage: string | React.ReactElement | Array | Array>; initialImage?: string | React.ReactElement; onLoad?: (event: React.SyntheticEvent) => void; onError?: (event: React.SyntheticEvent) => void; From cb636c4112b8515c9b80974e365e08916e2ffb80 Mon Sep 17 00:00:00 2001 From: "UCLES\\smithd" Date: Tue, 18 Sep 2018 01:02:38 +0100 Subject: [PATCH 9/9] Fixed issue with string array def --- types/react-image-fallback/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-image-fallback/index.d.ts b/types/react-image-fallback/index.d.ts index 3e4b4d4b84..4fcf2c20cd 100644 --- a/types/react-image-fallback/index.d.ts +++ b/types/react-image-fallback/index.d.ts @@ -17,7 +17,7 @@ export default class ReactImageFallback extends React.Component< export interface ReactImageFallbackProps { src: string; - fallbackImage: string | React.ReactElement | Array | Array>; + fallbackImage: string | React.ReactElement | string[] | Array>; initialImage?: string | React.ReactElement; onLoad?: (event: React.SyntheticEvent) => void; onError?: (event: React.SyntheticEvent) => void;