Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Runtime error for two classes in one ts file. #8572

Closed
vitaliy-leschenko opened this issue May 12, 2016 · 3 comments
Closed

Runtime error for two classes in one ts file. #8572

vitaliy-leschenko opened this issue May 12, 2016 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@vitaliy-leschenko
Copy link

TypeScript Version:

1.8.10

Code

export class BaseLayoutModel extends BaseModel {
    constructor(attributes?: any, options?: any) {
        super(attributes, options);
    }
}

export class BaseModel extends Backbone.Model {
    constructor(attributes?: any, options?: any) {
        super(attributes, options);
    }

    destroy(options?: Backbone.ModelDestroyOptions): any {
        const opts = _.extend({
            contentType: "application/json",
            dataType: "text"
        }, options || {});
        super.destroy(opts);
    }
}

Expected behavior:

Actual behavior:
Runtime error. BaseModel is undefined

@zpdDG4gta8XKpMCd
Copy link

in your code BaseModel is declared lexically after BaseLayoutModel

in the compiled code it means that BaseModel is used before being initialized

try swapping the declarations (BaseModel class should come first)

@vitaliy-leschenko
Copy link
Author

vitaliy-leschenko commented May 12, 2016

I know about “why it failed”. But this code translated to JS without any errors.

@Arnavion
Copy link
Contributor

Duplicate of #4341 and #5207 which should be fixed by #4343

@mhegazy mhegazy closed this as completed May 12, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label May 12, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants