Skip to content

Incorrect "Variable is used before being assigned" when initializing class member (strictNullChecks) #8967

@dchest

Description

@dchest

TypeScript Version:

1.9.0-dev.20160604-1.0

Code

const LANG = "Turbo Pascal"

class BestLanguage {
    name = LANG;
}

Expected behavior:

Compiled without errors.

Actual behavior:

$ tsc --strictNullChecks test.ts 
test.ts(4,12): error TS2454: Variable 'LANG' is used before being assigned.

Latest version that doesn't have this bug is Version 1.9.0-dev.20160602-1.0.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions