-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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] Convert to TypeScript #34751
Conversation
There are some issues with the build. Could you please verify your imports? |
packages/mui-base/src/TextareaAutosize/TextareaAutoSize.test.tsx
Outdated
Show resolved
Hide resolved
packages/mui-base/src/TextareaAutosize/TextareaAutoSize.test.tsx
Outdated
Show resolved
Hide resolved
'themeStyleOverrides', | ||
'themeVariants', | ||
], | ||
} as any), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting to any
should be used as a last resort. In this case, it should be possible to correct the code so it's not needed.
) { | ||
const lineHeight = typeof lineHeightArg === 'function' ? lineHeightArg : () => lineHeightArg; | ||
|
||
getComputedStyleStub[input] = getComputedStyle; | ||
getComputedStyleStub[input as any] = getComputedStyle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is not right here. An HTMLInputElement
shouldn't be used as an index.
const input: HTMLInputElement = container.querySelector( | ||
'textarea[aria-hidden=null]', | ||
) as HTMLInputElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const input: HTMLInputElement = container.querySelector( | |
'textarea[aria-hidden=null]', | |
) as HTMLInputElement; | |
const input: HTMLInputElement = container.querySelector('textarea[aria-hidden=null]')!; |
const shadow = container.querySelector('textarea[aria-hidden=true]'); | ||
expect(input.style).to.have.property('height', ''); | ||
expect(input.style).to.have.property('overflow', ''); | ||
|
||
setLayout(input, shadow, { | ||
setLayout(input as HTMLInputElement, shadow as HTMLTextAreaElement, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to cast input
as it has the correct type.
Also, make sure that shadow
has the correct type to avoid casting.
placeholder?: string; | ||
onChange?: (e: React.FormEvent<HTMLTextAreaElement>) => void; | ||
maxRows?: number | undefined; | ||
minRows: number | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minRows: number | undefined; | |
minRows?: number | undefined; |
@@ -85,12 +96,14 @@ describe('<TextareaAutosize />', () => { | |||
|
|||
it('should update when uncontrolled', () => { | |||
const handleChange = spy(); | |||
const { container } = render(<TextareaAutosize onChange={handleChange} />); | |||
const input = container.querySelector('textarea[aria-hidden=null]'); | |||
const { container } = render(<TextareaAutosize minRows={1} onChange={handleChange} />); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minRows
shouldn't be mandatory
@@ -0,0 +1,257 @@ | |||
import * as React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are too many changes in this file for git to treat it as a rename. It would be best to specify the new types in the TextareaAutosize.types.ts, to minimize the number of changes done here, so the history is preserved.
It would also make it easier to review the code.
@@ -0,0 +1 @@ | |||
export { default } from './TextareaAutoSize'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added types should also be exported.
Closing due to inactivity in favor of #35862 |
I update the
TextAreaAutoSize
to typeScriptCloses #34721