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

后端 未结 5 691
你的背包
你的背包 2021-01-01 09:31

So I\'m getting the above error in the console. It\'s caused by _super being undefined when it\'s passed to __extends (in the generated .js

5条回答
  •  甜味超标
    2021-01-01 09:47

    The order of the scripts on your HTML matters.

    Say you have a TypeScript file A.ts that defines an abstract class and a file B.ts with a class that extends the abstract class in A.ts

    export abstract class ShipmentsListScope implements IShipmentsListScope {

    A.ts:

    module app.example{
      "use strict";
    
      interface IMyInterface{
        // ..
      } 
      export abstract class MyAbstract implements IMyInterface{
        // ..
      }
    }
    

    B.ts

    module app.example{
        "use strict";
    
      class MyChildClass extends MyAbstract {
        // ...
      }
    }
    

    then in your HTML you have to ensure that the order of the scripts is correct once the javascripts have been generated:

     
    
    

提交回复
热议问题