Skip to content

Commit efeb135

Browse files
Revert #54442 and add a testcase (#61955)
1 parent 02672d2 commit efeb135

7 files changed

+125
-1
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36414,7 +36414,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3641436414
// reorderCandidates fills up the candidates array directly
3641536415
reorderCandidates(signatures, candidates, callChainFlags);
3641636416
if (!isJsxOpenFragment) {
36417-
Debug.assert(candidates.length, "Revert #54442 and add a testcase with whatever triggered this");
36417+
if (!candidates.length) {
36418+
if (reportErrors) {
36419+
diagnostics.add(getDiagnosticForCallNode(node, Diagnostics.Call_target_does_not_contain_any_signatures));
36420+
}
36421+
return resolveErrorCall(node);
36422+
}
3641836423
}
3641936424
const args = getEffectiveCallArguments(node);
3642036425

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,10 @@
20802080
"category": "Error",
20812081
"code": 2345
20822082
},
2083+
"Call target does not contain any signatures.": {
2084+
"category": "Error",
2085+
"code": 2346
2086+
},
20832087
"Untyped function calls may not accept type arguments.": {
20842088
"category": "Error",
20852089
"code": 2347
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
interfaceMergeWithNonGenericTypeArguments.ts(4,34): error TS2315: Type 'SomeBaseClass' is not generic.
2+
interfaceMergeWithNonGenericTypeArguments.ts(6,3): error TS2346: Call target does not contain any signatures.
3+
4+
5+
==== interfaceMergeWithNonGenericTypeArguments.ts (2 errors) ====
6+
export class SomeBaseClass { }
7+
export interface SomeInterface { }
8+
export interface MergedClass extends SomeInterface { }
9+
export class MergedClass extends SomeBaseClass<any> {
10+
~~~~~~~~~~~~~~~~~~
11+
!!! error TS2315: Type 'SomeBaseClass' is not generic.
12+
public constructor() {
13+
super();
14+
~~~~~
15+
!!! error TS2346: Call target does not contain any signatures.
16+
}
17+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//// [tests/cases/compiler/interfaceMergeWithNonGenericTypeArguments.ts] ////
2+
3+
//// [interfaceMergeWithNonGenericTypeArguments.ts]
4+
export class SomeBaseClass { }
5+
export interface SomeInterface { }
6+
export interface MergedClass extends SomeInterface { }
7+
export class MergedClass extends SomeBaseClass<any> {
8+
public constructor() {
9+
super();
10+
}
11+
}
12+
13+
//// [interfaceMergeWithNonGenericTypeArguments.js]
14+
"use strict";
15+
var __extends = (this && this.__extends) || (function () {
16+
var extendStatics = function (d, b) {
17+
extendStatics = Object.setPrototypeOf ||
18+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
20+
return extendStatics(d, b);
21+
};
22+
return function (d, b) {
23+
if (typeof b !== "function" && b !== null)
24+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
25+
extendStatics(d, b);
26+
function __() { this.constructor = d; }
27+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28+
};
29+
})();
30+
Object.defineProperty(exports, "__esModule", { value: true });
31+
exports.MergedClass = exports.SomeBaseClass = void 0;
32+
var SomeBaseClass = /** @class */ (function () {
33+
function SomeBaseClass() {
34+
}
35+
return SomeBaseClass;
36+
}());
37+
exports.SomeBaseClass = SomeBaseClass;
38+
var MergedClass = /** @class */ (function (_super) {
39+
__extends(MergedClass, _super);
40+
function MergedClass() {
41+
return _super.call(this) || this;
42+
}
43+
return MergedClass;
44+
}(SomeBaseClass));
45+
exports.MergedClass = MergedClass;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [tests/cases/compiler/interfaceMergeWithNonGenericTypeArguments.ts] ////
2+
3+
=== interfaceMergeWithNonGenericTypeArguments.ts ===
4+
export class SomeBaseClass { }
5+
>SomeBaseClass : Symbol(SomeBaseClass, Decl(interfaceMergeWithNonGenericTypeArguments.ts, 0, 0))
6+
7+
export interface SomeInterface { }
8+
>SomeInterface : Symbol(SomeInterface, Decl(interfaceMergeWithNonGenericTypeArguments.ts, 0, 30))
9+
10+
export interface MergedClass extends SomeInterface { }
11+
>MergedClass : Symbol(MergedClass, Decl(interfaceMergeWithNonGenericTypeArguments.ts, 1, 34), Decl(interfaceMergeWithNonGenericTypeArguments.ts, 2, 54))
12+
>SomeInterface : Symbol(SomeInterface, Decl(interfaceMergeWithNonGenericTypeArguments.ts, 0, 30))
13+
14+
export class MergedClass extends SomeBaseClass<any> {
15+
>MergedClass : Symbol(MergedClass, Decl(interfaceMergeWithNonGenericTypeArguments.ts, 1, 34), Decl(interfaceMergeWithNonGenericTypeArguments.ts, 2, 54))
16+
>SomeBaseClass : Symbol(SomeBaseClass, Decl(interfaceMergeWithNonGenericTypeArguments.ts, 0, 0))
17+
18+
public constructor() {
19+
super();
20+
>super : Symbol(SomeBaseClass, Decl(interfaceMergeWithNonGenericTypeArguments.ts, 0, 0))
21+
}
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [tests/cases/compiler/interfaceMergeWithNonGenericTypeArguments.ts] ////
2+
3+
=== interfaceMergeWithNonGenericTypeArguments.ts ===
4+
export class SomeBaseClass { }
5+
>SomeBaseClass : SomeBaseClass
6+
> : ^^^^^^^^^^^^^
7+
8+
export interface SomeInterface { }
9+
export interface MergedClass extends SomeInterface { }
10+
export class MergedClass extends SomeBaseClass<any> {
11+
>MergedClass : MergedClass
12+
> : ^^^^^^^^^^^
13+
>SomeBaseClass : SomeInterface
14+
> : ^^^^^^^^^^^^^
15+
16+
public constructor() {
17+
super();
18+
>super() : void
19+
> : ^^^^
20+
>super : typeof SomeBaseClass
21+
> : ^^^^^^^^^^^^^^^^^^^^
22+
}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export class SomeBaseClass { }
2+
export interface SomeInterface { }
3+
export interface MergedClass extends SomeInterface { }
4+
export class MergedClass extends SomeBaseClass<any> {
5+
public constructor() {
6+
super();
7+
}
8+
}

0 commit comments

Comments
 (0)