Skip to content

strictNullChecks mode - Variable is used before being assigned. #10641

Closed
@aliai

Description

@aliai

TypeScript Version: nightly (2.0.2)

In strictNullChecks mode only:

Code

const CONFIG = {
  foo: '',
  setFoo: function(foo: string) {
    // accessing (reading or writing) CONFIG.foo is not allowed!
    CONFIG.foo = foo;  // <-- Error: Variable 'CONFIG' is used before being assigned.
  }
};

Expected behavior:

I don't see why this is not a valid statement.

Actual behavior:

Trying to access any defined member of CONFIG in a method, defined within the object itself, raises an error: Variable 'CONFIG' is used before being assigned.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions