TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Partial classes

Open disshishkov opened this issue 12 years ago • 224 comments

Add support of partial classes. Mixins is not the same, because it's run-time realization. Need compile realization, where partial classes will be combine into one before converting typescript to javascript.

//FileA.ts
partial class ClassA
{      
    constructor(public name: string) {}
    public sayHello(): string { return "hi!"; }
}

//FileB.ts
partial class ClassA
{
   public sayBye(): string { return "by!"; }
}

will be:

partial class ClassA
{      
    constructor(public name: string) {}
    public sayHello(): string { return "hi!"; }
    public sayBye(): string { return "by!"; }
}

disshishkov avatar Aug 29 '14 08:08 disshishkov

@aluanhaddad why do you keep making this out as a run-time thing? Module loaders and all that have nothing to do with transpiling.

cosmoKenney avatar Apr 11 '17 21:04 cosmoKenney

+1

luisca-dev avatar Apr 25 '17 00:04 luisca-dev

@cosmoKenney

@aluanhaddad why do you keep making this out as a run-time thing? Module loaders and all that have nothing to do with transpiling.

That is not correct.

Look at the SystemJS and Webpack ecosystems and you will see otherwise.

Even more traditional, and rock solid gulp workflows rely on the correspondence between input and output files.

aluanhaddad avatar May 03 '17 16:05 aluanhaddad

+1

I need partial class because we are generating most of the base class using tools (to automate when there's a changes in the model). We then use partial class to add functionality to the class in a separate files so it won't be overwrite by the tool (that auto-generate the class).

jeeshenlee avatar May 10 '17 04:05 jeeshenlee