Skip to content

Commit dd48dd1

Browse files
authored
Merge pull request #14916 from Microsoft/master-addressPR14692
[Master] Address code review of PR 14692
2 parents 7de3539 + 7a66161 commit dd48dd1

8 files changed

+15
-89
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,9 +1544,9 @@ namespace ts {
15441544
}
15451545
}
15461546
else if (name.kind === SyntaxKind.ParenthesizedExpression) {
1547-
// If the expression in parenthsizedExpression is not an entity-name (e.g. it is a call expression), it won't be able to successfully resolve the name.
1548-
// This is the case when we are trying to do any language service operation in heritage clauses. By return undefined, the getSymbolOfEntityNameOrPropertyAccessExpression
1549-
// will attempt to checkPropertyAccessExpression to resolve symbol.
1547+
// If the expression in parenthesizedExpression is not an entity-name (e.g. it is a call expression), it won't be able to successfully resolve the name.
1548+
// This is the case when we are trying to do any language service operation in heritage clauses.
1549+
// By return undefined, the getSymbolOfEntityNameOrPropertyAccessExpression will attempt to checkPropertyAccessExpression to resolve symbol.
15501550
// i.e class C extends foo()./*do language service operation here*/B {}
15511551
return isEntityNameExpression(name.expression) ?
15521552
resolveEntityName(name.expression as EntityNameOrEntityNameExpression, meaning, ignoreErrors, dontResolveAlias, location) :

tests/baselines/reference/emitClassDeclarationWithPropertyAccessInHeritageClause1.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
//// [emitClassDeclarationWithPropertyAccessInHeritageClause1.ts]
2-
interface I {}
3-
interface CTor {
4-
new (hour: number, minute: number): I
5-
}
6-
var x: {
7-
B : CTor
8-
};
92
class B {}
103
function foo() {
114
return {B: B};
@@ -23,7 +16,6 @@ var __extends = (this && this.__extends) || (function () {
2316
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2417
};
2518
})();
26-
var x;
2719
var B = (function () {
2820
function B() {
2921
}
Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,17 @@
11
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAccessInHeritageClause1.ts ===
2-
interface I {}
3-
>I : Symbol(I, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 0))
4-
5-
interface CTor {
6-
>CTor : Symbol(CTor, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 14))
7-
8-
new (hour: number, minute: number): I
9-
>hour : Symbol(hour, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 2, 9))
10-
>minute : Symbol(minute, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 2, 22))
11-
>I : Symbol(I, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 0))
12-
}
13-
var x: {
14-
>x : Symbol(x, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 4, 3))
15-
16-
B : CTor
17-
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 4, 8))
18-
>CTor : Symbol(CTor, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 14))
19-
20-
};
212
class B {}
22-
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 6, 2))
3+
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 0))
234

245
function foo() {
25-
>foo : Symbol(foo, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 7, 10))
6+
>foo : Symbol(foo, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 10))
267

278
return {B: B};
28-
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 9, 12))
29-
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 6, 2))
9+
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 2, 12))
10+
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 0))
3011
}
3112
class C extends (foo()).B {}
32-
>C : Symbol(C, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 10, 1))
33-
>(foo()).B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 9, 12))
34-
>foo : Symbol(foo, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 7, 10))
35-
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 9, 12))
13+
>C : Symbol(C, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 3, 1))
14+
>(foo()).B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 2, 12))
15+
>foo : Symbol(foo, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 0, 10))
16+
>B : Symbol(B, Decl(emitClassDeclarationWithPropertyAccessInHeritageClause1.ts, 2, 12))
3617

tests/baselines/reference/emitClassDeclarationWithPropertyAccessInHeritageClause1.types

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,4 @@
11
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAccessInHeritageClause1.ts ===
2-
interface I {}
3-
>I : I
4-
5-
interface CTor {
6-
>CTor : CTor
7-
8-
new (hour: number, minute: number): I
9-
>hour : number
10-
>minute : number
11-
>I : I
12-
}
13-
var x: {
14-
>x : { B: CTor; }
15-
16-
B : CTor
17-
>B : CTor
18-
>CTor : CTor
19-
20-
};
212
class B {}
223
>B : B
234

tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAccessInHeritageClause1.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
interface I {}
2-
interface CTor {
3-
new (hour: number, minute: number): I
4-
}
5-
var x: {
6-
B : CTor
7-
};
81
class B {}
92
function foo() {
103
return {B: B};
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
/// <reference path="fourslash.ts" />
22

3-
//// interface I {}
4-
//// interface CTor {
5-
//// new (hour: number, minute: number): I
6-
//// }
7-
//// var x: {
8-
//// B : CTor
9-
//// };
103
//// class B {}
114
//// function foo() {
125
//// return {[|B|]: B};
136
//// }
147
//// class C extends (foo()).[|B|] {}
158
//// class C1 extends foo().[|B|] {}
169

17-
const [def, ref1, ref2] = test.ranges();
18-
verify.referencesOf(ref1, [def, ref1, ref2]);
19-
verify.referencesOf(ref2, [def, ref1, ref2]);
20-
verify.referencesOf(def, [def, ref1, ref2]);
10+
const ranges = test.ranges();
11+
for (const range of ranges) {
12+
verify.referencesOf(range, ranges);
13+
}

tests/cases/fourslash/gotoDefinitionPropertyAccessExpressionHeritageClause.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
/// <reference path='fourslash.ts' />
22

3-
//// interface I {}
4-
//// interface CTor {
5-
//// new (hour: number, minute: number): I
6-
//// }
7-
//// var x: {
8-
//// B : CTor
9-
//// };
103
//// class B {}
114
//// function foo() {
125
//// return {/*refB*/B: B};

tests/cases/fourslash/renamePropertyAccessExpressionHeritageClause.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
/// <reference path="fourslash.ts" />
22

3-
//// interface I {}
4-
//// interface CTor {
5-
//// new (hour: number, minute: number): I
6-
//// }
7-
//// var x: {
8-
//// B : CTor
9-
//// };
103
//// class B {}
114
//// function foo() {
125
//// return {[|B|]: B};

0 commit comments

Comments
 (0)