-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first pass of typescript types for everything (#3411)
Welp, that took longer than I was expecting! I think I've got a reasonable set of prop types for each module, but i got a bit tired of detailed checking towards the end. I'm not sure whether the polymorphic `as` behaviour actually works correctly - although in theory the types I've got there should handle it. Because of the generated types for the final component props, the error messages can be a bit wordy - but they do seem to also include the important information as well. I've added dtslint into the build, but unfortunately this only checks the types against the `simple.test.tsx` file, it doesn't check the types against the actual implementation in any way. Another mild annoyance is that although i've matched up the component filenames, the types don't work for the individual component files because of the `lib` vs `src` vs `es` part of the build process. In theory the files could be duplicated during the build for the exported code if this is desired.
- Loading branch information
Showing
140 changed files
with
1,956 additions
and
1,960 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!lib/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,5 @@ | ||
# NOTE | ||
This is mainly the v0.32 typings with a few updates for v1. The level of v1 compliance will improve over time. | ||
|
||
Below is a list of components that have started to be updated/checked and (at least to some extent) to work: | ||
This is mainly the v0.32 typings with simple updates for v1. | ||
|
||
* Container (renamed from Grid) | ||
* Col | ||
* Row | ||
* Dropdown (inc .Toggle .Menu, .Item) | ||
* NavDropdown (inc. Item) | ||
* Navbar (inc .Brand .Toggle .Collapse) | ||
* ButtonGroup | ||
* Button | ||
|
||
Many other v0.32 definitions may work for you 'out of the box' or with minor edits. | ||
|
||
The readme.md for v0.32 follows. | ||
|
||
# Installation | ||
> `npm install --save @types/react-bootstrap` | ||
# Summary | ||
This package contains type definitions for react-bootstrap (https://github.com/react-bootstrap/react-bootstrap). | ||
|
||
# Details | ||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-bootstrap | ||
|
||
Additional Details | ||
* Last updated: Wed, 10 Oct 2018 20:07:15 GMT | ||
* Dependencies: react | ||
* Global values: none | ||
|
||
# Credits | ||
These definitions were written by Walker Burgin <https://github.com/walkerburgin>, Vincent Siao <https://github.com/vsiao>, Danilo Barros <https://github.com/danilojrr>, Batbold Gansukh <https://github.com/Batbold-Gansukh>, Raymond May Jr. <https://github.com/octatone>, Cheng Sieu Ly <https://github.com/chengsieuly>, Mercedes Retolaza <https://github.com/mretolaza>, Kat Busch <https://github.com/katbusch>, Vito Samson <https://github.com/vitosamson>, Karol Janyst <https://github.com/LKay>, Aaron Beall <https://github.com/aaronbeall>, Johann Rakotoharisoa <https://github.com/jrakotoharisoa>, Andrew Makarov <https://github.com/r3nya>, Duong Tran <https://github.com/t49tran>. | ||
The level of v1 compliance will improve over time. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
import * as React from 'react'; | ||
import { Sizes } from 'react-bootstrap'; | ||
|
||
declare namespace Alert { | ||
export interface AlertProps extends React.HTMLProps<Alert> { | ||
bsSize?: Sizes; | ||
bsStyle?: string; | ||
closeLabel?: string; | ||
/** @deprecated since v0.29.0 */dismissAfter?: number; | ||
// TODO: Add more specific type | ||
onDismiss?: Function; | ||
} | ||
|
||
import SafeAnchor from './SafeAnchor'; | ||
|
||
import { BsPrefixComponent } from './helpers'; | ||
|
||
declare class AlertLink< | ||
As extends React.ReactType = typeof SafeAnchor | ||
> extends BsPrefixComponent<As> {} | ||
|
||
declare class AlertHeading< | ||
As extends React.ReactType = 'div' | ||
> extends BsPrefixComponent<As> {} | ||
|
||
interface AlertProps extends React.HTMLProps<Alert> { | ||
bsPrefix?: string; | ||
variant?: | ||
| 'primary' | ||
| 'secondary' | ||
| 'success' | ||
| 'danger' | ||
| 'warning' | ||
| 'info' | ||
| 'dark' | ||
| 'light'; | ||
dismissible?: boolean; | ||
show?: boolean; | ||
onClose?: () => void; | ||
closeLabel?: string; | ||
transition?: React.ReactType; | ||
} | ||
|
||
declare class Alert extends React.Component<AlertProps> { | ||
static Link: typeof AlertLink; | ||
static Heading: typeof AlertHeading; | ||
} | ||
declare class Alert extends React.Component<Alert.AlertProps> { } | ||
export = Alert; | ||
|
||
export default Alert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
import * as React from 'react'; | ||
|
||
declare namespace Badge { | ||
export interface BadgeProps extends React.HTMLProps<Badge> { | ||
bsClass?: string; | ||
pullRight?: boolean; | ||
} | ||
interface BadgeProps extends React.HTMLProps<Badge> { | ||
bsPrefix?: string; | ||
variant?: | ||
| 'primary' | ||
| 'secondary' | ||
| 'success' | ||
| 'danger' | ||
| 'warning' | ||
| 'info' | ||
| 'light' | ||
| 'dark'; | ||
pill?: boolean; | ||
} | ||
declare class Badge extends React.Component<Badge.BadgeProps> { } | ||
export = Badge; | ||
|
||
declare class Badge extends React.Component<BadgeProps> {} | ||
|
||
export default Badge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import * as React from 'react'; | ||
import * as BreadcrumbItem from './BreadcrumbItem'; | ||
|
||
declare namespace Breadcrumb { | ||
interface BreadcrumbProps extends React.HTMLProps<Breadcrumb> { | ||
bsClass?: string; | ||
} | ||
import { default as BreadcrumbItem } from './BreadcrumbItem'; | ||
|
||
import { BsPrefixComponent } from './helpers'; | ||
|
||
interface BreadcrumbProps { | ||
label?: string; | ||
listProps?: React.OlHTMLAttributes<any>; | ||
} | ||
declare class Breadcrumb extends React.Component<Breadcrumb.BreadcrumbProps> { | ||
public static Item: typeof BreadcrumbItem; | ||
|
||
declare class Breadcrumb< | ||
As extends React.ReactType = 'nav' | ||
> extends BsPrefixComponent<As, BreadcrumbProps> { | ||
static Item: typeof BreadcrumbItem; | ||
} | ||
export = Breadcrumb; | ||
|
||
export default Breadcrumb; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import * as React from 'react'; | ||
|
||
declare namespace BreadcrumbItem { | ||
export interface BreadcrumbItemProps extends React.Props<BreadcrumbItem> { | ||
active?: boolean; | ||
href?: string; | ||
title?: React.ReactNode; | ||
target?: string; | ||
} | ||
import { BsPrefixComponent } from './helpers'; | ||
|
||
interface BreadcrumbItemProps { | ||
active?: boolean; | ||
href?: string; | ||
target?: string; | ||
title?: React.ReactNode; | ||
} | ||
declare class BreadcrumbItem extends React.Component<BreadcrumbItem.BreadcrumbItemProps> { } | ||
export = BreadcrumbItem; | ||
|
||
declare class BreadcrumbItem< | ||
As extends React.ReactType = 'li' | ||
> extends BsPrefixComponent<As, BreadcrumbItemProps> {} | ||
|
||
export default BreadcrumbItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
import * as React from 'react'; | ||
import { Sizes } from 'react-bootstrap'; | ||
|
||
declare namespace Button { | ||
export interface ButtonProps extends React.HTMLProps<Button> { | ||
bsClass?: string; | ||
active?: boolean; | ||
block?: boolean; | ||
bsStyle?: string | null; | ||
bsSize?: Sizes; | ||
componentClass?: React.ReactType; | ||
disabled?: boolean; | ||
} | ||
import { BsPrefixComponent } from './helpers'; | ||
|
||
interface ButtonProps { | ||
active?: boolean; | ||
block?: boolean; | ||
variant?: | ||
| 'primary' | ||
| 'secondary' | ||
| 'success' | ||
| 'danger' | ||
| 'warning' | ||
| 'info' | ||
| 'dark' | ||
| 'light' | ||
| 'link' | ||
| 'outline-primary' | ||
| 'outline-secondary' | ||
| 'outline-success' | ||
| 'outline-danger' | ||
| 'outline-warning' | ||
| 'outline-info' | ||
| 'outline-dark' | ||
| 'outline-light'; | ||
size?: 'sm' | 'lg'; | ||
type?: 'button' | 'reset' | 'submit'; | ||
href?: string; | ||
disabled?: boolean; | ||
} | ||
declare class Button extends React.Component<Button.ButtonProps> { } | ||
export = Button; | ||
|
||
declare class Button< | ||
As extends React.ReactType = 'button' | ||
> extends BsPrefixComponent<As, ButtonProps> {} | ||
|
||
export default Button; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import * as React from 'react'; | ||
import { Sizes } from 'react-bootstrap'; | ||
|
||
declare namespace ButtonGroup { | ||
export interface ButtonGroupProps extends React.HTMLProps<ButtonGroup> { | ||
block?: boolean; | ||
bsSize?: Sizes; | ||
bsStyle?: string; | ||
justified?: boolean; | ||
vertical?: boolean; | ||
} | ||
|
||
import { BsPrefixComponent } from './helpers'; | ||
|
||
interface ButtonGroupProps { | ||
role?: string; | ||
size?: 'sm' | 'lg'; | ||
toggle?: boolean; | ||
vertical?: boolean; | ||
} | ||
declare class ButtonGroup extends React.Component<ButtonGroup.ButtonGroupProps> { } | ||
export = ButtonGroup; | ||
|
||
declare class ButtonGroup< | ||
As extends React.ReactType = 'div' | ||
> extends BsPrefixComponent<As, ButtonGroupProps> {} | ||
|
||
export default ButtonGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import * as React from 'react'; | ||
import { Sizes } from 'react-bootstrap'; | ||
|
||
declare namespace ButtonToolbar { | ||
export interface ButtonToolbarProps extends React.HTMLProps<ButtonToolbar> { | ||
block?: boolean; | ||
bsSize?: Sizes; | ||
bsStyle?: string; | ||
justified?: boolean; | ||
vertical?: boolean; | ||
} | ||
|
||
import { BsPrefixComponent } from './helpers'; | ||
|
||
interface ButtonToolbarProps { | ||
role?: string; | ||
} | ||
declare class ButtonToolbar extends React.Component<ButtonToolbar.ButtonToolbarProps> { } | ||
export = ButtonToolbar; | ||
|
||
declare class ButtonToolbar extends BsPrefixComponent< | ||
'div', | ||
ButtonToolbarProps | ||
> {} | ||
|
||
export default ButtonToolbar; |
Oops, something went wrong.