We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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.1.6
Search Terms:
Code
interface Identity { name: string } class Person implements Identity { name: string constructor(id: Identity) { Object.assign(this, id) } }
Expected behavior: Assign the Person's name property to the name property in id.
Person
name
id
Actual behavior: Compilation error: Property 'name' has no initializer and is not definitely assigned in the constructor. [2564]
Property 'name' has no initializer and is not definitely assigned in the constructor. [2564]
Playground Link: http://www.typescriptlang.org/play/#src=interface%20Identity%20%7B%0D%0A%20%20%20%20name%3A%20string%0D%0A%7D%0D%0A%0D%0Aclass%20Person%20implements%20Identity%20%7B%0D%0A%20%20%20%20name%3A%20string%0D%0A%0D%0A%20%20%20%20constructor(id%3A%20Identity)%20%7B%0D%0A%20%20%20%20%20%20%20%20Object.assign(this%2C%20id)%0D%0A%20%20%20%20%7D%0D%0A%7D
be sure to click on strictNullChecks, strictFunctionTypes, and strictPropertyInitialization
strictNullChecks
strictFunctionTypes
strictPropertyInitialization
The text was updated successfully, but these errors were encountered:
Duplicate of #26792
Sorry, something went wrong.
This issue has been marked as a duplicate and has seen no activity in the last day. It has been closed automatic house-keeping purposes.
No branches or pull requests
TypeScript Version: 3.1.6
Search Terms:
Code
Expected behavior:
Assign the
Person
'sname
property to thename
property inid
.Actual behavior:
Compilation error:
Property 'name' has no initializer and is not definitely assigned in the constructor. [2564]
Playground Link: http://www.typescriptlang.org/play/#src=interface%20Identity%20%7B%0D%0A%20%20%20%20name%3A%20string%0D%0A%7D%0D%0A%0D%0Aclass%20Person%20implements%20Identity%20%7B%0D%0A%20%20%20%20name%3A%20string%0D%0A%0D%0A%20%20%20%20constructor(id%3A%20Identity)%20%7B%0D%0A%20%20%20%20%20%20%20%20Object.assign(this%2C%20id)%0D%0A%20%20%20%20%7D%0D%0A%7D
be sure to click on
strictNullChecks
,strictFunctionTypes
, andstrictPropertyInitialization
The text was updated successfully, but these errors were encountered: