mi6 / mi6/ic-ui-kit

Internal issue 3122 - TypeScript error on autocorrect in HTMLIcTextFieldElement

Open
#4,028 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
53
Forks
63
Avg merge
2d 4h
Merged PRs (30d)
15

Description

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;
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the shown TypeScript error with HTMLIcTextFieldElement passed to within and inspect the type declaration for its autocorrect property. Done means the textField can be passed to shadow-dom-testing-library without the unknown-to-HTMLElement workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.