From cff487d37b90744c080f7e4d24eb1f9cf7a4a6a2 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 1 Dec 2020 21:10:06 -0500 Subject: [PATCH] Ported runtime TypeError for non-function, non-null __extends (#138) --- tslib.es6.js | 2 ++ tslib.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tslib.es6.js b/tslib.es6.js index c60aa60..bae9845 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -22,6 +22,8 @@ var extendStatics = function(d, b) { }; export function __extends(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 __()); diff --git a/tslib.js b/tslib.js index fcf619a..b56c529 100644 --- a/tslib.js +++ b/tslib.js @@ -65,6 +65,8 @@ var __createBinding; function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; __extends = 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 __());