Mixins, to me, are a mess. Each time I start to read about them my head hurts trying to figure out how they work.
Lots of people have asked for COMPILE-TIME partial class and method support.
I would propose the following -- just like C#:
File1.ts:
// Imagine this file is code generated and could be regenerated during development
export partial class Contact
{
firstName: string;
lastName: string;
partial OnInit( args: any ) : void;
constuctor( args: any )
{
this.OnInit( args );
}
}
export class Address
{
addr: string;
city: string;
state: string;
zip: string;
}
File2.ts
// See where I'm going with this? This file would be hand edited and allows me to specify associations and children.
partial class Contact
{
Addresses: string[] = [];
partial OnInit( args: any ) void
{
this.firstName = args.firstName;
this.lastName = args.lastName;
this.Addresses.push( new Address() );
}
}
Transpiling the above would emit one JS class for Contact, something like this:
var Contact = (function () {
function Contact() {
this.Addresses = [];
}
Contact.prototype.constuctor = function (args) {
this.OnInit( args );
};
Contact.prototype.OnInit = function (args) {
this.firstName = args.firstName;
this.lastName = args.lastName;
this.Addresses.push(new Address());
};
return Contact;
})();
var Address = (function () {
function Address() {
}
return Address;
})();
Mixins, to me, are a mess. Each time I start to read about them my head hurts trying to figure out how they work.
Lots of people have asked for COMPILE-TIME partial class and method support.
I would propose the following -- just like C#:
File1.ts:
File2.ts
Transpiling the above would emit one JS class for Contact, something like this: