Skip to content

In JS, this assignments in a function add undefined to the resulting property type #22641

@sandersn

Description

@sandersn

This is visible with --strict:

// @noEmit: true
// @allowJs: true
// @checkJs: true
// @strict: true
// @Filename: a.js

function A() {
    this.x = { y : 1 }
}
var a = new A()
a.x.y

Expected behavior:
No error

Actual behavior:
Error "Object is possibly undefined" when accessing a.x.y

Metadata

Metadata

Assignees

Labels

FixedA PR has been merged for this issuecheckJsRelates to checking JavaScript using TypeScript

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