question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript 3.2 bug: FormControl component="fieldset" not valid

See original GitHub issue

Typescript 3.2.1:

<FormControl component="fieldset" className={classes.formControl}>

[ts] Type '"fieldset"' is not assignable to type '"object" | "ruby" | "table" | "small" | "sub" | "embed" | "caption" | "menu" | "menuitem" | "meter" | "abbr" | "address" | "article" | "aside" | "b" | "bdi" | "bdo" | "big" | "blockquote" | ... 62 more ... | undefined'. [2322]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
eps1loncommented, Nov 30, 2018

DefinitelyTyped/DefinitelyTyped#30764 improved typechecking for React.ReactType which bites us here since our typings only support additional props that are assignable to the div element (which is the default for FormControl). However fieldset has some additional attributes and that’s why the compiler is (rightfully) complaining.

Defeat device:

<FormControl component={"fieldset" as "div"} className="hello-world" />

Perfectly safe at runtime since every attribute for div is a valid attribute for fieldset.

This is currently a limitation of our typings. With v4 we definitely plan to make our props are generic which should resolve those issues at the cost of an additional requirement in the form of explicitly typed callbacks.

I’m going to add a test case where we expect an error so that we’re reminded once this get’s fixed.

0reactions
cjauvincommented, Feb 16, 2019

I’m currently in the process of simultaneously learning React, MUI and TS, and I just ran today into the exact issue discussed in this thread. As I can’t really (yet) understand both the problem and its (temporary?) solution, I begin to wonder if tackling TS and MUI at the same time makes sense for a beginner, and maybe also, if now is a good time to do it. I’d appreciate any comments, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript 3.2 bug: FormControl component="fieldset" not valid
Perfectly safe at runtime since every attribute for div is a valid attribute for fieldset . This is currently a limitation of our...
Read more >
'component' does not exist in type 'FormControlProps' - Stack ...
It gives me following error: Object literal may only specify known properties, and 'component' does not exist in type ...
Read more >
formcontrol object object | The AI Search Engine You Control
It based on Cristian Deschamps answer. I update validity only on blur, so if value was invalid before focus it will be invalid...
Read more >
Selectors Level 4 - W3C
Note: Some pseudo-classes are mutually exclusive (such that a compound selector containing them, while valid, will never match anything), while ...
Read more >
How to Change MUI TextField's Border Color (Hover, Focus ...
Like the Input component, the color prop only changes focus color, not hover color. The key to styling the TextField component is understanding ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found