Skip to content

Commit

Permalink
[antd_v3.x.x] Updates enum for "type" in Button (to support new "link…
Browse files Browse the repository at this point in the history
…" type) (#3658)
  • Loading branch information
madsnedergaard authored and pascalduez committed Dec 7, 2019
1 parent acee24a commit 97c2f19
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions definitions/npm/antd_v3.x.x/flow_v0.104.x-/antd_v3.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ declare module "antd" {
shape?: 'circle' | 'round',
size?: 'small' | 'large',
target?: string,
type?: 'primary' | 'ghost' | 'dashed' | 'danger' | 'default',
type?: 'primary' | 'ghost' | 'dashed' | 'danger' | 'link' | 'default',
onClick?: (event: SyntheticEvent<HTMLButtonElement>) => void,
block?: boolean,
...
Expand Down Expand Up @@ -342,7 +342,7 @@ declare module "antd" {
declare class InputTextArea extends React$Component<{...}> {}

declare type InputPasswordProps = { visibilityToggle?: boolean, ... };

// Added in 3.12.0
declare class InputPassword extends React$Component<InputPasswordProps> {}

Expand Down Expand Up @@ -502,7 +502,7 @@ declare module "antd" {
declare class RadioButton extends React$Component<{...}> {}

declare export class Row extends React$Component<{...}> {}

declare export type SelectValue = string | string[] | number | number[];

declare export type SelectProps<T = SelectValue> = {
Expand Down
20 changes: 17 additions & 3 deletions definitions/npm/antd_v3.x.x/flow_v0.104.x-/test_antd_v3.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,24 @@ describe("Button", () => {
const button = <Button />;
});
it("should accept nullary or unary onClick handler", () => {
const good0 = <Button onClick={() => undefined} />
const good1 = <Button onClick={(event: SyntheticEvent<HTMLButtonElement>) => undefined} />
const good0 = <Button onClick={() => undefined} />;
const good1 = (
<Button
onClick={(event: SyntheticEvent<HTMLButtonElement>) => undefined}
/>
);
// $ExpectError
const bad = <Button onClick="bad" />;
});
it("should accept only certain strings for type prop", () => {
const good0 = <Button type="primary" />;
const good1 = <Button type="ghost" />;
const good2 = <Button type="dashed" />;
const good3 = <Button type="danger" />;
const good5 = <Button type="link" />;
const good4 = <Button type="default" />;
// $ExpectError
const bad = <Button onClick='bad' />
const bad = <Button type="bad" />;
});
});

Expand Down

0 comments on commit 97c2f19

Please sign in to comment.