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

Structural typing when specifying component props in TSX #15706

Closed
cnshenj opened this issue May 9, 2017 · 1 comment
Closed

Structural typing when specifying component props in TSX #15706

cnshenj opened this issue May 9, 2017 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@cnshenj
Copy link

cnshenj commented May 9, 2017

TypeScript Version: 2.3.2

Code

type MyComponentProps = {
    name: string;
};

class MyComponent extends React.Component<MyComponentProps, void> {}

class MyClass {
    public name: string;
    public age?: number;
}

const my: MyClass = { name: "Jack", age: 20 };
const props: MyComponentProps = { ...my }; // This works
const c1 = <MyComponent {...my} />; //  error TS2322: Property 'age' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComponent> & Readonly<{ children?: ReactNode; }>...'
const c2 = <MyComponent {...props} />; // This works
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label May 9, 2017
@yuit
Copy link
Contributor

yuit commented May 10, 2017

@cnshenj thanks for reporting this. This is a duplicate for #15463 ...we have a fix in nightly and will have it for 2.3.3 as well

@yuit yuit closed this as completed May 10, 2017
@yuit yuit added Duplicate An existing issue was already created and removed Bug A bug in TypeScript labels May 10, 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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants