screepers / screeps-typescript-starter

Starter kit for TypeScript-based Screeps AI codes.
https://screepers.gitbook.io/screeps-typescript-starter/
The Unlicense
441 stars 318 forks source link

order of typescript files in javascript #31

Closed bastianh closed 7 years ago

bastianh commented 8 years ago

I'm not sure if I'm the problem or if something is missing here. I'm a typescript noob.

I try to use classes... with inheritance and it's working fine if the base class is in the same file.. but when they are in seperate files it breakes with following error:

File A.ts: 
abstract class Role {
  ...
}
export default Role;

File B.ts:
import Role from "./A"
export class Harvester extends Role {
 ...
}
TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (main:3443:29)
    at __webpack_require__ (main:21:30)
    at Object.<anonymous> (main:3426:18)
    at __webpack_require__ (main:21:30)
    at Object.<anonymous> (main:3369:19)
    at __webpack_require__ (main:21:30)
    at Object.<anonymous> (main:3336:18)
    at __webpack_require__ (main:21:30)
    at Object.<anonymous> (main:55:24)

I think it's because the files are in the wrong order in the generated js file .. and I read that with grunt you can have a reference file to set the order. Or is this not possible at all?

AviDuda commented 7 years ago

You can't export default abstract classes, see Microsoft/Typescript#3792

bastianh commented 7 years ago

oh thanks.. I'm pretty sure I tried without the abstract but I guess I made some other mistake ...

resir014 commented 7 years ago

Closing and marking as answered.