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

后端 未结 5 660
你的背包
你的背包 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 10:00

    I had the same problem and it was caused by export default statements. To fix it I simply removed those and imported the required items another way:

    BEFORE

    A.ts

    export default MyClass;
    
    class MyClass { ... }
    

    B.ts

    import MyClass from "./A";
    
    class MyClass2 extends MyClass { ... }
    

    AFTER

    A.ts

    export class MyClass { ... }
    

    B.ts

    import { MyClass } from "./A";
    
    class MyClass2 extends MyClass { ... }
    

提交回复
热议问题