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

Attribute types are not checked if spread operator is used for passing props #132

Closed
2 tasks done
mickmister opened this issue Feb 28, 2024 · 1 comment
Closed
2 tasks done

Comments

@mickmister
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Versions

Version being used: 3.0.10

Description

I want to create an object that satisfiesHtmx.Attributes, and pass that to a component using a spread operator. This functionally works, but if there is a misspelled attribute, the JSX parser does not show a parsing error.

Steps to Reproduce

The problem is that if I type this incorrectly like:

const childProps = {
    'hx-wrongspelling': '/myapi',
};

return <div {...childProps}/>

I don't receive a type error, whereas I correctly receive a type error in this case:

return <div hx-wrongspelling='/myapi'/>

Expected Behavior

A type error should show when an invalid HTML attribute is passed in via spread operator

@arthurfiorette
Copy link
Member

This is a intended feature in typescript. JSX only respects this behavior.

https://www.typescriptlang.org/docs/handbook/2/objects.html#excess-property-checks

@arthurfiorette arthurfiorette closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants