Skip to content

Commit f073ee5

Browse files
committed
fix(__extends): Use correct behaviour with null prototype
1 parent 3cf8ae0 commit f073ee5

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

tslib.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
1212
See the Apache Version 2.0 License for specific language governing permissions
1313
and limitations under the License.
1414
***************************************************************************** */
15-
export declare function __extends(d: Function, b: Function): void;
15+
export declare function __extends(d: Function, b: Function | null): void;
1616
export declare function __assign(t: any, ...sources: any[]): any;
1717
export declare function __rest(t: any, propertyNames: (string | symbol)[]): any;
1818
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;

tslib.es6.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ var extendStatics = function(d, b) {
2222
};
2323

2424
export function __extends(d, b) {
25+
if (b === null) {
26+
d.prototype = Object.create(b);
27+
return;
28+
}
2529
extendStatics(d, b);
2630
function __() { this.constructor = d; }
27-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31+
__.prototype = b.prototype;
32+
d.prototype = new __();
2833
}
2934

3035
export var __assign = function() {

tslib.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,14 @@ var __classPrivateFieldSet;
6464
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6565

6666
__extends = function (d, b) {
67+
if (b === null) {
68+
d.prototype = Object.create(b);
69+
return;
70+
}
6771
extendStatics(d, b);
6872
function __() { this.constructor = d; }
69-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
73+
__.prototype = b.prototype;
74+
d.prototype = new __();
7075
};
7176

7277
__assign = Object.assign || function (t) {

0 commit comments

Comments
 (0)