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: 3.9.2
**Expected behavior: the two checked results to update properties of object should be same.
**Actual behavior: there is a type error in way 2, but not in way 1.
Code
interface xxx { id: string; name: string; description?: string; } const test = (propName: keyof xxx) => { const o: xxx = { id: '1', name: '1', description: '1' } const o2: xxx = { id: '1', name: '1', description: '1' } // change property way 1 const o3 = { ...o, [propName]: o2[propName] } // change property way 2 o[propName] = o2[propName] }
"use strict"; const test = (propName) => { const o = { id: '1', name: '1', description: '1' }; const o2 = { id: '1', name: '1', description: '1' }; // change property way 1 const o3 = Object.assign(Object.assign({}, o), { [propName]: o2[propName] }); // change property way 2 o[propName] = o2[propName]; };
{ "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true, "strictFunctionTypes": true, "strictPropertyInitialization": true, "strictBindCallApply": true, "noImplicitThis": true, "noImplicitReturns": true, "alwaysStrict": true, "esModuleInterop": true, "declaration": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "moduleResolution": 2, "target": "ES2017", "jsx": "React", "module": "ESNext" } }
Playground Link: Provided
Description: I am not sure the result for both of them should be correct or not. I just think they should be same.
The text was updated successfully, but these errors were encountered:
Duplicate of #13948 and #27273
Sorry, something went wrong.
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
TypeScript Version: 3.9.2
**Expected behavior: the two checked results to update properties of object should be same.
**Actual behavior: there is a type error in way 2, but not in way 1.
Code
Output
Compiler Options
Playground Link: Provided
Description: I am not sure the result for both of them should be correct or not. I just think they should be same.
The text was updated successfully, but these errors were encountered: