Skip to content

Commit 218bbcd

Browse files
Don't immediately return in getMemberSymbols.
1 parent 9b6a027 commit 218bbcd

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/services/completions.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,11 +1117,17 @@ namespace ts.Completions {
11171117
let type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType();
11181118
let insertQuestionDot = false;
11191119
if (type.isNullableType()) {
1120-
insertQuestionDot = isRightOfDot && !isRightOfQuestionDot;
1121-
type = type.getNonNullableType();
1122-
}
1123-
if (insertQuestionDot && preferences.includeAutomaticOptionalChainCompletions === false) {
1124-
return;
1120+
const canCorrectToQuestionDot =
1121+
isRightOfDot &&
1122+
!isRightOfQuestionDot &&
1123+
preferences.includeAutomaticOptionalChainCompletions !== false;
1124+
1125+
if (canCorrectToQuestionDot || isRightOfQuestionDot) {
1126+
type = type.getNonNullableType();
1127+
if (canCorrectToQuestionDot) {
1128+
insertQuestionDot = true;
1129+
}
1130+
}
11251131
}
11261132
addTypeProperties(type, !!(node.flags & NodeFlags.AwaitContext), insertQuestionDot);
11271133
}
@@ -1141,11 +1147,17 @@ namespace ts.Completions {
11411147
let type = typeChecker.getTypeAtLocation(node).getNonOptionalType();
11421148
let insertQuestionDot = false;
11431149
if (type.isNullableType()) {
1144-
insertQuestionDot = isRightOfDot && !isRightOfQuestionDot;
1145-
type = type.getNonNullableType();
1146-
}
1147-
if (insertQuestionDot && preferences.includeAutomaticOptionalChainCompletions === false) {
1148-
return;
1150+
const canCorrectToQuestionDot =
1151+
isRightOfDot &&
1152+
!isRightOfQuestionDot &&
1153+
preferences.includeAutomaticOptionalChainCompletions !== false;
1154+
1155+
if (canCorrectToQuestionDot || isRightOfQuestionDot) {
1156+
type = type.getNonNullableType();
1157+
if (canCorrectToQuestionDot) {
1158+
insertQuestionDot = true;
1159+
}
1160+
}
11491161
}
11501162
addTypeProperties(type, !!(node.flags & NodeFlags.AwaitContext), insertQuestionDot);
11511163
}

0 commit comments

Comments
 (0)