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

Controlled TextFields type bug #11927

Closed
ugreg opened this issue Feb 12, 2020 · 2 comments · Fixed by #11928
Closed

Controlled TextFields type bug #11927

ugreg opened this issue Feb 12, 2020 · 2 comments · Fixed by #11928

Comments

@ugreg
Copy link
Member

ugreg commented Feb 12, 2020

Environment Information

  • Package version(s)
"dependencies": {
    "@types/node": "^10.12.18",
    "@types/powerapps-component-framework": "^1.2.0",
    "office-ui-fabric-react": "^7.92.0",
    "react": "^16.12.0"
  }

Please provide a reproduction of the bug in a codepen:

Load the TextField samples for Controlled TextFields in codepen or in local text editor.

Actual behavior:

The Controlled TextField example uses incorrect types. The onchange methods private _onChangeX = (ev: React.FormEvent<HTMLInputElement>, newValue?: string) => { should instead be private _onChangeX = (ev: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string) => {.

[tsl] ERROR in D:\Form.tsx(40,10)
      TS2322: Type '(ev: React.FormEvent<HTMLInputElement>, newValue?: string | undefined) => void' is not assignable to type '(event: FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string | undefined) => void'.
  Types of parameters 'ev' and 'event' are incompatible.
    Type 'FormEvent<HTMLInputElement | HTMLTextAreaElement>' is not assignable to type 'FormEvent<HTMLInputElement>'.
      Type 'HTMLInputElement | HTMLTextAreaElement' is not assignable to type 'HTMLInputElement'.
        Type 'HTMLTextAreaElement' is missing the following properties from type 'HTMLInputElement': accept, align, alt, checked, and 23 more.

ERROR in D:\Form.tsx

Expected behavior:

App builds, compiles, and starts.

Priorities and help requested:

Are you willing to submit a PR to fix? Yes

Requested priority: Normal

@xugao
Copy link
Contributor

xugao commented Feb 12, 2020

@gregdegruy - thanks for reporting! I will fix this.
FYI on why this issue - currently our fabric code doesn't compile with strictFunctionTypes: true. related issue: #10226.

msft-github-bot pushed a commit that referenced this issue Feb 12, 2020
… is true (#11928)

#### Pull request checklist

- [x] Addresses an existing issue: Fixes #11927
- [x] Include a change request file using `$ yarn change`

#### Description of changes
Fix the typing error for `onChange` inside TextField examples when `strictFunctionTypes` is set to `true`
```
      TS2322: Type '(ev: React.FormEvent<HTMLInputElement>, newValue?: string | undefined) => void' is not assignable to type '(event: FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string | undefined) => void'.
  Types of parameters 'ev' and 'event' are incompatible.
    Type 'FormEvent<HTMLInputElement | HTMLTextAreaElement>' is not assignable to type 'FormEvent<HTMLInputElement>'.
      Type 'HTMLInputElement | HTMLTextAreaElement' is not assignable to type 'HTMLInputElement'.
        Type 'HTMLTextAreaElement' is missing the following properties from type 'HTMLInputElement': accept, align, alt, checked, and 23 more.
```
@msft-github-bot msft-github-bot added Status: Fixed Fixed in some PR and removed Status: In PR labels Feb 12, 2020
@msft-github-bot
Copy link
Contributor

🎉This issue was addressed in #11928, which has now been successfully released as office-ui-fabric-react@v7.93.0.:tada:

Handy links:

@microsoft microsoft locked as resolved and limited conversation to collaborators Mar 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants