From 84e66f7ede43c3b5a834da559d3fb5d33bbd41a7 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 9 Jun 2018 02:43:18 -0700 Subject: [PATCH 1/3] Initial creation of react-lazylog types --- types/react-lazylog/build/LazyLog.d.ts | 28 +++++++++++++++ types/react-lazylog/build/Line.d.ts | 22 ++++++++++++ types/react-lazylog/build/LineContent.d.ts | 12 +++++++ types/react-lazylog/build/LineNumber.d.ts | 12 +++++++ types/react-lazylog/build/LinePart.d.ts | 11 ++++++ types/react-lazylog/build/Loading.d.ts | 5 +++ types/react-lazylog/build/ScrollFollow.d.ts | 19 +++++++++++ types/react-lazylog/index.d.ts | 8 +++++ types/react-lazylog/package.json | 6 ++++ types/react-lazylog/react-lazylog-tests.tsx | 38 +++++++++++++++++++++ types/react-lazylog/tsconfig.json | 22 ++++++++++++ types/react-lazylog/tslint.json | 1 + 12 files changed, 184 insertions(+) create mode 100644 types/react-lazylog/build/LazyLog.d.ts create mode 100644 types/react-lazylog/build/Line.d.ts create mode 100644 types/react-lazylog/build/LineContent.d.ts create mode 100644 types/react-lazylog/build/LineNumber.d.ts create mode 100644 types/react-lazylog/build/LinePart.d.ts create mode 100644 types/react-lazylog/build/Loading.d.ts create mode 100644 types/react-lazylog/build/ScrollFollow.d.ts create mode 100644 types/react-lazylog/index.d.ts create mode 100644 types/react-lazylog/package.json create mode 100644 types/react-lazylog/react-lazylog-tests.tsx create mode 100644 types/react-lazylog/tsconfig.json create mode 100644 types/react-lazylog/tslint.json diff --git a/types/react-lazylog/build/LazyLog.d.ts b/types/react-lazylog/build/LazyLog.d.ts new file mode 100644 index 0000000000..21b42f8030 --- /dev/null +++ b/types/react-lazylog/build/LazyLog.d.ts @@ -0,0 +1,28 @@ +import { Component, ReactNode, CSSProperties } from "react"; +import { Range } from "immutable"; + +export interface LazyLogProps { + url: string; + fetchOptions?: RequestInit; + stream?: boolean; + height?: string | number; + width?: string | number; + follow?: boolean; + scrollToLine?: number; + highlight?: number | number[]; + selectableLines?: boolean; + formatPart?: (text: string) => ReactNode; + onLoad?: () => any; + onError?: (error: any) => any; + onHighlight?: (range: Range) => any; + rowHeight?: number; + overscanRowCount?: number; + containerStyle?: CSSProperties; + style?: CSSProperties; +} + +export class LazyLog extends Component { + static defaultProps: Partial; +} + +export default LazyLog; diff --git a/types/react-lazylog/build/Line.d.ts b/types/react-lazylog/build/Line.d.ts new file mode 100644 index 0000000000..d7c93eeaa3 --- /dev/null +++ b/types/react-lazylog/build/Line.d.ts @@ -0,0 +1,22 @@ +import { Component, ReactNode, CSSProperties, MouseEventHandler } from "react"; + +export interface LineProps { + data: { text: string }[]; + number: number; + rowHeight: number; + highlight?: boolean; + selectable?: boolean; + style?: CSSProperties; + formatPart?: (text: string) => ReactNode; + onLineNumberClick?: MouseEventHandler; + + /** + * This is never called + * https://github.com/mozilla-frontend-infra/react-lazylog/issues/18 + */ + onRowClick?: () => any; +} + +export default class Line extends Component { + static defaultProps: Partial; +} diff --git a/types/react-lazylog/build/LineContent.d.ts b/types/react-lazylog/build/LineContent.d.ts new file mode 100644 index 0000000000..28e397fe0d --- /dev/null +++ b/types/react-lazylog/build/LineContent.d.ts @@ -0,0 +1,12 @@ +import { Component, ReactNode, CSSProperties } from "react"; + +export interface LineContentProps { + data: { text: string }[]; + number: number; + formatPart?: (text: string) => ReactNode; + style?: CSSProperties; +} + +export default class LineContent extends Component { + static defaultProps: Partial; +} diff --git a/types/react-lazylog/build/LineNumber.d.ts b/types/react-lazylog/build/LineNumber.d.ts new file mode 100644 index 0000000000..4a7aa396d4 --- /dev/null +++ b/types/react-lazylog/build/LineNumber.d.ts @@ -0,0 +1,12 @@ +import { Component, ReactNode, CSSProperties, MouseEventHandler } from "react"; + +export interface LineNumberProps { + number: number; + highlight?: boolean; + onClick?: MouseEventHandler; + style?: CSSProperties; +} + +export default class LinePart extends Component { + static defaultProps: Partial; +} diff --git a/types/react-lazylog/build/LinePart.d.ts b/types/react-lazylog/build/LinePart.d.ts new file mode 100644 index 0000000000..4b0ff946a2 --- /dev/null +++ b/types/react-lazylog/build/LinePart.d.ts @@ -0,0 +1,11 @@ +import { Component, ReactNode, CSSProperties } from "react"; + +export interface LinePartProps { + part: { text: string }; + format?: (text: string) => ReactNode; + style?: CSSProperties; +} + +export default class LinePart extends Component { + static defaultProps: Partial; +} diff --git a/types/react-lazylog/build/Loading.d.ts b/types/react-lazylog/build/Loading.d.ts new file mode 100644 index 0000000000..7428caea7b --- /dev/null +++ b/types/react-lazylog/build/Loading.d.ts @@ -0,0 +1,5 @@ +import { Component } from "react"; + +export interface LoadingProps {} + +export default class Loading extends Component {} diff --git a/types/react-lazylog/build/ScrollFollow.d.ts b/types/react-lazylog/build/ScrollFollow.d.ts new file mode 100644 index 0000000000..c2da7f0fb2 --- /dev/null +++ b/types/react-lazylog/build/ScrollFollow.d.ts @@ -0,0 +1,19 @@ +import { Component, ReactNode } from "react"; + +export interface ScrollFollowRenderProps { + onScroll: ( + args: { scrollTop: number; scrollHeight: number; clientHeight: number } + ) => void; + follow: boolean; + startFollowing: () => void; + stopFollowing: () => void; +} + +export interface ScrollFollowProps { + render: (props: ScrollFollowRenderProps) => ReactNode; + startFollowing?: boolean; +} + +export class ScrollFollow extends Component {} + +export default ScrollFollow; diff --git a/types/react-lazylog/index.d.ts b/types/react-lazylog/index.d.ts new file mode 100644 index 0000000000..051ad7f536 --- /dev/null +++ b/types/react-lazylog/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for react-lazylog 3.1.4 +// Project: https://github.com/mozilla-frontend-infra/react-lazylog +// Definitions by: Benjamin Romano +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export * from "./build/LazyLog"; +export * from "./build/ScrollFollow"; diff --git a/types/react-lazylog/package.json b/types/react-lazylog/package.json new file mode 100644 index 0000000000..c658c73862 --- /dev/null +++ b/types/react-lazylog/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "immutable": ">=3.8.2" + } +} diff --git a/types/react-lazylog/react-lazylog-tests.tsx b/types/react-lazylog/react-lazylog-tests.tsx new file mode 100644 index 0000000000..3c66c82b55 --- /dev/null +++ b/types/react-lazylog/react-lazylog-tests.tsx @@ -0,0 +1,38 @@ +import * as React from "react"; +import LinePart, { LinePartProps } from "react-lazylog/build/LinePart"; +import LineNumber, { LineNumberProps } from "react-lazylog/build/LineNumber"; +import LineContent, { LineContentProps } from "react-lazylog/build/LineContent"; +import Line, { LineProps } from "react-lazylog/build/Line"; +import Loading from "react-lazylog/build/Loading"; +import { + LazyLog, + LazyLogProps, + ScrollFollow, + ScrollFollowProps, + ScrollFollowRenderProps +} from "react-lazylog"; + +LinePart.defaultProps.style = { color: "green" }; +const linePart = ; + +LineNumber.defaultProps.style = { color: "green" }; +const lineNumber = ; + +LineContent.defaultProps.style = { color: "green" }; +const lineContent = ; + +Line.defaultProps.style = { color: "green" }; +const line = ; + +const loading = ; + +const scrollFollow = ( + ( +
+ )} + /> +); + +LazyLog.defaultProps.style = { color: "green" }; +const lazyLog = ; diff --git a/types/react-lazylog/tsconfig.json b/types/react-lazylog/tsconfig.json new file mode 100644 index 0000000000..a1b35d2311 --- /dev/null +++ b/types/react-lazylog/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "react-lazylog-tests.tsx", + "index.d.ts", + "lib/build/LazyLog.d.ts", + "lib/build/LinePart.d.ts" + ] +} diff --git a/types/react-lazylog/tslint.json b/types/react-lazylog/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-lazylog/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From fbd62bbdf081809f69fe1ae4cf77697123202960 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 9 Jun 2018 02:55:48 -0700 Subject: [PATCH 2/3] Fix lint warnings --- types/react-lazylog/build/Line.d.ts | 2 +- types/react-lazylog/build/LineContent.d.ts | 2 +- types/react-lazylog/build/Loading.d.ts | 4 +--- types/react-lazylog/index.d.ts | 2 +- types/react-lazylog/tsconfig.json | 7 +++++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/types/react-lazylog/build/Line.d.ts b/types/react-lazylog/build/Line.d.ts index d7c93eeaa3..85c3444289 100644 --- a/types/react-lazylog/build/Line.d.ts +++ b/types/react-lazylog/build/Line.d.ts @@ -1,7 +1,7 @@ import { Component, ReactNode, CSSProperties, MouseEventHandler } from "react"; export interface LineProps { - data: { text: string }[]; + data: Array<{ text: string }>; number: number; rowHeight: number; highlight?: boolean; diff --git a/types/react-lazylog/build/LineContent.d.ts b/types/react-lazylog/build/LineContent.d.ts index 28e397fe0d..1bece45340 100644 --- a/types/react-lazylog/build/LineContent.d.ts +++ b/types/react-lazylog/build/LineContent.d.ts @@ -1,7 +1,7 @@ import { Component, ReactNode, CSSProperties } from "react"; export interface LineContentProps { - data: { text: string }[]; + data: Array<{ text: string }>; number: number; formatPart?: (text: string) => ReactNode; style?: CSSProperties; diff --git a/types/react-lazylog/build/Loading.d.ts b/types/react-lazylog/build/Loading.d.ts index 7428caea7b..45d1f38f15 100644 --- a/types/react-lazylog/build/Loading.d.ts +++ b/types/react-lazylog/build/Loading.d.ts @@ -1,5 +1,3 @@ import { Component } from "react"; -export interface LoadingProps {} - -export default class Loading extends Component {} +export default class Loading extends Component {} diff --git a/types/react-lazylog/index.d.ts b/types/react-lazylog/index.d.ts index 051ad7f536..6f9ad8aab8 100644 --- a/types/react-lazylog/index.d.ts +++ b/types/react-lazylog/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-lazylog 3.1.4 +// Type definitions for react-lazylog 3.1 // Project: https://github.com/mozilla-frontend-infra/react-lazylog // Definitions by: Benjamin Romano // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/react-lazylog/tsconfig.json b/types/react-lazylog/tsconfig.json index a1b35d2311..856e2e40aa 100644 --- a/types/react-lazylog/tsconfig.json +++ b/types/react-lazylog/tsconfig.json @@ -16,7 +16,10 @@ "files": [ "react-lazylog-tests.tsx", "index.d.ts", - "lib/build/LazyLog.d.ts", - "lib/build/LinePart.d.ts" + "build/Line.d.ts", + "build/LineContent.d.ts", + "build/LineNumber.d.ts", + "build/LinePart.d.ts", + "build/Loading.d.ts" ] } From 20c656b299af3090b08b7023d74364737cd36e63 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 9 Jun 2018 03:04:21 -0700 Subject: [PATCH 3/3] increase ts version num --- types/react-lazylog/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-lazylog/index.d.ts b/types/react-lazylog/index.d.ts index 6f9ad8aab8..57c7b623a1 100644 --- a/types/react-lazylog/index.d.ts +++ b/types/react-lazylog/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/mozilla-frontend-infra/react-lazylog // Definitions by: Benjamin Romano // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.6 export * from "./build/LazyLog"; export * from "./build/ScrollFollow";