Skip to content

Option for strictPropertyInitialization to check even potentially undefined properties #26015

Closed
@marcomura

Description

@marcomura

Opening new bug since the previous got closed without any explanation.

Why strictPropertyInitialization should require strictNullChecks?

class C {
    foo: number;
    bar = "hello";
    baz: boolean;
    //  ~~~
    //  Error! Property 'baz' has no initializer and is not assigned directly in the constructor.
    constructor() {
        this.foo = 42;
    }
}

Without stringNullChecks, I can solve the error explicitly assigning undefined to baz.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Add a FlagAny problem can be solved by flags, except for the problem of having too many flagsSuggestionAn idea for TypeScriptToo ComplexAn issue which adding support for may be too complex for the value it adds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions