FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add type safety to default props by jschuler · Pull Request #3536 · patternfly/patternfly-react · GitHub

add type safety to default props - #3536

Merged
redallen merged 1 commit into
patternfly:masterfrom
jschuler:gen_snapshots_only_ts_changes
Jan 21, 2020
Merged

add type safety to default props#3536
redallen merged 1 commit into
patternfly:masterfrom
jschuler:gen_snapshots_only_ts_changes

Conversation

Copy link
Copy Markdown
Contributor

What: Closes #3535

ariaDescribedBy = `pf-about-modal-content-${this.id}`;

static defaultProps = {
static defaultProps: PickOptional<AboutModalProps> = {

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why can't we do static defaultProps = { ... } as AboutModalProps?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You probably can, but if one of the types was wrong, for example if you defaulted isOpen to a string isOpen: 'false' the TS error/warning would not be as clear

Copy link
Copy Markdown
Collaborator

PatternFly-React preview: https://patternfly-react-pr-3536.surge.sh

codecov-io commented Jan 21, 2020
edited
Loading

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@0fb0a43). Click here to learn what that means.
The diff coverage is 86.11%.

@@            Coverage Diff            @@
##             master    #3536   +/-   ##
=========================================
  Coverage          ?   67.09%           
=========================================
  Files             ?      903           
  Lines             ?    25478           
  Branches          ?     2259           
=========================================
  Hits              ?    17095           
  Misses            ?     7341           
  Partials          ?     1042
Flag Coverage Δ
#misc 95.45% <ø> (?)
#patternfly3 69.29% <ø> (?)
#patternfly4 64.2% <86.11%> (?)
Impacted Files Coverage Δ
...patternfly-4/react-core/src/components/Nav/Nav.tsx 76.59% <ø> (ø)
...ernfly-4/react-core/src/components/Title/Title.tsx 94.11% <ø> (ø)
.../react-core/src/components/Wizard/WizardToggle.tsx 58.06% <ø> (ø)
...core/src/components/Dropdown/DropdownSeparator.tsx 90.9% <ø> (ø)
...-4/react-core/src/components/Dropdown/Dropdown.tsx 100% <ø> (ø)
...act-core/src/components/Popover/PopoverContent.tsx 50% <0%> (ø)
...ernfly-4/react-core/src/components/Brand/Brand.tsx 66.66% <0%> (ø)
...core/src/components/Popover/PopoverCloseButton.tsx 57.14% <0%> (ø)
...eact-core/src/components/Popover/PopoverFooter.tsx 75% <0%> (ø)
...-4/react-core/src/components/Wizard/WizardBody.tsx 60% <0%> (ø)
... and 59 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0fb0a43...1dd82e7. Read the comment docs.

isDisabled: false,
isValid: true,
onChange: Function.prototype
onChange: () => {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Must callback functions return an object or do we really want () => void?

There are a bunch of these throughout the PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is not the type definition but just a default value which is a stand in for any function, e.g.

(something) => {
  // function body
}

The actual type is onChange?: (checked: boolean, event: React.FormEvent<HTMLInputElement>) => void;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sorry, missed that

redallen left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks @jschuler !

redallen merged commit 464a8eb into patternfly:master Jan 21, 2020

Copy link
Copy Markdown
Collaborator

Your changes have been released in:

  • @patternfly/react-catalog-view-extension@1.1.80
  • @patternfly/react-core@3.131.3
  • @patternfly/react-docs@4.16.98
  • @patternfly/react-inline-edit-extension@2.14.40
  • demo-app-ts@3.17.14
  • @patternfly/react-table@2.24.83
  • @patternfly/react-topology@2.11.67
  • @patternfly/react-virtualized-extension@1.3.81

Thanks for your contribution! 🎉

This file contains hidden or 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
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.

Add type safety to default props

6 participants


Back | FazBrowse Home | New Git URL