mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-08 18:11:45 -06:00
Set parent pointers on manufactured reference for property initialization check (#27246)
This commit is contained in:
parent
9103191527
commit
93f6b73c8c
@ -26176,6 +26176,8 @@ namespace ts {
|
||||
|
||||
function isPropertyInitializedInConstructor(propName: Identifier, propType: Type, constructor: ConstructorDeclaration) {
|
||||
const reference = createPropertyAccess(createThis(), propName);
|
||||
reference.expression.parent = reference;
|
||||
reference.parent = constructor;
|
||||
reference.flowNode = constructor.returnFlowNode;
|
||||
const flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
|
||||
return !(getFalsyFlags(flowType) & TypeFlags.Undefined);
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
//// [strictBooleanMemberAssignability.ts]
|
||||
class Abc {
|
||||
def: boolean
|
||||
constructor() {
|
||||
this.def = true
|
||||
}
|
||||
}
|
||||
|
||||
//// [strictBooleanMemberAssignability.js]
|
||||
"use strict";
|
||||
var Abc = /** @class */ (function () {
|
||||
function Abc() {
|
||||
this.def = true;
|
||||
}
|
||||
return Abc;
|
||||
}());
|
||||
@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/strictBooleanMemberAssignability.ts ===
|
||||
class Abc {
|
||||
>Abc : Symbol(Abc, Decl(strictBooleanMemberAssignability.ts, 0, 0))
|
||||
|
||||
def: boolean
|
||||
>def : Symbol(Abc.def, Decl(strictBooleanMemberAssignability.ts, 0, 11))
|
||||
|
||||
constructor() {
|
||||
this.def = true
|
||||
>this.def : Symbol(Abc.def, Decl(strictBooleanMemberAssignability.ts, 0, 11))
|
||||
>this : Symbol(Abc, Decl(strictBooleanMemberAssignability.ts, 0, 0))
|
||||
>def : Symbol(Abc.def, Decl(strictBooleanMemberAssignability.ts, 0, 11))
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/strictBooleanMemberAssignability.ts ===
|
||||
class Abc {
|
||||
>Abc : Abc
|
||||
|
||||
def: boolean
|
||||
>def : boolean
|
||||
|
||||
constructor() {
|
||||
this.def = true
|
||||
>this.def = true : true
|
||||
>this.def : boolean
|
||||
>this : this
|
||||
>def : boolean
|
||||
>true : true
|
||||
}
|
||||
}
|
||||
7
tests/cases/compiler/strictBooleanMemberAssignability.ts
Normal file
7
tests/cases/compiler/strictBooleanMemberAssignability.ts
Normal file
@ -0,0 +1,7 @@
|
||||
// @strict: true
|
||||
class Abc {
|
||||
def: boolean
|
||||
constructor() {
|
||||
this.def = true
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user