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' doesn't report an error if any branch returns 'any' #13112

Closed
DanielRosenwasser opened this issue Dec 22, 2016 · 1 comment
Labels
Bug A bug in TypeScript Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 22, 2016

The following correctly reports an error on foo under noImplicitReturns.

function foo(y: number, z: number) {
    if (y)
        return z;
}

However, removing the type annotations from y and z squelches the error.

function foo(y, z) {
    if (y)
        return z;
}
@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Dec 22, 2016
@mhegazy mhegazy added this to the TypeScript 2.2 milestone Dec 22, 2016
@vladima vladima added the Working as Intended The behavior described is the intended behavior; this is not a bug label Dec 22, 2016
@vladima
Copy link
Contributor

vladima commented Dec 22, 2016

Discussed offline with @mhegazy and @billti - current behavior for .ts files is by design - we don't report noImplicitReturns error if inferred return type is any or void. It makes sense however to report it for .js files and we already have an issue to track this. Closing this one in favor of it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants