marmelab / react-admin

A frontend Framework for single-page applications on top of REST/GraphQL APIs, using TypeScript, React and Material Design
http://marmelab.com/react-admin
MIT License
24.89k stars 5.23k forks source link

v4 beta1 (upgrading old code): WebStorm "complains" that TextInput does not have a "required attribute name" #7277

Closed afilp closed 2 years ago

afilp commented 2 years ago

What you were expecting:

No warnings on <TextInput />

What happened instead:

Webstorm shows this on all occurences:

image

Steps to reproduce:

Just using TextInput.

Related code:

<SimpleForm>
            <TextInput label="Name" source="name" fullWidth />
            <TextInput label="Comments" source="comments" fullWidth />
</SimpleForm>

Environment

React-admin version: "react-admin": "^4.0.0-beta.1" Last version that did not exhibit the issue (if applicable): React version: "react": "^17.0.2" Browser: Stack trace (in case of a JS error):

WiXSL commented 2 years ago

This isn't a TypeScript error, but rather a feature/bug of your IDE. Can you confirm this?

afilp commented 2 years ago

Thanks @WiXSL . Not sure how I can confirm this, does anyone of you use WebStorm to see if they experience the same?

WiXSL commented 2 years ago

I'm using PHPStorm and I don't have any messages of the sort. Since it's not a code error but an IDE related one I'm closing this issue.

7system7 commented 10 months ago

I have the same issue. And this has been going on for at least 2 years.

image

fzaninotto commented 10 months ago

This really looks like a WebStorm issue as I've never experienced it in VSCode.

Besides, I have no idea what the error means:

Element TextInput doesn't have required attribute name

The TypeScript prop type for TextInput marks the name prop as optional. There is no required name in the propTypes.

In other terms, we have no way of reproducing this bug, and there is no reason it appears based on the code.

I really believe this is a bug in your IDE.

Did you open an issue in the WebStorm issue tracker?

7system7 commented 10 months ago

@fzaninotto I think almost the same that you. Actually I did not, because somebody else did it 2 months ago.

@afilp In the tooltip - what occurs on hover of the tag - there is a More actions..., you can choose that the IDE should not mark the name as a required field. It seems in the last 2 years this did not gives me enough pain to click 2, to solve this frustrating problem.

After this, there is another problem here. I do not know exactly, what did I switched off. :smile: Maybe this was not a bug, instead of a feature, or the IDE confused with another markup than JSX or so... At least, after the change, my all react-admin related code is clean. :partying_face:

fzaninotto commented 10 months ago

Interesting... In the screenshot of the WebStorm issue you linked, I read "Kotlin detected". I believe the IDE mixes up JSX for another language, which explains that it misinterprets the code.

Anyway, thanks for the feedback, and happy you got it solved on your side.