Suppose we have 2 simple TypeScript classes in 2 separate files:
- B.ts:
namespace A{
export abstract class ItemBase {
id:number=432;
}
}
- C.ts
///<reference path="B.ts"/>
namespace A{
export class ItemType extends A.ItemBase{}
}
- and invoking code in Code.ts:
///<reference path="C.ts"/>
let a:A.ItemType=new A.ItemType();
Everything works well after pushing it using clasp
But if I change the name of the C.ts file to AA.ts, I would get the error:
TypeError: Cannot read property "prototype" from undefined. (row 14, file „AA”).
The problem even exists if I would not instantiate the ItemType class in Code.ts.
It seems that ts2gas doesn't take into consideration the extends
keyword during the code transpiling and sets the output gs files as corresponding ts files order. So if we name the extended class file before the class file that we were extending from (in alphabetical order) we would get an error.
Do I have to take care of proper order of ts filenames during development? Do I have to attach some sort of mechanism that takes care of gs file loading order? It seems to be redundant for me while the gs files have been already transpiled. The transpilation process (ts2gas) should take care of proper class extension strategy that was used in TypeScript manner. If ts2gas can transpile the TypeScript Class into JS OOP, using prototyping, why it can't handle the class extensions properly?
I suppose there's some simpler and better way.