Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for const/type pairs as enums #66

Merged
merged 6 commits into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/__tests__/__fixtures__/enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2018-present Palantir Techologies.
*
* This file contains dummy code for testing the typescript plugin.
*/

/** classic typescript enum */
export enum Intent {
PRIMARY = "primary",
SUCCESS = "success",
WARNING = "warning",
DANGER = "danger",
}

/** const/type pair: enum & string literals */
export const IconName = {
ADD: "add" as "add",
REMOVE: "remove" as "remove",
// tslint:disable-next-line:object-literal-sort-keys
PLUS: "plus" as "plus",
MINUS: "minus" as "minus",
};
export type IconName = "add" | "remove" | "plus" | "minus";

/** plain old object literal, *not* an enum */
export const Literal = {
LEFT: "left",
RIGHT: "right",
};
9 changes: 0 additions & 9 deletions src/__tests__/__fixtures__/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
* This file contains dummy code for testing the typescript plugin.
*/

export enum Intent {
Primary,
Success,
Warning,
Danger,
}
export type IconName = "add" | "remove" | "plus" | "minus";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You move the test for the Intent enum to enums.ts but you left this unioned string type here and duplicated it in enums.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i moved all the enums to a separate test but i left just the union here so we're testing a non-basic type


export interface IActionProps {
Expand All @@ -19,9 +13,6 @@ export interface IActionProps {
/** Name of the icon (the part after `pt-icon-`) to add to the button. */
iconName?: IconName;

/** Visual intent color to apply to element. */
intent: Intent;

/** Click event handler. */
onClick: (event: MouseEvent) => void;

Expand Down
Loading