Skip to content

Getters are not undefined checked on nullables #9671

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
tinganho opened this issue Jul 13, 2016 · 1 comment
Closed

Getters are not undefined checked on nullables #9671

tinganho opened this issue Jul 13, 2016 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@tinganho
Copy link
Contributor

Below should give me an error:

class A {
   a(): string | null {
        if (Math.random() > 0.5) {
            return '';
        }

        // it does error here as expected
    }
}
class A {
    get a(): string | null {
        if (Math.random() > 0.5) {
            return '';
        }

        // it should error here because it returns undefined
    }
}
tsc -v
Version 2.1.0-dev.20160713
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jul 13, 2016
@RyanCavanaugh
Copy link
Member

Is this under --noImplicitReturns ?

@RyanCavanaugh RyanCavanaugh added this to the TypeScript 2.0.1 milestone Aug 1, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Aug 22, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants