mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix(47438): show auto-complete for this inside class static blocks (#47460)
This commit is contained in:
@@ -2086,8 +2086,7 @@ namespace ts.Completions {
|
||||
// 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);
|
||||
typeChecker.tryGetThisTypeAt(node, /*includeGlobalThis*/ false);
|
||||
|
||||
let type = typeChecker.getTypeAtLocation(node).getNonOptionalType();
|
||||
let insertQuestionDot = false;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @target: esnext
|
||||
////class Foo {
|
||||
//// static #a = 1;
|
||||
//// static a() {
|
||||
//// this./*1*/
|
||||
//// }
|
||||
//// static b() {
|
||||
//// Foo./*2*/
|
||||
//// }
|
||||
//// static {
|
||||
//// this./*3*/
|
||||
//// }
|
||||
//// static {
|
||||
//// Foo./*4*/
|
||||
//// }
|
||||
////}
|
||||
|
||||
verify.completions({
|
||||
marker: ["1", "2", "3", "4"],
|
||||
exact: completion.functionMembersPlus([
|
||||
{ name: "#a", sortText: completion.SortText.LocalDeclarationPriority },
|
||||
{ name: "a", sortText: completion.SortText.LocalDeclarationPriority },
|
||||
{ name: "b", sortText: completion.SortText.LocalDeclarationPriority },
|
||||
{ name: "prototype" }
|
||||
])
|
||||
});
|
||||
Reference in New Issue
Block a user