Skip to content

Commit e310261

Browse files
committed
Fix issue and back-port typescript-go #2376
1 parent 2dfdbba commit e310261

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

src/compiler/checker.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13212,6 +13212,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1321213212
}
1321313213

1321413214
function getBaseTypes(type: InterfaceType): BaseType[] {
13215+
if (!(getObjectFlags(type) & (ObjectFlags.ClassOrInterface | ObjectFlags.Reference))) {
13216+
return emptyArray
13217+
}
1321513218
if (!type.baseTypesResolved) {
1321613219
if (pushTypeResolution(type, TypeSystemPropertyName.ResolvedBaseTypes)) {
1321713220
if (type.objectFlags & ObjectFlags.Tuple) {
@@ -35053,28 +35056,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3505335056
* In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration.
3505435057
*/
3505535058
function isPropertyDeclaredInAncestorClass(prop: Symbol): boolean {
35056-
if (!(prop.parent!.flags & SymbolFlags.Class)) {
35057-
return false;
35058-
}
35059-
let classType: InterfaceType | undefined = getTypeOfSymbol(prop.parent!) as InterfaceType;
35060-
while (true) {
35061-
classType = classType.symbol && getSuperClass(classType) as InterfaceType | undefined;
35062-
if (!classType) {
35063-
return false;
35064-
}
35065-
const superProperty = getPropertyOfType(classType, prop.escapedName);
35066-
if (superProperty && superProperty.valueDeclaration) {
35067-
return true;
35059+
if (prop.parent && prop.parent.flags & SymbolFlags.Class) {
35060+
const baseTypes = getBaseTypes(getDeclaredTypeOfSymbol(prop.parent) as InterfaceType)
35061+
if (baseTypes.length) {
35062+
const superProperty = getPropertyOfType(baseTypes[0], prop.escapedName)
35063+
return !!(superProperty && superProperty.valueDeclaration)
3506835064
}
3506935065
}
35070-
}
35071-
35072-
function getSuperClass(classType: InterfaceType): Type | undefined {
35073-
const x = getBaseTypes(classType);
35074-
if (x.length === 0) {
35075-
return undefined;
35076-
}
35077-
return getIntersectionType(x);
35066+
return false
3507835067
}
3507935068

3508035069
function reportNonexistentProperty(propNode: Identifier | PrivateIdentifier, containingType: Type, isUncheckedJS: boolean) {

0 commit comments

Comments
 (0)