From d820b8efeb77bfe6fff3b50da75beeaa999d0ea6 Mon Sep 17 00:00:00 2001 From: abeall Date: Sat, 7 Oct 2017 00:34:24 -0400 Subject: [PATCH 1/3] Changed TabProps.title to ReactNode not string, per docs --- types/react-bootstrap/index.d.ts | 1 + types/react-bootstrap/lib/Tab.d.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/react-bootstrap/index.d.ts b/types/react-bootstrap/index.d.ts index dcb5998f7a..8ccff26951 100644 --- a/types/react-bootstrap/index.d.ts +++ b/types/react-bootstrap/index.d.ts @@ -9,6 +9,7 @@ // Kat Busch , // Vito Samson // Karol Janyst +// Aaron Beall // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/react-bootstrap/lib/Tab.d.ts b/types/react-bootstrap/lib/Tab.d.ts index f30264a562..1c98d8c0a3 100644 --- a/types/react-bootstrap/lib/Tab.d.ts +++ b/types/react-bootstrap/lib/Tab.d.ts @@ -1,17 +1,18 @@ import * as React from 'react'; -import { TransitionCallbacks } from 'react-bootstrap'; +import { TransitionCallbacks, Omit } from 'react-bootstrap'; import * as TabContainer from './TabContainer'; import * as TabPane from './TabPane'; import * as TabContent from './TabContent'; declare namespace Tab { - export interface TabProps extends TransitionCallbacks, React.HTMLProps { + export interface TabProps extends TransitionCallbacks, Omit, "title"> { animation?: boolean; 'aria-labelledby'?: string; bsClass?: string; eventKey?: any; // TODO: Add more specific type unmountOnExit?: boolean; tabClassName?: string; + title?: React.ReactNode; // Override HTMLProps.title to allow nodes not just strings } } declare class Tab extends React.Component { From 07f707e2eb8eac55e2f05c03445d3bae680417e9 Mon Sep 17 00:00:00 2001 From: abeall Date: Mon, 9 Oct 2017 12:12:25 -0400 Subject: [PATCH 2/3] Fixed declaration of title/label as ReactNode for components, per docs --- types/react-bootstrap/lib/DropdownButton.d.ts | 1 + types/react-bootstrap/lib/Popover.d.ts | 5 +++-- types/react-bootstrap/lib/ProgressBar.d.ts | 5 +++-- types/react-bootstrap/lib/SplitButton.d.ts | 6 ++++-- .../test/react-bootstrap-individual-components-tests.tsx | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/types/react-bootstrap/lib/DropdownButton.d.ts b/types/react-bootstrap/lib/DropdownButton.d.ts index df66dd36dd..e2626e2bb7 100644 --- a/types/react-bootstrap/lib/DropdownButton.d.ts +++ b/types/react-bootstrap/lib/DropdownButton.d.ts @@ -10,6 +10,7 @@ declare namespace DropdownButton { navItem?: boolean; noCaret?: boolean; pullRight?: boolean; + title: React.ReactNode; } export type DropdownButtonProps = DropdownButtonBaseProps & React.HTMLProps; diff --git a/types/react-bootstrap/lib/Popover.d.ts b/types/react-bootstrap/lib/Popover.d.ts index 2af51da4b6..95abc38854 100644 --- a/types/react-bootstrap/lib/Popover.d.ts +++ b/types/react-bootstrap/lib/Popover.d.ts @@ -1,8 +1,8 @@ import * as React from 'react'; -import { Sizes } from 'react-bootstrap'; +import { Sizes, Omit } from 'react-bootstrap'; declare namespace Popover { - export interface PopoverProps extends React.HTMLProps { + export interface PopoverProps extends Omit, "title"> { // Optional arrowOffsetLeft?: number | string; arrowOffsetTop?: number | string; @@ -11,6 +11,7 @@ declare namespace Popover { placement?: string; positionLeft?: number | string; // String support added since v0.30.0 positionTop?: number | string; // String support added since v0.30.0 + title?: React.ReactNode; } } declare class Popover extends React.Component { } diff --git a/types/react-bootstrap/lib/ProgressBar.d.ts b/types/react-bootstrap/lib/ProgressBar.d.ts index 89b2e07cc0..8fc408ac65 100644 --- a/types/react-bootstrap/lib/ProgressBar.d.ts +++ b/types/react-bootstrap/lib/ProgressBar.d.ts @@ -1,8 +1,8 @@ import * as React from 'react'; -import { Sizes } from 'react-bootstrap'; +import { Sizes, Omit } from 'react-bootstrap'; declare namespace ProgressBar { - export interface ProgressBarProps extends React.HTMLProps { + export interface ProgressBarProps extends Omit, "label"> { // Optional active?: boolean; bsSize?: Sizes; @@ -13,6 +13,7 @@ declare namespace ProgressBar { now?: number; srOnly?: boolean; striped?: boolean; + label?: React.ReactNode; } } declare class ProgressBar extends React.Component { } diff --git a/types/react-bootstrap/lib/SplitButton.d.ts b/types/react-bootstrap/lib/SplitButton.d.ts index 7f3d9d7f30..7b824cd647 100644 --- a/types/react-bootstrap/lib/SplitButton.d.ts +++ b/types/react-bootstrap/lib/SplitButton.d.ts @@ -1,13 +1,15 @@ import * as React from 'react'; -import { Sizes } from 'react-bootstrap'; +import { Sizes, Omit } from 'react-bootstrap'; declare namespace SplitButton { - export interface SplitButtonProps extends React.HTMLProps { + export interface SplitButtonProps extends Omit, "title"> { bsStyle?: string; bsSize?: Sizes; dropdownTitle?: any; // TODO: Add more specific type dropup?: boolean; pullRight?: boolean; + title: React.ReactNode; + id: string; } } declare class SplitButton extends React.Component { } diff --git a/types/react-bootstrap/test/react-bootstrap-individual-components-tests.tsx b/types/react-bootstrap/test/react-bootstrap-individual-components-tests.tsx index 78579dc953..ff2c5b7472 100644 --- a/types/react-bootstrap/test/react-bootstrap-individual-components-tests.tsx +++ b/types/react-bootstrap/test/react-bootstrap-individual-components-tests.tsx @@ -120,7 +120,7 @@ export class ReactBootstrapIndividualComponentsTest extends React.Component { - + @@ -178,7 +178,7 @@ export class ReactBootstrapIndividualComponentsTest extends React.Component { - + From 267157dfba5efa100329ab2a729c418db2853b6a Mon Sep 17 00:00:00 2001 From: abeall Date: Tue, 12 Dec 2017 13:16:23 -0500 Subject: [PATCH 3/3] Support for strictNullChecks --- types/react-intl/index.d.ts | 7 ++++--- types/react-intl/react-intl-tests.tsx | 15 +++++++++++---- types/react-intl/tsconfig.json | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index 8557f22cb0..7fc19e41ab 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -12,6 +12,7 @@ declare namespace ReactIntl { type DateSource = Date | string | number; + type MessageValue = string | number | boolean | Date | null | undefined; interface Locale { locale: string; @@ -69,8 +70,8 @@ declare namespace ReactIntl { formatRelative(value: DateSource, options?: FormattedRelative.PropsBase & { now?: any }): string; formatNumber(value: number, options?: FormattedNumber.PropsBase): string; formatPlural(value: number, options?: FormattedPlural.Base): keyof FormattedPlural.PropsBase; - formatMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number | boolean | Date}): string; - formatHTMLMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number | boolean | Date}): string; + formatMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: MessageValue}): string; + formatHTMLMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: MessageValue}): string; locale: string; formats: any; messages: { [id: string]: string }; @@ -138,7 +139,7 @@ declare namespace ReactIntl { } interface Props extends MessageDescriptor { - values?: {[key: string]: string | number | boolean | Date | JSX.Element}; + values?: {[key: string]: MessageValue | JSX.Element}; tagName?: string; } } diff --git a/types/react-intl/react-intl-tests.tsx b/types/react-intl/react-intl-tests.tsx index 25f1016026..726802a8bb 100644 --- a/types/react-intl/react-intl-tests.tsx +++ b/types/react-intl/react-intl-tests.tsx @@ -50,12 +50,12 @@ const SomeFunctionalComponentWithIntl: React.ComponentClass const formattedRelative = formatRelative(new Date().getTime(), { format: "short" }); const formattedNumber = formatNumber(123, { format: "short" }); const formattedPlural = formatPlural(1, { style: "ordinal" }); - const formattedMessage = formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); + const formattedMessage = formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger", nullAllowed: null, undefinedAllowed: undefined }); const formattedMessagePlurals = formatMessage({ id: "hello", - defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" }, - { name: "Roger", unreadCount: 123 }); - const formattedHTMLMessage = formatHTMLMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); + defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" + }, { name: "Roger", unreadCount: 123 }); + const formattedHTMLMessage = formatHTMLMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger", nullAllowed: null, undefinedAllowed: undefined }); return (
@@ -136,6 +136,13 @@ class SomeComponent extends React.Component + +