Skip to content

fix(ts): mark default modal props as optional#5037

Merged
chasestarr merged 3 commits intomasterfrom
modal-optional-props
Jul 19, 2022
Merged

fix(ts): mark default modal props as optional#5037
chasestarr merged 3 commits intomasterfrom
modal-optional-props

Conversation

@chasestarr
Copy link
Collaborator

Description

Seeing errors like below. I'm not sure why this kind of error does not raise when running tsc in baseui repo?

  | 2022-07-15 16:57:26 PDT | ....tsx:11:8 - error TS2740: Type '{ children: Element; onClose: () => any; isOpen: true; }' is missing the following properties from type 'ModalProps': animate, autoFocus, closeable, overrides, and 2 more.
  | 2022-07-15 16:57:35 PDT |  
  | 2022-07-15 16:57:35 PDT | 11       <Modal onClose={() => null} isOpen={true}>
  | 2022-07-15 16:57:35 PDT | ~~~~~
  | 2022-07-15 16:57:35 PDT |  
  | 2022-07-15 16:57:35 PDT | ....tsx:34:6 - error TS2740: Type '{ children: Element; onClose: () => void; isOpen: boolean; }' is missing the following properties from type 'ModalProps': animate, autoFocus, closeable, overrides, and 2 more.
  | 2022-07-15 16:57:35 PDT |  
  | 2022-07-15 16:57:35 PDT | 34     <Modal onClose={modalClose} isOpen={props.isOpen}>
  | 2022-07-15 16:57:35 PDT | ~~~~~

Scope

Patch: Bug Fix

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 18, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d7840e9:

Sandbox Source
Basic usage Configuration

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 18, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 65cf119
Status: ✅  Deploy successful!
Preview URL: https://128e28db.baseweb.pages.dev
Branch Preview URL: https://modal-optional-props.baseweb.pages.dev

View logs

@zxbodya
Copy link
Contributor

zxbodya commented Jul 19, 2022

I'm not sure why this kind of error does not raise when running tsc in baseui repo?

most likely the reason is that in code having the error Modal component is not used directly, but is wrapped in some kind of high order component

(when used directly like it is in baseui repository - typescript can see static defaultProps field on component, and so to treat properties provided there as optional)

@chasestarr chasestarr merged commit 1c01257 into master Jul 19, 2022
@chasestarr chasestarr deleted the modal-optional-props branch July 19, 2022 17:28
andriuss pushed a commit to andriuss/baseweb that referenced this pull request Aug 2, 2022
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.

2 participants