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

Generic JSX components #15742

Closed
mhegazy opened this issue May 10, 2017 · 0 comments · Fixed by #15789
Closed

Generic JSX components #15742

mhegazy opened this issue May 10, 2017 · 0 comments · Fixed by #15789
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@mhegazy
Copy link
Contributor

mhegazy commented May 10, 2017

The fix in #15687 did not get the original issue resolved, now that we have the apparent type, we can not spread T into a Component<T>.

here are a few samples:

import * as React from "react";

const decorator = function <T>(Component: React.StatelessComponent<T>): React.StatelessComponent<T> {
    return (props) => <Component {...props} ></Component> // should be ok
};

const decorator2 = function <T extends { x: number }>(Component: React.StatelessComponent<T>): React.StatelessComponent<T> {
    return (props) => <Component {...props} x={2} ></Component>  // Should be ok, x is known
};

const decorator4 = function <T extends { x: number }>(Component: React.StatelessComponent<T>): React.StatelessComponent<T> {
    return (props) => <Component {...props} y={"blah"} ></Component>  // Should be an error, unknown y
};
@mhegazy mhegazy added the Bug A bug in TypeScript label May 10, 2017
@mhegazy mhegazy added this to the TypeScript 2.3.3 milestone May 10, 2017
@yuit yuit mentioned this issue May 11, 2017
2 tasks
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label May 12, 2017
@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
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants