Skip to content

JS: property on function "used before being assigned" regression #27167

@brendankenny

Description

@brendankenny

TypeScript Version: master, due to #27128

Search Terms:
is used before being assigned, property on function, expando

Code

// test.js
class TestClass {}
TestClass.NONE = 'NONE';

function fn() {
  console.log(TestClass.NONE); // error TS2565: Property 'NONE' is used before being assigned.
}

test with tsc --strict --allowJs --checkJs --noEmit

Expected behavior:
No error.

Error only seems to appear if the property is accessed within another function body, not top-level (or same level). Not an error without --strictNullChecks.

Testing with latest found this error when a property was defined on a function or class (outside its body) and then required from a different file, but it appears to be the same problem if they're in the same file, as in the example above.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallycheckJsRelates to checking JavaScript using TypeScript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions