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

[Icon] fix return type of render() #3190

Merged
merged 1 commit into from
Dec 3, 2018
Merged
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
4 changes: 2 additions & 2 deletions packages/core/src/components/icon/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export class Icon extends React.PureComponent<IIconProps & React.DOMAttributes<H
public static readonly SIZE_STANDARD = 16;
public static readonly SIZE_LARGE = 20;

public render() {
public render(): JSX.Element | null {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like this should be caught by a test? there's some react 15 testing set up here right?

also how does this actually fix the problem? why is Icon#render inferred as MaybeElement in the first place...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

typeof icon !== "string" includes booleans, which are not valid return values from render().

we do have a react 15 setup but karma doesn't actually fail on compile errors (codymikol/karma-webpack#66)

const { icon } = this.props;
if (icon == null) {
if (icon == null || typeof icon === "boolean") {
return null;
} else if (typeof icon !== "string") {
return icon;
Expand Down