mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 06:17:19 -05:00
Fix completions in return when in function with contextual 'this' (#45340)
This commit is contained in:
@@ -1602,6 +1602,12 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
if (!isTypeLocation) {
|
||||
// GH#39946. Pulling on the type of a node inside of a function with a contextual `this` parameter can result in a circularity
|
||||
// if the `node` is part of the exprssion of a `yield` or `return`. This circularity doesn't exist at compile time because
|
||||
// we will check (and cache) the type of `this` *before* checking the type of the node.
|
||||
const container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
if (!isSourceFile(container) && container.parent) typeChecker.getTypeAtLocation(container);
|
||||
|
||||
let type = typeChecker.getTypeAtLocation(node).getNonOptionalType();
|
||||
let insertQuestionDot = false;
|
||||
if (type.isNullableType()) {
|
||||
|
||||
Reference in New Issue
Block a user