-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[Bug]: slot cannot be passed a data-* attribute #27302
Comments
Duplicate of #23033? |
@layershifter possibly, seems that the #23033 is about the component prop itself, what this one is about is passing down a data attribute to one of the slots of the component. This might be caused by the same root issue, but I didn't want to make assumptions. |
Yes, this is basically the same issue, and as @behowell described, this would be a possible solution #23033 (comment). Just to be clear, this is not a slot problem itself, it's a TS "problem" (it's more like a TS bad decision?); In the case down hese TS is not being forgiving when passing properties that don't belong to a specified type, although it allows on the jsx root itself and also on non overlapping props. To give a simple solution for the problem in hand, just cast the type and things will work! https://stackblitz.com/edit/v966zs?file=src%2Fexample.tsx |
added more context on the issue #23033 (comment) what @bsunderhus suggesting is the only workaround ATM, which comes with its own set of problems. |
Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes. Still require assistance? Please, create a new issue with up-to date details. |
1 similar comment
Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes. Still require assistance? Please, create a new issue with up-to date details. |
Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes. Still require assistance? Please, create a new issue with up-to date details. |
1 similar comment
Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes. Still require assistance? Please, create a new issue with up-to date details. |
An option is to have mutliple .d.ts versions. We would need a build support for that, worth investigating. |
It wouldn't be entirely possible in our current TS version (v3.9). we would need a set of known |
Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes. Still require assistance? Please, create a new issue with up-to date details. |
This issue is faced by multiple major partners and needs more attention. We need to recheck TS version matrix and discuss the timelines with @Hotell. |
Seems like our current TS version does not support String Template literal type! But assuming we are able to upgrade our min TS to v4.5 we've still encountered another problem while investigating this through our partners:
Seems like a universal solution with Template literal types will not resolve this issue in our case. As we're using unions of types. |
This problem sums up on two TS features: We would need some sort of feature on TS side to disable EPC (Excess property checks) on object literals passed to slots. This is not supported by language! every object literal declaration is always EPC!
Since slot properties are not direct jsx properties, but an object, then EPC rules do apply to object literals on slot properties, only way to avoid this issue is:
Here's a an example of the problem with |
I opened up microsoft/TypeScript#58898, but in the meantime one way to address this is to use this type instead of type DistPick<T, K> =
T extends infer _ ? (K extends keyof T ? Pick<T, K> : never) : never; I believe the problem is that But to avoid all of that work, The subtlety is that if type DistPick<T, K> = Pick<
T extends infer _ ? (K extends keyof T ? Pick<T, K> : never) : never,
K,
>; |
Library
React Components / v9 (@fluentui/react-components)
System Info
Are you reporting Accessibility issue?
no
Reproduction
https://codesandbox.io/s/nice-poitras-wsk2c1?file=/example.tsx
Bug Description
Actual Behavior
Setting a "data-something" attribute to a slot results in TS error.
The data attribute is actually set on the appropriate DOM element.
Expected Behavior
Data attributes should be allowed in slot.
Logs
No response
Requested priority
High
Products/sites affected
No response
Are you willing to submit a PR to fix?
yes
Validations
The text was updated successfully, but these errors were encountered: