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

[JS/JSX] Children prop is not recognized properly #15605

Closed
methyl opened this issue May 5, 2017 · 3 comments
Closed

[JS/JSX] Children prop is not recognized properly #15605

methyl opened this issue May 5, 2017 · 3 comments

Comments

@methyl
Copy link

methyl commented May 5, 2017

TypeScript Version: 2.3.1

Code

import React from "react";

const Foo = ({ children }) =>
  <div>
    {children}
  </div>

const Bar = () =>
  <Foo>Test</Foo>

Expected behavior:
Children prop is recognized, type check passes.

Actual behavior:

Error occurs:

message: 'Type '{}' is not assignable to type 'IntrinsicAttributes & { children: any; }'.
  Type '{}' is not assignable to type '{ children: any; }'.
    Property 'children' is missing in type '{}'.'
at: '9,3'
source: 'ts'
@methyl
Copy link
Author

methyl commented May 5, 2017

The same happens for typescript code:

import React from "react";

const Foo: React.StatelessComponent<{ children: Element }> = ({ children }) =>
  <div>
    {children}
  </div>

const Bar: React.StatelessComponent <{}> = () =>
  <Foo>Test</Foo>

@methyl
Copy link
Author

methyl commented May 5, 2017

Duplicate of #6471

@methyl methyl closed this as completed May 5, 2017
@mhegazy
Copy link
Contributor

mhegazy commented May 5, 2017

This is actually a duplicate of #15583. Please update your @types/react. see #15583 (comment) for more info.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants