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

fixAddMissingMember should create a constructor if not present #20331

Closed
ghost opened this issue Nov 29, 2017 · 2 comments
Closed

fixAddMissingMember should create a constructor if not present #20331

ghost opened this issue Nov 29, 2017 · 2 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Quick Fixes Editor-provided fixes, often called code actions. Suggestion An idea for TypeScript

Comments

@ghost
Copy link

ghost commented Nov 29, 2017

TypeScript Version: 2.7.0-dev.20171129

Code

a.js

class C {
    m() {
        this.x;
    }
}

Expected behavior:

Can fix the error by creating a constructor.

Actual behavior:

No codefix unless I manually add a constructor.

@ghost ghost self-assigned this Nov 29, 2017
@mhegazy mhegazy added Bug A bug in TypeScript Domain: Quick Fixes Editor-provided fixes, often called code actions. labels Nov 29, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Nov 29, 2017

one issue here is creating a constructor to just get the type is a bit of an overkill.. it gets more interesting when you have a base class, now you have to create a forwarding constructor, ideally with the same number and names of parameters..

one alternative here is for us to support @property or @member on a class a a source of property declaration. #15715 tracks a similar scenario

@mhegazy mhegazy unassigned ghost Nov 29, 2017
@mhegazy mhegazy added Bug A bug in TypeScript Domain: Quick Fixes Editor-provided fixes, often called code actions. and removed Bug A bug in TypeScript Domain: Quick Fixes Editor-provided fixes, often called code actions. labels Nov 29, 2017
@mhegazy mhegazy assigned ghost Nov 29, 2017
@mhegazy mhegazy added Suggestion An idea for TypeScript and removed Bug A bug in TypeScript labels Apr 12, 2018
@mhegazy mhegazy unassigned ghost Apr 12, 2018
@mhegazy mhegazy added the Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature label Apr 12, 2018
@RyanCavanaugh
Copy link
Member

This doesn't seem to come up often

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Quick Fixes Editor-provided fixes, often called code actions. Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants