Skip to content

Commit b04b8d0

Browse files
committed
fix(__extends): Use correct behaviour with null prototype
1 parent 54a056a commit b04b8d0

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

tslib.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1212
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1313
PERFORMANCE OF THIS SOFTWARE.
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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ var extendStatics = function(d, b) {
2222
};
2323

2424
export function __extends(d, b) {
25-
if (typeof b !== "function" && b !== null)
25+
if (b === null) {
26+
(d.prototype = Object.create(b)).constructor = d;
27+
return;
28+
} else if (typeof b !== "function") {
2629
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
30+
}
2731
extendStatics(d, b);
2832
function __() { this.constructor = d; }
29-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33+
__.prototype = b.prototype;
34+
d.prototype = new __();
3035
}
3136

3237
export var __assign = function() {

tslib.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,16 @@ var __createBinding;
6666
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6767

6868
__extends = function (d, b) {
69-
if (typeof b !== "function" && b !== null)
69+
if (b === null) {
70+
(d.prototype = Object.create(b)).constructor = d;
71+
return;
72+
} else if (typeof b !== "function") {
7073
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
74+
}
7175
extendStatics(d, b);
7276
function __() { this.constructor = d; }
73-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
77+
__.prototype = b.prototype;
78+
d.prototype = new __();
7479
};
7580

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

0 commit comments

Comments
 (0)