samedi 9 avril 2016

TypeScript: TypeError b is undefined

When I am trying to create inheritance in TypeScript the following JavaScript gets generated:

var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};

Which looks exactly like the one that should be generated. But the Problem is that on execution Firefox gives this Message:

TypeError: b is undefined

In Chrome the error looks a bit different, but seems to be of the same origin:

Uncaught TypeError: Cannot read property 'prototype' of undefined

The implementation in typescript looks like this

class Movie extends Medium {
//Some Fields
    constructor(title: string, description: string, ageRestriction: AgeRestriction, isBluRay: boolean) {
        super(title, description, ageRestriction);
        this.isBluRay = isBluRay;
    }
}

class Medium implements IMedium {
//Getters, Setters and Fields
    constructor(title: string, description: string, ageRestriction: AgeRestriction) {
        this.title = title;
        this.description = description;
        this.ageRestriction = ageRestriction;
    }
}

I have already tried various ways of compiling the code, but the result is always the same




Aucun commentaire:

Enregistrer un commentaire