From 8e264ca2522d8f606c2cd840df5928d886f37c4b Mon Sep 17 00:00:00 2001 From: jthornca <48975873+jthornca@users.noreply.github.com> Date: Fri, 3 Apr 2020 10:15:43 -0700 Subject: [PATCH] =?UTF-8?q?Update=20react-tagsinput=20Type=20Mappings=20to?= =?UTF-8?q?=20use=20Generics=20instead=20of=20=E2=80=A6=20(#43586)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update react-tagsinput Type Mappings to use Generics instead of for tag types. * Update react-tagsinput Generic Support to better handle backward compatibility. Added support to `keyof` Generic type for tagDisplayProp. --- types/react-tagsinput/index.d.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/types/react-tagsinput/index.d.ts b/types/react-tagsinput/index.d.ts index 945d207475..b9f0de64e0 100644 --- a/types/react-tagsinput/index.d.ts +++ b/types/react-tagsinput/index.d.ts @@ -10,9 +10,7 @@ import * as React from "react"; export as namespace ReactTagsInput; export = TagsInput; -type Tag = any; - -declare class TagsInput extends React.Component { +declare class TagsInput extends React.Component> { accept(): any; addTag(tag: Tag): any; blur(): void; @@ -22,10 +20,10 @@ declare class TagsInput extends React.Component { declare namespace TagsInput { interface InputProps { - readonly [prop: string]: any; + readonly [prop: string]: any; } - interface RenderInputProps extends InputProps { + interface RenderInputProps extends InputProps { readonly addTag: (tag: Tag) => void; readonly onChange: (e: React.ChangeEvent<{ readonly value: string }>) => void; readonly ref: (r: any) => void; // parameter is either a DOM element or a mounted React component @@ -36,7 +34,7 @@ declare namespace TagsInput { readonly [prop: string]: any; } - interface RenderTagProps extends TagProps { + interface RenderTagProps extends TagProps { readonly disabled: boolean; readonly getTagDisplayValue: (tag: Tag) => string; readonly onRemove: (tagIndex: number) => void; @@ -45,7 +43,7 @@ declare namespace TagsInput { type RenderLayout = (tagElements: React.ReactElement[], inputElement: React.ReactElement) => React.ReactChild; - interface ReactTagsInputProps extends React.Props { + interface ReactTagsInputProps extends React.Props> { value: Tag[]; onChange: (tags: Tag[], changed: Tag[], changedIndexes: number[]) => void; onChangeInput?: (value: string) => void; @@ -65,9 +63,9 @@ declare namespace TagsInput { focusedClassName?: string; tagProps?: TagProps; inputProps?: InputProps; - tagDisplayProp?: string | null; - renderTag?: (props: RenderTagProps) => React.ReactNode; - renderInput?: (props: RenderInputProps) => React.ReactNode; + tagDisplayProp?: keyof Tag | string | null; + renderTag?: (props: RenderTagProps) => React.ReactNode; + renderInput?: (props: RenderInputProps) => React.ReactNode; renderLayout?: RenderLayout; preventSubmit?: boolean; }