javascript - Typescript error runtime error: Cannot read property 'prototype' of undefined when extending -


so i'm getting above error in console. it's caused _super being undefined when it's passed __extends (in generated .js).

here's test code can used reproduce error:

//this entirety of file test.ts module test {     export class test1 {         public name: string;         public number: number;          constructor() {          }     } } 

then in separate file have class inherits one:

/// <reference path="test.ts" /> module test {     export class test2 extends test1 {         constructor() {             super();         }     } } 

the <reference path... shouldn't needed (and isn't), added see if helped (it didn't).

the files included in correct order (test.ts test2.ts) via bundleconfig (running or without optimisations doesn't have effect).

i being giant noob, haven't slightest clue i've messed up. other instances of problem i've found online folks using command line compiler combine multiple typescript files 1 single file. i'm using bundler that, when don't combine them, exact same issue.

please me, i'm @ wits end!

as requested, here's compiled javascript: test.js:

//this entirety of file test.ts var test; (function (test) {     var test1 = (function () {         function test1() {         }         return test1;     })();     test.test1 = test1; })(test || (test = {})); //# sourcemappingurl=test.js.map 

test2.js:

var __extends = this.__extends || function (d, b) {     (var p in b) if (b.hasownproperty(p)) d[p] = b[p];     function __() { this.constructor = d; }     __.prototype = b.prototype;     d.prototype = new __(); }; /// <reference path="test.ts" /> var test; (function (test) {     var test2 = (function (_super) {         __extends(test2, _super);         function test2() {             _super.call(this);         }         return test2;     })(test.test1);     test.test2 = test2; })(test || (test = {})); //# sourcemappingurl=test2.js.map 

possible reasons happening:

  1. quadruple-check bundleconfig concatenating files in correct order. far common cause of error.
  2. verify don't have top-level export directives in test.ts. cause file become external module , test1 no longer visible.

failing that, should post emitted javascript question can diagnose what's causing issue.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -