From b04b8d063cc895f3a31cb74f837df8c7039a29de Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Wed, 15 Jan 2020 07:30:00 +0100 Subject: [PATCH] =?UTF-8?q?fix(=5F=5Fextends):=20Use=C2=A0correct=C2=A0beh?= =?UTF-8?q?aviour=20with=C2=A0`null`=C2=A0prototype?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tslib.d.ts | 2 +- tslib.es6.js | 9 +++++++-- tslib.js | 9 +++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tslib.d.ts b/tslib.d.ts index 3ad370a..ceb97b4 100644 --- a/tslib.d.ts +++ b/tslib.d.ts @@ -12,7 +12,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ -export declare function __extends(d: Function, b: Function): void; +export declare function __extends(d: Function, b: Function | null): void; export declare function __assign(t: any, ...sources: any[]): any; export declare function __rest(t: any, propertyNames: (string | symbol)[]): any; export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; diff --git a/tslib.es6.js b/tslib.es6.js index bd73dce..96f574c 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -22,11 +22,16 @@ var extendStatics = function(d, b) { }; export function __extends(d, b) { - if (typeof b !== "function" && b !== null) + if (b === null) { + (d.prototype = Object.create(b)).constructor = d; + return; + } else if (typeof b !== "function") { 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 __()); + __.prototype = b.prototype; + d.prototype = new __(); } export var __assign = function() { diff --git a/tslib.js b/tslib.js index 4e2462e..5eb7910 100644 --- a/tslib.js +++ b/tslib.js @@ -66,11 +66,16 @@ 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) + if (b === null) { + (d.prototype = Object.create(b)).constructor = d; + return; + } else if (typeof b !== "function") { 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 __()); + __.prototype = b.prototype; + d.prototype = new __(); }; __assign = Object.assign || function (t) {