I'm now exploring again the combination of ES modu...
# javascript
e
I'm now exploring again the combination of ES modules + ES classes + per-file granularity. Take this outputted JS code
Copy code
var ZNetAddressClass;
function ZNetAddress() {
  if (ZNetAddressClass === VOID) {
    class $ {
      constructor(host, port) {
        this.host = host;
        this.port = port;
      }
      r16() {
        return this.host;
      }
      s16() {
        return this.port;
      }
    }
    initMetadataForClass($, 'ZNetAddress');
    ZNetAddressClass = $;
  }
  return ZNetAddressClass;
}
//region block: exports
export {
  ZNetAddress as ZNetAddressgit3xj5nnn3g,
};
And its generated TS declaration
Copy code
export declare class ZNetAddress {
    constructor(host: string, port: number);
    get host(): string;
    get port(): number;
}
Would I be able to extend
ZNetAddress
from TS? E.g.,
Copy code
class MyExample extends ZNetAddress { ... }
a
Yes, the only thing you need to remember, that you should import from the TS side not
YOUR_FILE.mjs
but
YOUR_FILE.exports.mjs
Inside the file should be placed the following code:
Copy code
import { ZNetAddressgit3xj5nnn3g } from "./YOUR_FILE.mjs"

var ZNetAddress = ZNetAddressgit3xj5nnn3g()

export {
  ZNetAddress
}
e
Thanks! I'll have to check how the usability is on the long run with the imports from the
*.exports
file. I'll check with the "real" TS users