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

Quickfix for functions missing return statement #13589

Closed
Chris2011 opened this issue Jan 20, 2017 · 5 comments
Closed

Quickfix for functions missing return statement #13589

Chris2011 opened this issue Jan 20, 2017 · 5 comments
Labels
Declined The issue was declined as something which matches the TypeScript vision Domain: Quick Fixes Editor-provided fixes, often called code actions. Suggestion An idea for TypeScript

Comments

@Chris2011
Copy link

Chris2011 commented Jan 20, 2017

TypeScript Version: 2.0.3

Code

I have this piece of code where I see the error of missing return type. Correct behaviour

    public getListData(path: string): Object {

    }

I use NetBeans with the NBTS Plugin: https://github.com/Everlaw/nbts.
I created a ticket there: Everlaw/nbts#85 which I want to have fixes for warnings/errors. I have a method with Object as a return type. The method body is empty. It throws an error that I need a return type.

Expected behavior:

I want to have fixes for the error that I can add the return type or change the method return type to void as you can see it here, which is working for Java:

return-value-java

Actual behavior:

I only see the error:

return-value

Regards

Chris

@Chris2011
Copy link
Author

Chris2011 commented Jan 20, 2017

I updated to TS 2.1.5 but it is still a problem. Only to inform you.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label May 24, 2017
@mhegazy mhegazy added Suggestion An idea for TypeScript Domain: Quick Fixes Editor-provided fixes, often called code actions. and removed Needs Investigation This issue needs a team member to investigate its status. labels May 25, 2017
@mhegazy mhegazy changed the title Please add hints with fixes Quickfix for functions missing return statement May 25, 2017
@amcasey
Copy link
Member

amcasey commented Aug 21, 2017

What return value would the code fix generate? In Java, it seems like you could use null or the default of a literal type, but it's less clear (to me) in JS/TS.

@RyanCavanaugh RyanCavanaugh added the Declined The issue was declined as something which matches the TypeScript vision label Aug 15, 2018
@RyanCavanaugh
Copy link
Member

Without a plausible value to put in the return statement, just inserting one token isn't a great use case for a "quick fix"

@Chris2011
Copy link
Author

The return value, that should generate, is that, for example for the Object example a simple {} or for any other type like MyType, could be <MyType>{} or new MyType() if it is not an interface. So it is only an easy fix, that you don't have to type it manually. You see ah I forgot the return statement, please create me one. Nothing more.

@Kingwl
Copy link
Contributor

Kingwl commented Aug 16, 2018

actually i'm working on similar issues
and that will support more pattern
#26434

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Declined The issue was declined as something which matches the TypeScript vision Domain: Quick Fixes Editor-provided fixes, often called code actions. Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants