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

Typescript: Error when using Menu.Item as Link. #1079

Closed
wcatron opened this issue Dec 22, 2016 · 2 comments
Closed

Typescript: Error when using Menu.Item as Link. #1079

wcatron opened this issue Dec 22, 2016 · 2 comments

Comments

@wcatron
Copy link
Contributor

wcatron commented Dec 22, 2016

Steps

  1. Use typescript.
  2. Use a Menu.Item with the link property set (also as={Link}) and the to property.

Expected Result

Typescript shouldn't fail.

Actual Result

Typescript fails because to is not a property of Menu.Item. Note: The actual generated code works as expected.

error TS2339: Property 'to' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<MenuItemProps, ComponentState>> & { chil...

Version

0.63.1

Testcase

<Menu.Item name='home' link as={Link} to="/home">Home</Menu.Item>

Solution

One possible solution is to add the to?:string prop to Menu.Item's typescript declaration file however that would snowball because technically it would support any property of Link (or any property of whatever class you put in as). Perhaps a better solution would be to separate it as a subclass of Menu.Item i.e. Menu.Item.Link and only use as when you're defining a class that inherits the same properties as Menu.Item.

@wcatron
Copy link
Contributor Author

wcatron commented Dec 22, 2016

I found a work around for anyone else who runs into this issue. Warning it's pretty ugly.

<Menu.Item name='home' link as={Link} {...{to: "/home"}}>Home</Menu.Item>

@levithomason
Copy link
Member

Duplicate, see #1072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants