Skip to content

Update type react-toastr: Allow JSX to be used for title and message content.#24910

Merged
RyanCavanaugh merged 4 commits intoDefinitelyTyped:masterfrom
DanRegazzi:FixReactToastrTypeDefinition
Apr 16, 2018
Merged

Update type react-toastr: Allow JSX to be used for title and message content.#24910
RyanCavanaugh merged 4 commits intoDefinitelyTyped:masterfrom
DanRegazzi:FixReactToastrTypeDefinition

Conversation

@DanRegazzi
Copy link
Copy Markdown
Contributor

The type definition only allowed strings to be used for the toast title and message content, but react-toastr should also allow JSX elements to be used. Updated the type definition to allow 'any' type for the toast title and message content to allow for strings or JSX Elements.

If changing an existing definition:

@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Apr 11, 2018

@DanRegazzi Thank you for submitting this PR!

🔔 @shssoichiro - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

info: (message: string, title: string, optionsOverride?: {}) => void;
success: (message: string, title: string, optionsOverride?: {}) => void;
warning: (message: string, title: string, optionsOverride?: {}) => void;
error: (message: any, title: any, optionsOverride?: any) => void;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the intent is a React element, you should use React.ReactNode instead of any.

Is there a reason optionsOverride was changed from a generic object to any?

@@ -1,6 +1,6 @@
// Type definitions for react-toastr 3.0
// Type definitions for react-toastr 3.1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the intent is for this version number to be react-toastr's version number, which is still 3.0.0. Someone who maintains DefinitelyTyped can confirm.

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Apr 11, 2018
@typescript-bot
Copy link
Copy Markdown
Contributor

@DanRegazzi One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you!

Change toast notify functions to use string or ReactNode types explicitly
Revert change to options override type
@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Apr 13, 2018
@typescript-bot
Copy link
Copy Markdown
Contributor

🔔 @shssoichiro - Thanks for your review of this PR! Can you please look at the new code and update your review status if appropriate?

info: (message: string, title: string, optionsOverride?: {}) => void;
success: (message: string, title: string, optionsOverride?: {}) => void;
warning: (message: string, title: string, optionsOverride?: {}) => void;
error: (message: string | React.ReactNode, title: string | React.ReactNode, optionsOverride?: {}) => void;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ReactNode includes string, so you only need so specify ReactNode.

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L148

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Apr 13, 2018
@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Apr 13, 2018
@typescript-bot
Copy link
Copy Markdown
Contributor

A definition author has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped!

@RyanCavanaugh RyanCavanaugh merged commit 9de8070 into DefinitelyTyped:master Apr 16, 2018
@RyanCavanaugh
Copy link
Copy Markdown
Member

🌟 🎈 🎉 🏆 🎂 ✨ ⭐️

Congratulations on your first DefinitelyTyped contribution!

🌟 🎈 🎉 🏆 🎂 ✨ ⭐️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants