diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index e5e781b8a1771..15bfd676e77a2 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -1,4 +1,4 @@
-///
+///
///
/* @internal */
@@ -3986,16 +3986,13 @@ namespace ts {
function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] {
const typeArgCount = length(typeArgumentNodes);
return filter(getSignaturesOfType(type, SignatureKind.Construct),
- sig => typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= length(sig.typeParameters));
+ sig => typeArgCount <= length(sig.typeParameters));
}
function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] {
let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes);
- if (typeArgumentNodes) {
- const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode);
- signatures = map(signatures, sig => getSignatureInstantiation(sig, typeArguments));
- }
- return signatures;
+ const typeArguments = length(typeArgumentNodes) ? map(typeArgumentNodes, getTypeFromTypeNode): undefined
+ return signatures && map(signatures, sig => length(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments) : sig);
}
/**
@@ -4587,9 +4584,8 @@ namespace ts {
const typeArgCount = length(typeArguments);
const result: Signature[] = [];
for (const baseSig of baseSignatures) {
- const minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters);
const typeParamCount = length(baseSig.typeParameters);
- if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) {
+ if (typeArgCount <= typeParamCount) {
const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, /*errorNode*/ undefined)) : cloneSignature(baseSig);
sig.typeParameters = classType.localTypeParameters;
sig.resolvedReturnType = classType;
diff --git a/tests/baselines/reference/classExtendingClassLikeType.errors.txt b/tests/baselines/reference/classExtendingClassLikeType.errors.txt
index 5edefd78ec514..e37d0b5498b81 100644
--- a/tests/baselines/reference/classExtendingClassLikeType.errors.txt
+++ b/tests/baselines/reference/classExtendingClassLikeType.errors.txt
@@ -1,9 +1,11 @@
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(7,18): error TS2689: Cannot extend an interface 'Base'. Did you mean 'implements'?
+tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(19,18): error TS2510: Base constructors must all have the same return type.
+tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(27,18): error TS2510: Base constructors must all have the same return type.
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(45,18): error TS2508: No base constructor has the specified number of type arguments.
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(56,18): error TS2510: Base constructors must all have the same return type.
-==== tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts (3 errors) ====
+==== tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts (5 errors) ====
interface Base {
x: T;
y: U;
@@ -25,6 +27,8 @@ tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts
declare function getBase(): BaseConstructor;
class D1 extends getBase() {
+ ~~~~~~~~~
+!!! error TS2510: Base constructors must all have the same return type.
constructor() {
super("abc", "def");
this.x = "x";
@@ -33,6 +37,8 @@ tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts
}
class D2 extends getBase() {
+ ~~~~~~~~~
+!!! error TS2510: Base constructors must all have the same return type.
constructor() {
super(10);
super(10, 20);
diff --git a/tests/baselines/reference/extendingFromGenericTypeWithMissingTypeArguments.js b/tests/baselines/reference/extendingFromGenericTypeWithMissingTypeArguments.js
new file mode 100644
index 0000000000000..b5ca6e03cc7b3
--- /dev/null
+++ b/tests/baselines/reference/extendingFromGenericTypeWithMissingTypeArguments.js
@@ -0,0 +1,68 @@
+//// [extendingFromGenericTypeWithMissingTypeArguments.ts]
+class C1 {
+ c1_prop: T;
+}
+class D1 extends C1 {
+ d1_prop: number;
+}
+
+var d1 = new D1();
+d1.c1_prop; // any
+d1.d1_prop;
+
+
+class C2 {
+ constructor(a: T) { }
+ c1_prop: T;
+}
+class D2 extends C2 {
+ d1_prop: number;
+}
+
+var d1 = new D2(2);
+d1.c1_prop; // any
+d1.d1_prop;
+
+
+
+//// [extendingFromGenericTypeWithMissingTypeArguments.js]
+var __extends = (this && this.__extends) || (function () {
+ var extendStatics = Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+ return function (d, b) {
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+ };
+})();
+var C1 = (function () {
+ function C1() {
+ }
+ return C1;
+}());
+var D1 = (function (_super) {
+ __extends(D1, _super);
+ function D1() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ return D1;
+}(C1));
+var d1 = new D1();
+d1.c1_prop; // any
+d1.d1_prop;
+var C2 = (function () {
+ function C2(a) {
+ }
+ return C2;
+}());
+var D2 = (function (_super) {
+ __extends(D2, _super);
+ function D2() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ return D2;
+}(C2));
+var d1 = new D2(2);
+d1.c1_prop; // any
+d1.d1_prop;
diff --git a/tests/baselines/reference/extendingFromGenericTypeWithMissingTypeArguments.symbols b/tests/baselines/reference/extendingFromGenericTypeWithMissingTypeArguments.symbols
new file mode 100644
index 0000000000000..52bccc7861e6e
--- /dev/null
+++ b/tests/baselines/reference/extendingFromGenericTypeWithMissingTypeArguments.symbols
@@ -0,0 +1,67 @@
+=== tests/cases/compiler/extendingFromGenericTypeWithMissingTypeArguments.ts ===
+class C1 {
+>C1 : Symbol(C1, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 0, 0))
+>T : Symbol(T, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 0, 9))
+
+ c1_prop: T;
+>c1_prop : Symbol(C1.c1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 0, 13))
+>T : Symbol(T, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 0, 9))
+}
+class D1 extends C1 {
+>D1 : Symbol(D1, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 2, 1))
+>C1 : Symbol(C1, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 0, 0))
+
+ d1_prop: number;
+>d1_prop : Symbol(D1.d1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 3, 21))
+}
+
+var d1 = new D1();
+>d1 : Symbol(d1, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 7, 3), Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 20, 3))
+>D1 : Symbol(D1, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 2, 1))
+
+d1.c1_prop; // any
+>d1.c1_prop : Symbol(C1.c1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 0, 13))
+>d1 : Symbol(d1, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 7, 3), Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 20, 3))
+>c1_prop : Symbol(C1.c1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 0, 13))
+
+d1.d1_prop;
+>d1.d1_prop : Symbol(D1.d1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 3, 21))
+>d1 : Symbol(d1, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 7, 3), Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 20, 3))
+>d1_prop : Symbol(D1.d1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 3, 21))
+
+
+class C2 {
+>C2 : Symbol(C2, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 9, 11))
+>T : Symbol(T, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 12, 9))
+
+ constructor(a: T) { }
+>a : Symbol(a, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 13, 16))
+>T : Symbol(T, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 12, 9))
+
+ c1_prop: T;
+>c1_prop : Symbol(C2.c1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 13, 25))
+>T : Symbol(T, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 12, 9))
+}
+class D2 extends C2 {
+>D2 : Symbol(D2, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 15, 1))
+>C2 : Symbol(C2, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 9, 11))
+
+ d1_prop: number;
+>d1_prop : Symbol(D2.d1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 16, 21))
+}
+
+var d1 = new D2(2);
+>d1 : Symbol(d1, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 7, 3), Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 20, 3))
+>D2 : Symbol(D2, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 15, 1))
+
+d1.c1_prop; // any
+>d1.c1_prop : Symbol(C1.c1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 0, 13))
+>d1 : Symbol(d1, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 7, 3), Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 20, 3))
+>c1_prop : Symbol(C1.c1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 0, 13))
+
+d1.d1_prop;
+>d1.d1_prop : Symbol(D1.d1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 3, 21))
+>d1 : Symbol(d1, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 7, 3), Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 20, 3))
+>d1_prop : Symbol(D1.d1_prop, Decl(extendingFromGenericTypeWithMissingTypeArguments.ts, 3, 21))
+
+
diff --git a/tests/baselines/reference/extendingFromGenericTypeWithMissingTypeArguments.types b/tests/baselines/reference/extendingFromGenericTypeWithMissingTypeArguments.types
new file mode 100644
index 0000000000000..f1a946837bdad
--- /dev/null
+++ b/tests/baselines/reference/extendingFromGenericTypeWithMissingTypeArguments.types
@@ -0,0 +1,70 @@
+=== tests/cases/compiler/extendingFromGenericTypeWithMissingTypeArguments.ts ===
+class C1 {
+>C1 : C1
+>T : T
+
+ c1_prop: T;
+>c1_prop : T
+>T : T
+}
+class D1 extends C1 {
+>D1 : D1
+>C1 : C1
+
+ d1_prop: number;
+>d1_prop : number
+}
+
+var d1 = new D1();
+>d1 : D1
+>new D1() : D1
+>D1 : typeof D1
+
+d1.c1_prop; // any
+>d1.c1_prop : any
+>d1 : D1
+>c1_prop : any
+
+d1.d1_prop;
+>d1.d1_prop : number
+>d1 : D1
+>d1_prop : number
+
+
+class C2 {
+>C2 : C2
+>T : T
+
+ constructor(a: T) { }
+>a : T
+>T : T
+
+ c1_prop: T;
+>c1_prop : T
+>T : T
+}
+class D2 extends C2 {
+>D2 : D2
+>C2 : C2
+
+ d1_prop: number;
+>d1_prop : number
+}
+
+var d1 = new D2(2);
+>d1 : D1
+>new D2(2) : D2
+>D2 : typeof D2
+>2 : 2
+
+d1.c1_prop; // any
+>d1.c1_prop : any
+>d1 : D1
+>c1_prop : any
+
+d1.d1_prop;
+>d1.d1_prop : number
+>d1 : D1
+>d1_prop : number
+
+
diff --git a/tests/baselines/reference/recursiveBaseConstructorCreation3.errors.txt b/tests/baselines/reference/recursiveBaseConstructorCreation3.errors.txt
index f14a7838860a5..f12084493aaec 100644
--- a/tests/baselines/reference/recursiveBaseConstructorCreation3.errors.txt
+++ b/tests/baselines/reference/recursiveBaseConstructorCreation3.errors.txt
@@ -1,8 +1,7 @@
tests/cases/compiler/recursiveBaseConstructorCreation3.ts(6,27): error TS2707: Type parameter 'T' implicitly has type 'any' because it was not supplied.
-tests/cases/compiler/recursiveBaseConstructorCreation3.ts(9,11): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
-==== tests/cases/compiler/recursiveBaseConstructorCreation3.ts (2 errors) ====
+==== tests/cases/compiler/recursiveBaseConstructorCreation3.ts (1 errors) ====
declare class base {
}
declare class abc extends base {
@@ -13,7 +12,5 @@ tests/cases/compiler/recursiveBaseConstructorCreation3.ts(9,11): error TS2351: C
!!! error TS2707: Type parameter 'T' implicitly has type 'any' because it was not supplied.
}
- var bar = new xyz(); // Error: Invalid 'new' expression.
- ~~~~~~~~~
-!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
+ var bar = new xyz();
var r: xyz = bar.foo;
\ No newline at end of file
diff --git a/tests/baselines/reference/recursiveBaseConstructorCreation3.js b/tests/baselines/reference/recursiveBaseConstructorCreation3.js
index cd2efb703a0ec..add4c3f084a3c 100644
--- a/tests/baselines/reference/recursiveBaseConstructorCreation3.js
+++ b/tests/baselines/reference/recursiveBaseConstructorCreation3.js
@@ -7,9 +7,9 @@ declare class abc extends base {
declare class xyz extends abc {
}
-var bar = new xyz(); // Error: Invalid 'new' expression.
+var bar = new xyz();
var r: xyz = bar.foo;
//// [recursiveBaseConstructorCreation3.js]
-var bar = new xyz(); // Error: Invalid 'new' expression.
+var bar = new xyz();
var r = bar.foo;
diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.errors.txt b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.errors.txt
index 2686f2e59c0ca..33327ea0d43e1 100644
--- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.errors.txt
+++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.errors.txt
@@ -1,9 +1,7 @@
tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts(8,17): error TS2707: Type parameter 'T2' implicitly has type 'any' because it was not supplied.
-tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts(9,21): error TS2346: Supplied parameters do not match any signature of call target.
-tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts(9,27): error TS7006: Parameter 'value' implicitly has an 'any' type.
-==== tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts (3 errors) ====
+==== tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts (1 errors) ====
class A {
constructor(private map: (value: T1) => T2) {
@@ -15,8 +13,4 @@ tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrec
~~~~~~~~~
!!! error TS2707: Type parameter 'T2' implicitly has type 'any' because it was not supplied.
constructor() { super(value => String(value)); }
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! error TS2346: Supplied parameters do not match any signature of call target.
- ~~~~~
-!!! error TS7006: Parameter 'value' implicitly has an 'any' type.
}
\ No newline at end of file
diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.errors.txt b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.errors.txt
index efe8f96edd569..79e110cbe947d 100644
--- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.errors.txt
+++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.errors.txt
@@ -1,10 +1,8 @@
tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts(8,17): error TS2707: Type parameter 'T1' implicitly has type 'any' because it was not supplied.
tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts(8,17): error TS2707: Type parameter 'T2' implicitly has type 'any' because it was not supplied.
-tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts(9,21): error TS2346: Supplied parameters do not match any signature of call target.
-tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts(9,27): error TS7006: Parameter 'value' implicitly has an 'any' type.
-==== tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts (4 errors) ====
+==== tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts (2 errors) ====
class A {
constructor(private map: (value: T1) => T2) {
@@ -18,8 +16,4 @@ tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeAr
~
!!! error TS2707: Type parameter 'T2' implicitly has type 'any' because it was not supplied.
constructor() { super(value => String(value)); }
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! error TS2346: Supplied parameters do not match any signature of call target.
- ~~~~~
-!!! error TS7006: Parameter 'value' implicitly has an 'any' type.
}
\ No newline at end of file
diff --git a/tests/cases/compiler/extendingFromGenericTypeWithMissingTypeArguments.ts b/tests/cases/compiler/extendingFromGenericTypeWithMissingTypeArguments.ts
new file mode 100644
index 0000000000000..1358b000c5b4b
--- /dev/null
+++ b/tests/cases/compiler/extendingFromGenericTypeWithMissingTypeArguments.ts
@@ -0,0 +1,24 @@
+class C1 {
+ c1_prop: T;
+}
+class D1 extends C1 {
+ d1_prop: number;
+}
+
+var d1 = new D1();
+d1.c1_prop; // any
+d1.d1_prop;
+
+
+class C2 {
+ constructor(a: T) { }
+ c1_prop: T;
+}
+class D2 extends C2 {
+ d1_prop: number;
+}
+
+var d1 = new D2(2);
+d1.c1_prop; // any
+d1.d1_prop;
+
diff --git a/tests/cases/compiler/recursiveBaseConstructorCreation3.ts b/tests/cases/compiler/recursiveBaseConstructorCreation3.ts
index f06d27599503a..9e3ff968fb774 100644
--- a/tests/cases/compiler/recursiveBaseConstructorCreation3.ts
+++ b/tests/cases/compiler/recursiveBaseConstructorCreation3.ts
@@ -7,5 +7,5 @@ declare class abc extends base {
declare class xyz extends abc {
}
-var bar = new xyz(); // Error: Invalid 'new' expression.
+var bar = new xyz();
var r: xyz = bar.foo;
\ No newline at end of file