Skip to content

Cannot read property 'flags' of undefined when assigning tuple to class with private property #36871

@ghost

Description

TypeScript Version: 3.9.0-dev.20200215

Code

class C {
	#x = 0
}

function f(x: [number]): C {
	return x
}

Expected behavior:

No crash

Actual behavior:

TypeError: Cannot read property 'flags' of undefined
    at reportUnmatchedProperty (.../typescript/lib/tsc.js:40770:38)
    at propertiesRelatedTo (.../typescript/lib/tsc.js:40815:25)
    at structuredTypeRelatedTo (.../typescript/lib/tsc.js:40501:34)
    at recursiveTypeRelatedTo (.../typescript/lib/tsc.js:40248:53)
    at isRelatedTo (.../typescript/lib/tsc.js:39930:38)
    at checkTypeRelatedTo (.../typescript/lib/tsc.js:39638:26)
    at checkTypeRelatedToAndOptionallyElaborate (.../typescript/lib/tsc.js:38950:24)
    at checkTypeAssignableToAndOptionallyElaborate (.../typescript/lib/tsc.js:38944:20)
    at checkReturnStatement (.../typescript/lib/tsc.js:52933:25)
    at checkSourceElementWorker (.../typescript/lib/tsc.js:54384:28)

Related Issues: #36677

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions