Skip to content

Object.assing(this, {...}) not interpreted in constructors #38394

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

Closed
dilyanpalauzov opened this issue May 7, 2020 · 2 comments
Closed

Object.assing(this, {...}) not interpreted in constructors #38394

dilyanpalauzov opened this issue May 7, 2020 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@dilyanpalauzov
Copy link

For this file:

class T {
    a: string
    constructor (a:string) {
	Object.assign(this, {a})
    }
}

let t = new T('b')

tsc 3.8.3 reports

error TS2564: Property 'a' has no initializer and is not definitely assigned in the constructor.

I think property 'a'is definitely assigned in the constructor. this.a = a means the same.

@MartinJohns
Copy link
Contributor

Duplicate of #28883. Search terms: object assign this constructor.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label May 8, 2020
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants