Added type checks to avoid false positive results

This commit is contained in:
navya9singh
2022-07-19 14:38:24 -07:00
parent d0547f1d0b
commit 9b1cbe059b
5 changed files with 97 additions and 18 deletions

View File

@@ -15589,8 +15589,8 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
return accessFlags & AccessFlags.IncludeUndefined ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
}
errorIfWritingToReadonlyIndex(indexInfo);
if (accessFlags & AccessFlags.IncludeUndefined && objectType.symbol.flags & (SymbolFlags.RegularEnum | SymbolFlags.ConstEnum)) {
if(indexType.flags & TypeFlags.EnumLiteral){
if (accessFlags & AccessFlags.IncludeUndefined && objectType.symbol && objectType.symbol.flags & (SymbolFlags.RegularEnum | SymbolFlags.ConstEnum)) {
if (indexType.symbol && indexType.flags & TypeFlags.EnumLiteral && getParentOfSymbol(indexType.symbol) === objectType.symbol) {
return indexInfo.type;
}
}