mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 01:33:15 -05:00
Merge pull request #3473 from randombk/bug-genericConstraintCrash
Fix crash with unmet generic constraints
This commit is contained in:
@@ -7275,8 +7275,8 @@ namespace ts {
|
||||
checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true);
|
||||
}
|
||||
else if (candidateForTypeArgumentError) {
|
||||
if (!isTaggedTemplate && (<CallExpression>node).typeArguments) {
|
||||
checkTypeArguments(candidateForTypeArgumentError, (<CallExpression>node).typeArguments, [], /*reportErrors*/ true)
|
||||
if (!isTaggedTemplate && typeArguments) {
|
||||
checkTypeArguments(candidateForTypeArgumentError, typeArguments, [], /*reportErrors*/ true)
|
||||
}
|
||||
else {
|
||||
Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0);
|
||||
|
||||
24
tests/baselines/reference/genericTypeConstraints.errors.txt
Normal file
24
tests/baselines/reference/genericTypeConstraints.errors.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
tests/cases/compiler/genericTypeConstraints.ts(9,27): error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
|
||||
Property 'fooMethod' is missing in type 'FooExtended'.
|
||||
tests/cases/compiler/genericTypeConstraints.ts(9,31): error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/genericTypeConstraints.ts (2 errors) ====
|
||||
class Foo {
|
||||
fooMethod() {}
|
||||
}
|
||||
|
||||
class FooExtended { }
|
||||
|
||||
class Bar<T extends Foo> { }
|
||||
|
||||
class BarExtended extends Bar<FooExtended> {
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
|
||||
!!! error TS2344: Property 'fooMethod' is missing in type 'FooExtended'.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
45
tests/baselines/reference/genericTypeConstraints.js
Normal file
45
tests/baselines/reference/genericTypeConstraints.js
Normal file
@@ -0,0 +1,45 @@
|
||||
//// [genericTypeConstraints.ts]
|
||||
class Foo {
|
||||
fooMethod() {}
|
||||
}
|
||||
|
||||
class FooExtended { }
|
||||
|
||||
class Bar<T extends Foo> { }
|
||||
|
||||
class BarExtended extends Bar<FooExtended> {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
//// [genericTypeConstraints.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
Foo.prototype.fooMethod = function () { };
|
||||
return Foo;
|
||||
})();
|
||||
var FooExtended = (function () {
|
||||
function FooExtended() {
|
||||
}
|
||||
return FooExtended;
|
||||
})();
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
}
|
||||
return Bar;
|
||||
})();
|
||||
var BarExtended = (function (_super) {
|
||||
__extends(BarExtended, _super);
|
||||
function BarExtended() {
|
||||
_super.call(this);
|
||||
}
|
||||
return BarExtended;
|
||||
})(Bar);
|
||||
13
tests/cases/compiler/genericTypeConstraints.ts
Normal file
13
tests/cases/compiler/genericTypeConstraints.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
class Foo {
|
||||
fooMethod() {}
|
||||
}
|
||||
|
||||
class FooExtended { }
|
||||
|
||||
class Bar<T extends Foo> { }
|
||||
|
||||
class BarExtended extends Bar<FooExtended> {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user