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

noImplicitReturns ignored when some return value is any #15064

Closed
ghost opened this issue Apr 7, 2017 · 4 comments
Closed

noImplicitReturns ignored when some return value is any #15064

ghost opened this issue Apr 7, 2017 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@ghost
Copy link

ghost commented Apr 7, 2017

TypeScript Version: nightly (2.3.0-dev.20170325)

Code

With --noImplicitReturns on:

declare var x: any;
function f() {
    if (1 + 1 === 3) {
        return x;
    }
}

Expected behavior:

The same error we get if we use declare var x: number;: Not all code paths return a value.

Actual behavior:

No error.

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Apr 7, 2017

This is "working as intended" according to #13112, but I wasn't given an actual explanation for why the issue was closed out.

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Apr 7, 2017
@aluanhaddad
Copy link
Contributor

aluanhaddad commented Apr 7, 2017

Seems fairly logical because void is assignable to any. Perhaps I am missing something.

I think the weirder behavior is that this is an error

function f(): undefined {
}

@gcnew
Copy link
Contributor

gcnew commented Apr 7, 2017

Maybe related #13284.

@mhegazy mhegazy added Duplicate An existing issue was already created and removed Bug A bug in TypeScript labels Jul 20, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

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

5 participants