Skip to content

Commit 1564049

Browse files
committed
Code review comments
1 parent 15f07e6 commit 1564049

4 files changed

Lines changed: 108 additions & 4 deletions

File tree

src/compiler/checker.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16247,10 +16247,8 @@ namespace ts {
1624716247
function writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) {
1624816248
const classType = <InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(node));
1624916249
resolveBaseTypesOfClass(classType);
16250-
const baseType = classType.resolvedBaseTypes[0];
16251-
if (baseType) {
16252-
getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags);
16253-
}
16250+
const baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType;
16251+
getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags);
1625416252
}
1625516253

1625616254
function hasGlobalName(name: string): boolean {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
tests/cases/compiler/declarationEmit_expressionInExtends4.ts(2,10): error TS4060: Return type of exported function has or is using private name 'D'.
2+
tests/cases/compiler/declarationEmit_expressionInExtends4.ts(6,17): error TS2315: Type 'D' is not generic.
3+
tests/cases/compiler/declarationEmit_expressionInExtends4.ts(10,18): error TS2304: Cannot find name 'SomeUndefinedFunction'.
4+
tests/cases/compiler/declarationEmit_expressionInExtends4.ts(15,18): error TS2304: Cannot find name 'SomeUndefinedFunction'.
5+
tests/cases/compiler/declarationEmit_expressionInExtends4.ts(15,18): error TS4020: Extends clause of exported class 'C3' has or is using private name 'SomeUndefinedFunction'.
6+
7+
8+
==== tests/cases/compiler/declarationEmit_expressionInExtends4.ts (5 errors) ====
9+
10+
function getSomething() {
11+
~~~~~~~~~~~~
12+
!!! error TS4060: Return type of exported function has or is using private name 'D'.
13+
return class D { }
14+
}
15+
16+
class C extends getSomething()<number, string> {
17+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18+
!!! error TS2315: Type 'D' is not generic.
19+
20+
}
21+
22+
class C2 extends SomeUndefinedFunction()<number, string> {
23+
~~~~~~~~~~~~~~~~~~~~~
24+
!!! error TS2304: Cannot find name 'SomeUndefinedFunction'.
25+
26+
}
27+
28+
29+
class C3 extends SomeUndefinedFunction {
30+
~~~~~~~~~~~~~~~~~~~~~
31+
!!! error TS2304: Cannot find name 'SomeUndefinedFunction'.
32+
~~~~~~~~~~~~~~~~~~~~~
33+
!!! error TS4020: Extends clause of exported class 'C3' has or is using private name 'SomeUndefinedFunction'.
34+
35+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//// [declarationEmit_expressionInExtends4.ts]
2+
3+
function getSomething() {
4+
return class D { }
5+
}
6+
7+
class C extends getSomething()<number, string> {
8+
9+
}
10+
11+
class C2 extends SomeUndefinedFunction()<number, string> {
12+
13+
}
14+
15+
16+
class C3 extends SomeUndefinedFunction {
17+
18+
}
19+
20+
//// [declarationEmit_expressionInExtends4.js]
21+
var __extends = (this && this.__extends) || function (d, b) {
22+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
23+
function __() { this.constructor = d; }
24+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25+
};
26+
function getSomething() {
27+
return (function () {
28+
function D() {
29+
}
30+
return D;
31+
}());
32+
}
33+
var C = (function (_super) {
34+
__extends(C, _super);
35+
function C() {
36+
_super.apply(this, arguments);
37+
}
38+
return C;
39+
}(getSomething()));
40+
var C2 = (function (_super) {
41+
__extends(C2, _super);
42+
function C2() {
43+
_super.apply(this, arguments);
44+
}
45+
return C2;
46+
}(SomeUndefinedFunction()));
47+
var C3 = (function (_super) {
48+
__extends(C3, _super);
49+
function C3() {
50+
_super.apply(this, arguments);
51+
}
52+
return C3;
53+
}(SomeUndefinedFunction));
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// @declaration: true
2+
3+
function getSomething() {
4+
return class D { }
5+
}
6+
7+
class C extends getSomething()<number, string> {
8+
9+
}
10+
11+
class C2 extends SomeUndefinedFunction()<number, string> {
12+
13+
}
14+
15+
16+
class C3 extends SomeUndefinedFunction {
17+
18+
}

0 commit comments

Comments
 (0)