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

[TextareaAutosize][base] Convert code to TypeScript #34721

Closed
michaldudak opened this issue Oct 11, 2022 · 7 comments · Fixed by #35862
Closed

[TextareaAutosize][base] Convert code to TypeScript #34721

michaldudak opened this issue Oct 11, 2022 · 7 comments · Fixed by #35862
Assignees
Labels
component: TextareaAutosize The React component. enhancement This is not a bug, nor a new feature package: base-ui Specific to @mui/base typescript

Comments

@michaldudak
Copy link
Member

Convert the TextareaAutosize and related modules (everything inside mui-base/src/TextareaAutosize) to TypeScript, to increase consistency with other MUI Base components.
There should be no functional changes.
Use other components as a reference.

@michaldudak michaldudak added component: TextareaAutosize The React component. package: base-ui Specific to @mui/base enhancement This is not a bug, nor a new feature labels Oct 11, 2022
@ryanrw
Copy link

ryanrw commented Oct 12, 2022

@michaldudak I think I can take this task. Could you assign to me, please?

@michaldudak
Copy link
Member Author

Sure, go ahead!

@ryanrw
Copy link

ryanrw commented Oct 14, 2022

I need help with with some piece of code inside the TextareaAutoSize.

The component contains inputRef and shadowRef, which is React's ref.

React.useRef(null);

Is it a good practice that I use non-null assertion on the variable assignment like this?

const inputShallow = shadowRef.current;
// here I put the non-null assertion to resolve TS typecheck
inputShallow!.style.width = computedStyle.width;

It will resolve the TypeScript typecheck error warning, but I don't know if ref can be null.

Thank you for your help.

@michaldudak
Copy link
Member Author

Yes, you could do it. This ref is null only initially. We would get runtime errors otherwise.


I see @paco9595 has also started working on this in #34751. Could you please coordinate your efforts? As @ryanrw was assigned to this issue, I'd prefer his implementation to be merged, but we can have @paco9595's PR as a fallback.

@ryanrw
Copy link

ryanrw commented Oct 14, 2022

@michaldudak It's ok to merge #34751 work first, since I'm tried to type safe if I'm possible to do so. (It's also holiday here, sorry for late work 😅)

@ryanrw
Copy link

ryanrw commented Oct 14, 2022

@michaldudak I just review on #34751 and I think his work is as same as mine, so it's ok to using his work instead.

@sai6855
Copy link
Contributor

sai6855 commented Jan 18, 2023

@michaldudak created PR which closes this issue #35862

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: TextareaAutosize The React component. enhancement This is not a bug, nor a new feature package: base-ui Specific to @mui/base typescript
Projects
Archived in project
4 participants