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

strictNullChecks and undefined values in class #9131

Closed
nicolashenry opened this issue Jun 13, 2016 · 1 comment
Closed

strictNullChecks and undefined values in class #9131

nicolashenry opened this issue Jun 13, 2016 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@nicolashenry
Copy link

TypeScript Version:

1.9.0-dev.20160613-1.0

Code

class Greeter {
    greeting: string;
    constructor(message: string) {
        // do nothing
    }
    greet() {
        return 'Hello, ' + this.greeting;
    }
}

export let greeting: string = new Greeter('world').greeting;

// greeting is undefined
console.log(greeting);

Expected behavior:

I would expect the compiler to complain about greeting not being assigned at least once in constructor with strictNullChecks flag activated.

Actual behavior:

The code run without error.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 13, 2016
@RyanCavanaugh
Copy link
Member

See #8476

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants