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

[zero][runtime] Implement typings for public runtime API #39215

Merged
merged 8 commits into from
Oct 23, 2023

Conversation

brijeshb42
Copy link
Contributor

@brijeshb42 brijeshb42 commented Sep 29, 2023

@brijeshb42 brijeshb42 added the package: system Specific to @mui/system label Sep 29, 2023
@mui-bot
Copy link

mui-bot commented Sep 29, 2023

Netlify deploy preview

https://deploy-preview-39215--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against deb1101

@brijeshb42 brijeshb42 force-pushed the zero-typescript-support branch 4 times, most recently from 97e2bc6 to cb29cac Compare October 3, 2023 06:55
apps/zero-runtime-next-app/src/components/Grid.tsx Outdated Show resolved Hide resolved
@@ -286,8 +301,8 @@ const SliderTrack = styled('span', {
color: 'secondary',
},
style: {
backgroundColor: theme.vars ? theme.vars.palette.Slider.secondaryTrack : undefined,
borderColor: theme.vars ? theme.vars.palette.Slider.secondaryTrack : undefined,
backgroundColor: (theme.vars ?? theme).palette.Slider?.secondaryTrack,
Copy link
Member

Choose a reason for hiding this comment

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

We should be able to not use this many conditional chaining if the types of the theme are correctly defined, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. That comes from the user. In this case, I specified vars as {vars?: ThemeVars} that's why the conditionals.

@@ -1,5 +1,8 @@
{
"env": {
"jest": true
},
"rules": {
"react/react-in-jsx-scope": "off"
Copy link
Member

Choose a reason for hiding this comment

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

Why block this? We can import React where it makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

We should rather be consistent in the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a vite app with jsx as auto. So it's not needed to import React if you are only using JSX

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @mnajdova Could you look into the PR again? I've implemented majority of the requested changes.

apps/zero-runtime-vite-app/src/App.tsx Outdated Show resolved Hide resolved
apps/zero-runtime-vite-app/src/App.tsx Outdated Show resolved Hide resolved
packages/zero-runtime/src/index.ts Outdated Show resolved Hide resolved
packages/zero-runtime/src/styled.spec.tsx Outdated Show resolved Hide resolved
packages/zero-runtime/src/styled.spec.tsx Outdated Show resolved Hide resolved
@brijeshb42 brijeshb42 force-pushed the zero-typescript-support branch 3 times, most recently from ae5a7b7 to 07fe5fc Compare October 12, 2023 13:11
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 16, 2023
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 18, 2023
@brijeshb42 brijeshb42 force-pushed the zero-typescript-support branch 6 times, most recently from 9cf6686 to d15e563 Compare October 18, 2023 12:30
@@ -748,6 +756,7 @@ const Slider = React.forwardRef(function Slider(props, ref) {
},
ownerState: {
...ownerState,
// @ts-expect-error
Copy link
Member

Choose a reason for hiding this comment

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

I guess this is consumer-facing side, not related to zero-runtime.

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

👍 Can't wait to try!

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 20, 2023
},
{
props: {
isBlue: true,
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this throw, as isBlue is not part of the props interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not explicitly forbid passing unknown props but'll provide autocompletion for known props.
I verified that it works the same way with @mui/system.

Copy link
Member

@mnajdova mnajdova Oct 23, 2023

Choose a reason for hiding this comment

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

In that case, we should fix it in the @mui/system, too, and not replicate the wrong behavior (at least in my opinion is wrong). Is there a limitation that it was implemented like this? Can we fix it?

Considering this will be the API that will be used mostly about styling the components, we need to make sure it is strictly typed. Otherwise, image the callbacks not having a strict props type, it can cause so many issues.

I am approving we do a follow-up, to allow @siriwatknp to use the types we have so far.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am still exploring a way to fix it. There's one more feature to be added (automatic prop suggestion when as prop is provided with a different element. Will try to add both the fixes together.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 22, 2023
@brijeshb42 brijeshb42 merged commit f8edfef into mui:master Oct 23, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants