Skip to content

Commit

Permalink
added additional condition for literals and symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
danay1999 committed Jul 12, 2022
1 parent 50372d9 commit 868ef27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42217,7 +42217,10 @@ namespace ts {
checkPropertyAccessExpression(name, CheckMode.Normal);
if(!links.resolvedSymbol){
const expressionType = checkExpressionCached(name.expression);
const infos = getApplicableIndexInfos(expressionType, getLiteralTypeFromPropertyName(name.name));
let infos = getApplicableIndexInfos(expressionType, getLiteralTypeFromPropertyName(name.name));
if(infos.length === 0 && getIndexInfosOfType(expressionType).filter(type => type.keyType.flags & TypeFlags.TemplateLiteral || type.keyType.flags & TypeFlags.ESSymbol).length > 0){
infos = getApplicableIndexInfos(expressionType, checkExpressionCached(name.name));
}
if (length(infos) && infos[0].declaration && infos[0].declaration?.symbol.flags & SymbolFlags.Signature && infos[0].declaration?.jsDoc) {
const copy = createSymbol(SymbolFlags.Signature, InternalSymbolName.Index);
copy.declarations = mapDefined(infos, i => i.declaration);
Expand Down
15 changes: 7 additions & 8 deletions src/services/symbolDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,11 @@ namespace ts.SymbolDisplay {
displayParts.push(spacePart());
}

function addFullSymbolName(symbolToDisplay: Symbol, enclosingDeclaration?: Node, indexInfos?:IndexInfo[]) {
function addFullSymbolName(symbolToDisplay: Symbol, enclosingDeclaration?: Node, indexInfos?: IndexInfo[]) {
if (alias && symbolToDisplay === symbol) {
symbolToDisplay = alias;
}
let fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined,
const fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined,
SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing | SymbolFormatFlags.AllowAnyNodeKind);
if(symbolToDisplay.flags & SymbolFlags.Signature){
if(indexInfos){
Expand All @@ -661,11 +661,9 @@ namespace ts.SymbolDisplay {
if(length(indexInfos)){
//Needed to handle more than one type of index
for(let info=0; info<indexInfos.length; info++){
const indexTypeDisplayParts = typeToDisplayParts(typeChecker, indexInfos[info].keyType);
const indexTypeDisplayParts = typeToDisplayParts(typeChecker, indexInfos[info].keyType);
//Needed to handle template literals
for (const part of indexTypeDisplayParts){
fullSymbolDisplayParts[index++] = part;
}
for (const part of indexTypeDisplayParts) fullSymbolDisplayParts[index++] = part;
if(info !== indexInfos.length-1){
fullSymbolDisplayParts[index++] = spacePart();
fullSymbolDisplayParts[index++] = punctuationPart(SyntaxKind.BarToken);
Expand All @@ -685,13 +683,14 @@ namespace ts.SymbolDisplay {
}
}

function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string, indexInfos?:IndexInfo[]) {
function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string, indexInfos?: IndexInfo[]) {
prefixNextMeaning();
if (symbolKind) {
pushSymbolKind(symbolKind);
if (symbol && !some(symbol.declarations, d => isArrowFunction(d) || (isFunctionExpression(d) || isClassExpression(d)) && !d.name)) {
displayParts.push(spacePart());
addFullSymbolName(symbol, undefined, indexInfos);
const enclosingDeclaration = undefined;
addFullSymbolName(symbol, enclosingDeclaration, indexInfos);
}
}
}
Expand Down

0 comments on commit 868ef27

Please sign in to comment.