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

Various small code fixes / type fixes #3313

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

bradenmacdonald
Copy link
Contributor

@bradenmacdonald bradenmacdonald commented Dec 3, 2024

Description

I created a script to run TypeScript type checking on all the MDX code examples in the docs, and it found these small issues. I will add inline comments to explain where helpful.

Deploy Preview

https://deploy-preview-3313--paragon-openedx.netlify.app/

Merge Checklist

n/a - no changes to how any of the Paragon components actually work or look.

Post-merge Checklist

  • Verify your changes were released to NPM at the expected version.
  • If you'd like, share your contribution in #show-and-tell.
  • 🎉 🙌 Celebrate! Thanks for your contribution.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Dec 3, 2024
@openedx-webhooks
Copy link

Thanks for the pull request, @bradenmacdonald!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/paragon-working-group. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Copy link

netlify bot commented Dec 3, 2024

Deploy Preview for paragon-openedx ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f940bd8
🔍 Latest deploy log https://app.netlify.com/sites/paragon-openedx/deploys/67548206f7d8fe0008f28e3a
😎 Deploy Preview https://deploy-preview-3313--paragon-openedx.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -145,7 +145,7 @@ You can use `Dropdown.Toggle` with [IconButton](/components/iconbutton) componen
```jsx live
<Dropdown.Deprecated>
<Dropdown.Deprecated.Button>
<Icon className="fa fa-user pr-3" alt="" />
<Icon className="fa fa-user pr-3" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

<Icon> does not accept an alt prop. It accepts an optional screenReaderText but it can be omitted for decorative icons, to emulate alt=""

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

@@ -36,6 +36,8 @@ interface Props extends React.HTMLAttributes<HTMLButtonElement> {
variant?: 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'light' | 'dark' | 'black' | 'brand';
/** size of button to render */
size?: 'sm' | 'md' | 'inline';
/** Used with `IconButtonToggle` */
value?: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you can see in the docs, <IconButtonToggle> requires its <IconButton> children to accept a value prop, but that wasn't defined in the prop types.

Fixed a type error:

Property 'value' does not exist on type 'IntrinsicAttributes & Pick<Pick<PropsWithTooltip, "variant" | "className" | "children" | "slot" | "style" | "title" | "size" | "defaultChecked" | ... 260 more ... | "tooltipContent"> & Pick<...> & Pick<...>, "tooltipContent"> & Partial<...> & Partial<...>'.

@@ -31,7 +31,7 @@ The standard `ModalDialog` composition. `StandardModal` passes all of its props
footerNode={(
<ActionRow>
<p className="small">
<Hyperlink href="#">Get help</Hyperlink>
<Hyperlink destination="#">Get help</Hyperlink>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although this was working, the <Hyperlink> component expects destination as a prop, not href.

@@ -36,7 +36,7 @@ export const isEveryPropDefined = (props, otherPropNames) => otherPropNames
* Returns a PropType entry with the given propType that is required if otherPropName
* is truthy.
* @param {func} propType - target PropType
* @param {string} otherPropName - string name for prop that, if true, marks the
* @param {string | string[]} otherPropName - string name for prop that, if true, marks the
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you can see in the implementation below as well as how this function is used, this param accepts a string array.

@@ -105,7 +105,7 @@ class ListBoxWrapperForOnSelect extends React.Component {
<span className="sr-only">none</span>
) : (
<span
arialabelledby={`list-box-option-${
aria-labelledby={`list-box-option-${
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Property 'arialabelledby' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>'. Did you mean '"aria-labelledby"'?

isValid: false,
validationMessage: 'Please make a selection.',
};
}
return feedback;
return { isValid: true };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change (A) simplifies the validator function, making it a bit more clear, and (B) helps TypeScript avoid a type inference mistake: Object literal may only specify known properties, and 'validationMessage' does not exist in type '{ isValid: boolean; }'.

const [value, setValue] = useState('');

const handleChange = (e) => setValue(e.target.value);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes: Block-scoped variable 'value' used before its declaration.

@@ -253,7 +253,7 @@ To enable proper selection behavior with backend pagination (i.e., when ``isSele
</Component>
);

const ClearAction = ({ as: Component, tableInstance, ...rest }) => (
const ClearAction = ({ as: Component, tableInstance }) => (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rest parameter was unused.

Fixes: 'rest' is declared but its value is never read.

.slice(0, numParagraphs)
.map(text => <p key={text}>{text}</p>);
.map(text => <p key={text}>{text}</p>)}</>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes:

'HipsterIpsum' cannot be used as a JSX component.
  Its return type 'Element[]' is not a valid JSX element.

@bradenmacdonald bradenmacdonald added the documentation Relates to documentation improvements label Dec 3, 2024
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.31%. Comparing base (bf583b1) to head (f940bd8).
Report is 8 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3313   +/-   ##
=======================================
  Coverage   93.31%   93.31%           
=======================================
  Files         249      249           
  Lines        4441     4441           
  Branches     1014     1014           
=======================================
  Hits         4144     4144           
  Misses        294      294           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

Overall this is looking great. I'm not sure what's going on with the linting errors in HipsterIpsum (specifically why they're showing up as annotations on the diff but not failing the lint check)

Other than that this LGTM!

@bradenmacdonald bradenmacdonald force-pushed the braden/small-type-fixes branch from 4567bd6 to f940bd8 Compare December 7, 2024 17:12
@bradenmacdonald
Copy link
Contributor Author

Weird. Yeah, I didn't even notice that check failure because of how it was showing up. Thanks for spotting it. I've rebased this and fixed the lint issues in HipsterIpsum.

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

Thanks for clearing up the lint errors! This LGTM! :shipit:

@bradenmacdonald bradenmacdonald merged commit 9526409 into openedx:master Dec 9, 2024
10 checks passed
@bradenmacdonald bradenmacdonald deleted the braden/small-type-fixes branch December 9, 2024 17:37
@openedx-semantic-release-bot

🎉 This PR is included in version 22.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@openedx-semantic-release-bot

🎉 This PR is included in version 23.0.0-alpha.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Relates to documentation improvements open-source-contribution PR author is not from Axim or 2U released on @alpha released
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants