We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 Version: 2.1.4
Code
interface IPerson { name: string; } let person: IPerson = { name: 'John' }; let person2: IPerson; person2 = { name: 'John', age:34 }; //error!!!! person2 = { ...person, age: 34 }; //no error!!!!
Question Is person2 = { ...person, age: 34 }; //no error!!!! expected behavior?
person2 = { ...person, age: 34 }; //no error!!!!
The text was updated successfully, but these errors were encountered:
I think this is expected behavior. These are not object literals but rather expressions that produce a value that is a subtype of their constituents.
Sorry, something went wrong.
OK, thanks, but is there any other solution how to avoid typing errors, e.g.:
person2 = { ...person, xname: 'Charles' };
Duplicate of #12717
No branches or pull requests
TypeScript Version: 2.1.4
Code
Question
Is
person2 = { ...person, age: 34 }; //no error!!!!
expected behavior?The text was updated successfully, but these errors were encountered: