mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
fix typeof completions broken
This commit is contained in:
parent
b8def16e92
commit
7c93affd7d
@ -19263,8 +19263,8 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isValidPropertyAccessForCompletions(node: PropertyAccessExpression | ImportTypeNode, type: Type, property: Symbol): boolean {
|
||||
return isValidPropertyAccessWithType(node, node.kind !== SyntaxKind.ImportType && node.expression.kind === SyntaxKind.SuperKeyword, property.escapedName, type)
|
||||
function isValidPropertyAccessForCompletions(node: PropertyAccessExpression | ImportTypeNode | QualifiedName, type: Type, property: Symbol): boolean {
|
||||
return isValidPropertyAccessWithType(node, node.kind === SyntaxKind.PropertyAccessExpression && node.expression.kind === SyntaxKind.SuperKeyword, property.escapedName, type)
|
||||
&& (!(property.flags & SymbolFlags.Method) || isValidMethodAccess(property, type));
|
||||
}
|
||||
function isValidMethodAccess(method: Symbol, actualThisType: Type): boolean {
|
||||
|
||||
@ -3108,7 +3108,7 @@ namespace ts {
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName | ImportTypeNode, propertyName: string): boolean;
|
||||
/** Exclude accesses to private properties or methods with a `this` parameter that `type` doesn't satisfy. */
|
||||
/* @internal */ isValidPropertyAccessForCompletions(node: PropertyAccessExpression | ImportTypeNode, type: Type, property: Symbol): boolean;
|
||||
/* @internal */ isValidPropertyAccessForCompletions(node: PropertyAccessExpression | ImportTypeNode | QualifiedName, type: Type, property: Symbol): boolean;
|
||||
/** Follow all aliases to get the original symbol. */
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
/** Follow a *single* alias to get the immediately aliased symbol. */
|
||||
|
||||
@ -913,7 +913,7 @@ namespace ts.Completions {
|
||||
}
|
||||
else {
|
||||
for (const symbol of type.getApparentProperties()) {
|
||||
if (typeChecker.isValidPropertyAccessForCompletions(node.kind === SyntaxKind.ImportType ? <ImportTypeNode>node : <PropertyAccessExpression>node.parent, type, symbol)) {
|
||||
if (typeChecker.isValidPropertyAccessForCompletions(node.kind === SyntaxKind.ImportType ? <ImportTypeNode>node : <PropertyAccessExpression | QualifiedName>node.parent, type, symbol)) {
|
||||
addPropertySymbol(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
15
tests/cases/fourslash/completionTypeofExpressions.ts
Normal file
15
tests/cases/fourslash/completionTypeofExpressions.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// const x = "str";
|
||||
//// function test(arg: typeof x./*1*/) {}
|
||||
//// function test1(arg: typeof (x./*2*/)) {}
|
||||
|
||||
verify.completions({
|
||||
marker: "1",
|
||||
includes: ['length']
|
||||
});
|
||||
|
||||
verify.completions({
|
||||
marker: "2",
|
||||
includes: ['length']
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user