Skip to content

Commit

Permalink
Merge pull request #37283 from JoshuaKGoldberg/extends-constructor-ty…
Browse files Browse the repository at this point in the history
…peerror

Added runtime TypeError for non-function, non-null __extends
  • Loading branch information
rbuckton authored Dec 2, 2020
2 parents 5581009 + 943b350 commit e012417
Show file tree
Hide file tree
Showing 821 changed files with 2,295 additions and 635 deletions.
2 changes: 2 additions & 0 deletions src/compiler/factory/emitHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ namespace ts {
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/abstractClassInLocalScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/abstractProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/abstractPropertyInConstructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/abstractPropertyNegative.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/accessOverriddenBaseClassMember1.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/accessorsOverrideProperty7.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/aliasUsageInAccessorsOfClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/aliasUsageInArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/aliasUsageInFunctionExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/aliasUsageInGenericFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/aliasUsageInIndexerOfClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/aliasUsageInObjectLiteral.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/aliasUsageInOrExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand All @@ -70,6 +72,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/aliasUsageInVarAssignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/ambiguousOverloadResolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
4 changes: 4 additions & 0 deletions tests/baselines/reference/anonClassDeclarationEmitIsAnon.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down Expand Up @@ -84,6 +86,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/apparentTypeSubtyping.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/apparentTypeSupertype.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/arrayAssignmentTest1.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/arrayAssignmentTest2.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/arrayBestCommonTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/arrayLiteralTypeInference.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/arrayLiterals.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/arrowFunctionContexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/assertionTypePredicates1.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ var __extends = (this && this.__extends) || (function () {
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down
Loading

0 comments on commit e012417

Please sign in to comment.