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

xxxProps type error with data-* attribute #18874

Closed
2 tasks done
oscar-b opened this issue Dec 16, 2019 · 6 comments
Closed
2 tasks done

xxxProps type error with data-* attribute #18874

oscar-b opened this issue Dec 16, 2019 · 6 comments
Labels
external dependency Blocked by external dependency, we can’t do anything about it typescript

Comments

@oscar-b
Copy link

oscar-b commented Dec 16, 2019

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

When specifying PaperProps there's a type error.

Expected Behavior 🤔

There should be no type error.

Steps to Reproduce 🕹

https://codesandbox.io/s/material-demo-h11wl
demo.tsx, row 55:

PaperProps={{ 'data-testid': '123' }}

Steps:

  1. Add the following the a Popover:
PaperProps={{ 'data-testid': '123' }}

image

Error:

Object literal may only specify known properties, and ''data-testid'' does not exist in type 'Partial'.ts(2769)

Context 🔦

Cypress needs selectors for targeting elements, and using a data-id or data-testid attribute is the preferred solution that doesn't rely on styling selectors which might change over time.

Your Environment 🌎

Tech Version
Material-UI v4.8.0
React v16.12.0
Browser
TypeScript v3.7.3
etc.
@oscar-b oscar-b changed the title Popover PaperProps type error with data- attribute Popover PaperProps type error with data-* attribute Dec 16, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 16, 2019

I have no idea where this error originates from. Any idea? It looks like TypeScript gives up: https://codesandbox.io/s/material-demo-h11wl.

@oscar-b
Copy link
Author

oscar-b commented Dec 16, 2019

I have no idea where this error originates from. Any idea? It looks like TypeScript gives up: https://codesandbox.io/s/material-demo-h11wl.

No sorry I don't really have any idea, I'm new to using TS :| But I was assuming that data-* should be whitelisted, and as far as I can see this works (and should be using the same type):

<Paper data-testid="123">

@oscar-b
Copy link
Author

oscar-b commented Dec 16, 2019

@oliviertassinari This looks relevant: microsoft/TypeScript#28960

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 16, 2019

@oscar-b Oh great, so it's somewhat a limitation of TypeScript?

@oscar-b
Copy link
Author

oscar-b commented Dec 16, 2019

@oscar-b Oh great, so it's somewhat a limitation of TypeScript?

That's the way I interpret it, at least :/

@oliviertassinari oliviertassinari added the external dependency Blocked by external dependency, we can’t do anything about it label Dec 16, 2019
@oliviertassinari oliviertassinari changed the title Popover PaperProps type error with data-* attribute xxxProps type error with data-* attribute Dec 17, 2019
@eps1lon
Copy link
Member

eps1lon commented Dec 27, 2019

Closing this in favor of microsoft/TypeScript#28960. Please upvote and subscribe to that issue instead if you'd like to see this fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external dependency Blocked by external dependency, we can’t do anything about it typescript
Projects
None yet
Development

No branches or pull requests

3 participants