From 1cde5fd4bed85380a1fcf88d5bfced87e82c5622 Mon Sep 17 00:00:00 2001 From: Pete Date: Thu, 14 Feb 2019 21:59:35 -0800 Subject: [PATCH 1/8] Allow arbitrary strings in string literal union types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Restore `Transform` and `ValueTransform` string union literal types • Use generics to allow arbitrary strings for parameters with the previously listed types • Move exported functions to the bottom of the file --- types/theo/index.d.ts | 133 +++++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 61 deletions(-) diff --git a/types/theo/index.d.ts b/types/theo/index.d.ts index d60a797159..27ee6c51c0 100644 --- a/types/theo/index.d.ts +++ b/types/theo/index.d.ts @@ -5,51 +5,46 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -import { Collection, Map, List, OrderedMap } from "immutable"; +import { Collection, Map, List, OrderedMap } from 'immutable' export type StyleProperty = - | "name" - | "value" - | "type" - | "originalValue" - | "category" - | "comment" - | "meta"; + | 'name' + | 'value' + | 'type' + | 'originalValue' + | 'category' + | 'comment' + | 'meta'; export type Format = - | "custom-properties.css" - | "cssmodules.css" - | "scss" - | "sass" - | "less" - | "styl" - | "map.css" - | "map.variable.scss" - | "list.scss" - | "module.js" - | "common.js" - | "html" - | "json" - | "raw.json" - | "ios.json" - | "android.xml" - | "aura.tokens"; + | 'custom-properties.css' + | 'cssmodules.css' + | 'scss' + | 'sass' + | 'less' + | 'styl' + | 'map.css' + | 'map.variable.scss' + | 'list.scss' + | 'module.js' + | 'common.js' + | 'html' + | 'json' + | 'raw.json' + | 'ios.json' + | 'android.xml' + | 'aura.tokens'; -export function convert(options: ConvertOptions): Promise; -export function convertSync(options: ConvertOptions): string; -export function registerFormat( - name: string, - format: FormatResultFn | string -): void; -export function registerTransform( - name: string, - valueTransforms: string[] -): void; -export function registerValueTransform( - name: string, - predicate: (prop: Prop) => boolean, - transform: (prop: Prop) => string | number -): void; +export type Transform = 'raw' | 'ios' | 'android' | 'web'; + +export type ValueTransform = + | 'color/rgb' + | 'color/hex' + | 'color/hex8rgba' + | 'color/hex8argb' + | 'percentage/float' + | 'relative/pixel' + | 'relative/pixelValue'; export type Prop = Map; export type Props = List; @@ -58,36 +53,52 @@ export type Meta = Map; export type FormatResultFn = (result: ImmutableStyleMap) => string; export interface StyleMap { - aliases: Aliases; - global?: Props; - imports?: string[]; - props: Props; - meta: Meta; - options: object; + aliases: Aliases; + global?: Props; + imports?: string[]; + props: Props; + meta: Meta; + options: object; } export interface ImmutableStyleMap extends Map { - toJS(): StyleMap; - get(key: K): StyleMap[K]; + toJS(): StyleMap; + get(key: K): StyleMap[K]; } export interface ConvertOptions { - transform: TransformOptions; - format: FormatOptions; - resolveAliases?: boolean; - resolveMetaAliases?: boolean; + transform: TransformOptions; + format: FormatOptions; + resolveAliases?: boolean; + resolveMetaAliases?: boolean; } -export interface TransformOptions { - type?: string; - file: string; - data?: string; +export interface TransformOptions { + type?: Transform | T; + file: string; + data?: string; } export interface FormatOptions { - type: Format; - options?: ( - options: object, - transformPropName?: (name: string) => string - ) => void; + type: Format; + options?: ( + options: object, + transformPropName?: (name: string) => string + ) => void; } + +export function convert(options: ConvertOptions): Promise; +export function convertSync(options: ConvertOptions): string; +export function registerFormat( + name: Format | T, + format: FormatResultFn | string +): void; +export function registerTransform( + name: Transform | T, + valueTransforms: ValueTransform[] | T[] +): void; +export function registerValueTransform( + name: ValueTransform | T, + predicate: (prop: Prop) => boolean, + transform: (prop: Prop) => string | number +): void; From b9c1d04fefc27a7e2d433a9739b0e2b355c58316 Mon Sep 17 00:00:00 2001 From: Pete Date: Thu, 14 Feb 2019 22:05:14 -0800 Subject: [PATCH 2/8] Undo prettier formatting and fix type argument error --- types/theo/index.d.ts | 128 +++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/types/theo/index.d.ts b/types/theo/index.d.ts index 27ee6c51c0..3735da3e0c 100644 --- a/types/theo/index.d.ts +++ b/types/theo/index.d.ts @@ -5,46 +5,46 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -import { Collection, Map, List, OrderedMap } from 'immutable' +import { Collection, Map, List, OrderedMap } from "immutable"; export type StyleProperty = - | 'name' - | 'value' - | 'type' - | 'originalValue' - | 'category' - | 'comment' - | 'meta'; + | "name" + | "value" + | "type" + | "originalValue" + | "category" + | "comment" + | "meta"; export type Format = - | 'custom-properties.css' - | 'cssmodules.css' - | 'scss' - | 'sass' - | 'less' - | 'styl' - | 'map.css' - | 'map.variable.scss' - | 'list.scss' - | 'module.js' - | 'common.js' - | 'html' - | 'json' - | 'raw.json' - | 'ios.json' - | 'android.xml' - | 'aura.tokens'; + | "custom-properties.css" + | "cssmodules.css" + | "scss" + | "sass" + | "less" + | "styl" + | "map.css" + | "map.variable.scss" + | "list.scss" + | "module.js" + | "common.js" + | "html" + | "json" + | "raw.json" + | "ios.json" + | "android.xml" + | "aura.tokens"; -export type Transform = 'raw' | 'ios' | 'android' | 'web'; +export type Transform = "raw" | "ios" | "android" | "web"; export type ValueTransform = - | 'color/rgb' - | 'color/hex' - | 'color/hex8rgba' - | 'color/hex8argb' - | 'percentage/float' - | 'relative/pixel' - | 'relative/pixelValue'; + | "color/rgb" + | "color/hex" + | "color/hex8rgba" + | "color/hex8argb" + | "percentage/float" + | "relative/pixel" + | "relative/pixelValue"; export type Prop = Map; export type Props = List; @@ -53,52 +53,52 @@ export type Meta = Map; export type FormatResultFn = (result: ImmutableStyleMap) => string; export interface StyleMap { - aliases: Aliases; - global?: Props; - imports?: string[]; - props: Props; - meta: Meta; - options: object; + aliases: Aliases; + global?: Props; + imports?: string[]; + props: Props; + meta: Meta; + options: object; } export interface ImmutableStyleMap extends Map { - toJS(): StyleMap; - get(key: K): StyleMap[K]; + toJS(): StyleMap; + get(key: K): StyleMap[K]; } export interface ConvertOptions { - transform: TransformOptions; - format: FormatOptions; - resolveAliases?: boolean; - resolveMetaAliases?: boolean; + transform: TransformOptions; + format: FormatOptions; + resolveAliases?: boolean; + resolveMetaAliases?: boolean; } -export interface TransformOptions { - type?: Transform | T; - file: string; - data?: string; +export interface TransformOptions { + type?: Transform | T; + file: string; + data?: string; } export interface FormatOptions { - type: Format; - options?: ( - options: object, - transformPropName?: (name: string) => string - ) => void; + type: Format; + options?: ( + options: object, + transformPropName?: (name: string) => string + ) => void; } export function convert(options: ConvertOptions): Promise; export function convertSync(options: ConvertOptions): string; -export function registerFormat( - name: Format | T, - format: FormatResultFn | string +export function registerFormat( + name: Format | T, + format: FormatResultFn | string ): void; -export function registerTransform( - name: Transform | T, - valueTransforms: ValueTransform[] | T[] +export function registerTransform( + name: Transform | T, + valueTransforms: ValueTransform[] | T[] ): void; -export function registerValueTransform( - name: ValueTransform | T, - predicate: (prop: Prop) => boolean, - transform: (prop: Prop) => string | number +export function registerValueTransform( + name: ValueTransform | T, + predicate: (prop: Prop) => boolean, + transform: (prop: Prop) => string | number ): void; From a6133c9cadf5697a985fe3510a7e40d5f7c5851f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Moln=C3=A1r?= Date: Fri, 15 Feb 2019 12:49:26 +0100 Subject: [PATCH 3/8] Update index.d.ts fix(Options): fix type of preserveAspectRatio --- types/react-lottie/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-lottie/index.d.ts b/types/react-lottie/index.d.ts index a57da91307..d547396a11 100644 --- a/types/react-lottie/index.d.ts +++ b/types/react-lottie/index.d.ts @@ -21,7 +21,7 @@ export interface Options { */ animationData: any; rendererSettings?: { - preserveAspectRatio?: boolean; + preserveAspectRatio?: string; /** * The canvas context */ From ac4cae1d50f4c974b26d74f4a5a5b8e43a3c057e Mon Sep 17 00:00:00 2001 From: Pete Date: Fri, 15 Feb 2019 08:24:46 -0800 Subject: [PATCH 4/8] Bump TS to 2.3 --- types/theo/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/theo/index.d.ts b/types/theo/index.d.ts index 3735da3e0c..de15c0238a 100644 --- a/types/theo/index.d.ts +++ b/types/theo/index.d.ts @@ -1,9 +1,9 @@ -// Type definitions for theo 8.1 +// Type definitions for Theo 8.1 // Project: https://github.com/salesforce-ux/theo // Definitions by: Pete Petrash // Niko Laitinen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { Collection, Map, List, OrderedMap } from "immutable"; From f3e63b2691452497c99b213e84e20eb43803f849 Mon Sep 17 00:00:00 2001 From: Pete Date: Fri, 15 Feb 2019 10:57:30 -0800 Subject: [PATCH 5/8] Disable 'no-unnecessary-generics' rule --- types/theo/tslint.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/types/theo/tslint.json b/types/theo/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/theo/tslint.json +++ b/types/theo/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} From 4059f8e4f9417d51a161b1c3d5887ccca9d3d2ab Mon Sep 17 00:00:00 2001 From: Adam Vigneaux Date: Fri, 15 Feb 2019 13:44:08 -0500 Subject: [PATCH 6/8] Update jsoneditor types to match version 5.28.2 --- types/jsoneditor/index.d.ts | 177 ++++++++++++++++++++++++--- types/jsoneditor/jsoneditor-tests.ts | 10 +- types/jsoneditor/package.json | 6 + 3 files changed, 173 insertions(+), 20 deletions(-) create mode 100644 types/jsoneditor/package.json diff --git a/types/jsoneditor/index.d.ts b/types/jsoneditor/index.d.ts index f095cb8434..3c74a3d789 100644 --- a/types/jsoneditor/index.d.ts +++ b/types/jsoneditor/index.d.ts @@ -1,54 +1,199 @@ -// Type definitions for jsoneditor v5.19.0 +// Type definitions for jsoneditor v5.28.2 // Project: https://github.com/josdejong/jsoneditor // Definitions by: Alejandro Sánchez // Errietta Kostala +// Adam Vigneaux // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// +import { Ajv } from "ajv"; + declare module 'jsoneditor' { - export interface JSONEditorNode { + type JSONPath = (string|number)[]; + + export interface Node { field: string; - value: string; - path: Array; + value?: string; + path: JSONPath; } export type JSONEditorMode = 'tree' | 'view' | 'form' | 'code' | 'text'; + export interface NodeName { + path: string; + type: 'object'|'array'; + size: number; + } + + export interface ValidationError { + path: JSONPath; + message: string; + } + + export interface Template { + text: string; + title: string; + className?: string; + field: string; + value: any; + } + + export type AutoCompleteCompletion = null|string[]|{startFrom: number, options: string[]}; + + export type AutoCompleteOptionsGetter = ( + text: string, path: JSONPath, input: string, editor: JSONEditor, + ) => AutoCompleteCompletion|Promise; + + export interface AutoCompleteOptions { + /** + * @default [39, 35, 9] + */ + confirmKeys?: number[]; + caseSensitive?: boolean; + getOptions?: AutoCompleteOptionsGetter; + } + + export interface SelectionPosition { + row: number; + column: number; + } + + export interface SerializableNode { + value: any; + path: JSONPath; + } + + // Based on the API of https://github.com/Sphinxxxx/vanilla-picker + export interface Color { + rgba: Array; + hsla: Array; + rgbString: string; + rgbaString: string; + hslString: string; + hslaString: string; + hex: string; + } + export interface JSONEditorOptions { ace?: AceAjax.Ace; - ajv?: any; // Any for now, since ajv typings aren't A-Ok + ajv?: Ajv; onChange?: () => void; - onEditable?: (node: JSONEditorNode) => boolean | {field: boolean, value: boolean}; + onChangeJSON?: (json: any) => void; + onChangeText?: (jsonString: string) => void; + onEditable?: (node: Node) => boolean|{field: boolean, value: boolean}; onError?: (error: Error) => void; onModeChange?: (newMode: JSONEditorMode, oldMode: JSONEditorMode) => void; + onNodeName?: (nodeName: NodeName) => string|undefined; + onValidate?: (json: any) => ValidationError[]|Promise; + /** + * @default false + */ escapeUnicode?: boolean; + /** + * @default false + */ sortObjectKeys?: boolean; + /** + * @default true + */ history?: boolean; + /** + * @default 'tree' + */ mode?: JSONEditorMode; - modes?: Array; + modes?: JSONEditorMode[]; + /** + * @default undefined + */ name?: string; - schema?: Object; - schemaRefs?: Object; + schema?: object; + schemaRefs?: object; + /** + * @default true + */ search?: boolean; + /** + * @default 2 + */ indentation?: number; theme?: string; + templates?: Template[]; + autocomplete?: AutoCompleteOptions; + /** + * @default true + */ + mainMenuBar?: boolean; + /** + * @default true + */ + navigationBar?: boolean; + /** + * @default true + */ + statusBar?: boolean; + onTextSelectionChange?: (start: SelectionPosition, end: SelectionPosition, text: string) => void; + onSelectionChange?: (start: SerializableNode, end: SerializableNode) => void; + onEvent?: (node: Node, event: string) => void; + /** + * @default true + */ + colorPicker?: boolean; + onColorPicker?: (parent: HTMLElement, color: string, onChange: (color: Color) => void) => void; + /** + * @default true + */ + timestampTag?: boolean; + language?: string; + languages?: { + [lang: string]: { + [key: string]: string; + }; + }; + modalAnchor?: HTMLElement; + /** + * @default true + */ + enableSort?: boolean; + /** + * @default true + */ + enableTransform?: boolean; + /** + * @default 100 + */ + maxVisibleChilds?: number; + } export default class JSONEditor { - constructor(container: HTMLElement, options?: JSONEditorOptions, json?: Object); + constructor(container: HTMLElement, options?: JSONEditorOptions, json?: any); collapseAll(): void; destroy(): void; expandAll(): void; focus(): void; - set(json: Object): void; - setMode(mode: JSONEditorMode): void; - setName(name?: string): void; - setSchema(schema: Object): void; - setText(jsonString: string): void; get(): any; getMode(): JSONEditorMode; - getName(): string; + getName(): string|undefined; + getNodesByRange(start: {path: JSONPath}, end: {path: JSONPath}): Array; + getSelection(): {start: SerializableNode, end: SerializableNode}; getText(): string; + getTextSelection(): {start: SelectionPosition, end: SelectionPosition, text: string}; + refresh(): void; + set(json: any): void; + setMode(mode: JSONEditorMode): void; + setName(name?: string): void; + setSchema(schema: object, schemaRefs?: object): void; + setSelection(start: {path: JSONPath}, end: {path: JSONPath}): void; + setText(jsonString: string): void; + setTextSelection(start: SelectionPosition, end: SelectionPosition): void; + update(json: any): void; + updateText(jsonString: string): void; + + static VALID_OPTIONS: Array; + static ace: AceAjax.Ace; + static Ajv: Ajv; + static VanillaPicker: any; } } diff --git a/types/jsoneditor/jsoneditor-tests.ts b/types/jsoneditor/jsoneditor-tests.ts index d905e6ba76..b584a14416 100644 --- a/types/jsoneditor/jsoneditor-tests.ts +++ b/types/jsoneditor/jsoneditor-tests.ts @@ -1,11 +1,13 @@ -import JSONEditor, {JSONEditorMode, JSONEditorNode, JSONEditorOptions } from 'jsoneditor'; +import * as Ajv from 'ajv'; +import JSONEditor, {JSONEditorMode, Node, JSONEditorOptions } from 'jsoneditor'; let options: JSONEditorOptions; +options = {}; options = { ace: ace, - //ajv: Ajv({allErrors: true, verbose: true}) + ajv: new Ajv({allErrors: true, verbose: true}), onChange() {}, - onEditable(node: JSONEditorNode) { + onEditable(node: Node) { return true; }, onError(error: Error) {}, @@ -23,7 +25,7 @@ options = { theme: 'default' }; options = { - onEditable(node: JSONEditorNode) { + onEditable(node: Node) { return {field: true, value: false}; } }; diff --git a/types/jsoneditor/package.json b/types/jsoneditor/package.json new file mode 100644 index 0000000000..b47ef67b0a --- /dev/null +++ b/types/jsoneditor/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "ajv": "*" + } +} From 2cc88d04eecc2dd35f7b6d16d12cf1a8ebee36f4 Mon Sep 17 00:00:00 2001 From: Aaron Rosen Date: Fri, 15 Feb 2019 14:50:46 -0500 Subject: [PATCH 7/8] ReactNavigation: Exposes NavigationContext type. --- types/react-navigation/index.d.ts | 5 ++++- types/react-navigation/react-navigation-tests.tsx | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index df678c4ed9..860d54523e 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -31,6 +31,7 @@ // Fellipe Chagas // Deniss Borisovs // Kenneth Skovhus +// Aaron Rosen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -623,7 +624,7 @@ export interface NavigationEventSubscription { } export interface NavigationEventsProps extends ViewProps { - navigation?: NavigationNavigator; + navigation?: NavigationScreenProp; onWillFocus?: NavigationEventCallback; onDidFocus?: NavigationEventCallback; onWillBlur?: NavigationEventCallback; @@ -1367,3 +1368,5 @@ export interface SafeAreaViewProps extends ViewProps { } export const SafeAreaView: React.ComponentClass; + +export const NavigationContext: React.Context>; diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index d30714fadb..777a8fa9f3 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -42,6 +42,7 @@ import { HeaderBackButton, Header, NavigationContainer, + NavigationContext, NavigationParams, NavigationPopAction, NavigationPopToTopAction, @@ -681,3 +682,14 @@ const ViewWithNavigationEvents = ( onDidBlur={console.log} /> ); + +// Test NavigationContext +const componentWithNavigationContext = ( + + { + navigationContext => ( + + ) + } + +); From 0c02ca4f738975b2d1d28965d593083e4c9ecc61 Mon Sep 17 00:00:00 2001 From: Ting-Wai To Date: Sun, 17 Feb 2019 01:13:42 -0800 Subject: [PATCH 8/8] [ioredis] Add xadd definitions to support MAXLEN argument --- types/ioredis/index.d.ts | 2 ++ types/ioredis/ioredis-tests.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/types/ioredis/index.d.ts b/types/ioredis/index.d.ts index d5f829c8fe..743c3c061a 100644 --- a/types/ioredis/index.d.ts +++ b/types/ioredis/index.d.ts @@ -489,6 +489,8 @@ declare namespace IORedis { xack(key: KeyType, group: string, ...ids: string[]): any; xadd(key: KeyType, id: string, ...args: string[]): any; + xadd(key: KeyType, maxLenOption: 'MAXLEN' | 'maxlen', count: number, ...args: string[]): any; + xadd(key: KeyType, maxLenOption: 'MAXLEN' | 'maxlen', approximate: '~', count: number, ...args: string[]): any; xclaim(key: KeyType, group: string, consumer: string, minIdleTime: number, ...args: any[]): any; diff --git a/types/ioredis/ioredis-tests.ts b/types/ioredis/ioredis-tests.ts index 9950a8543f..89e4120f0e 100644 --- a/types/ioredis/ioredis-tests.ts +++ b/types/ioredis/ioredis-tests.ts @@ -177,6 +177,8 @@ new Redis.Cluster([{ redis.xack('streamName', 'groupName', 'id'); redis.xadd('streamName', '*', 'field', 'name'); +redis.xadd('streamName', 'MAXLEN', 100, '*', 'field', 'name'); +redis.xadd('streamName', 'MAXLEN', '~', 100, '*', 'field', 'name'); redis.xclaim('streamName', 'groupName', 'consumerName', 3600000, 'id'); redis.xdel('streamName', 'id'); redis.xgroup('CREATE', 'streamName', 'groupName', '$');