Internal issue 3122 - TypeScript error on autocorrect in HTMLIcTextFieldElement
There is an issue with incompatible types when using ICDS with the shadow-dom-testing-library.
The following code:
const textField = container.querySelector('ic-text-field') as HTMLIcTextFieldElement;
await waitFor(() => expect(textField).toHaveClass('hydrated'));
const textInput = await within(textField).findByShadowRole('textbox');
gives the following error for the textField inside the within function:
Argument of type 'HTMLIcTextFieldElement' is not assignable to parameter of type 'HTMLElement'.
Types of property 'autocorrect' are incompatible.
Type 'string' is not assignable to type 'boolean'.
Type 'string' is not assignable to type 'boolean'.ts(2345)
A workaround is as follows:
const textField = container.querySelector('ic-text-field') as unknown as HTMLElement;
Breaking change to make it a boolean
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement says:
HTMLElement.autocorrect https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/autocorrect A boolean that represents whether or not text input by a user should be automatically corrected. This reflects the autocorrect HTML global attribute.
However the examples show it accepting "on", "off" or "", as has been implemented for the textfield component https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/autocorrect#value