tspartials

For typescript inspired from C# partial classes, help divide functionality of a single class into multiple classes files

Usage no npm install needed!

<script type="module">
  import tspartials from 'https://cdn.skypack.dev/tspartials';
</script>

README

Typescript Partials (αlpha release)

Inspired from C# partial classes for typescript, Simplified 🎀 syntax that may help divide functionality of a single class into multiple 🍬🍬🍬 class files

Install

Install dependencies with npm:

npm i partials

Import

import partial from 'partials';

Add your partial classes 🍬🍬🍬

@partial export class Employee {
    @partial work: EmployeeWork;
    @partial lunch: EmployeeLunch;
    start() {
        this.work.doWork();
        this.lunch.goToLunch();
    }
}
@partial export class EmployeeWork {
    @partial model: EmployeeModel;
    doWork() {
        console.log(`doWork()`);
    }
}
@partial export class EmployeeLunch {
  
    @partial model: EmployeeModel;
    goToLunch() {
        console.log(`goToLunch()`);
    }
}

Use your class

new Employee().start()
// Ouputs:
// goToWork()
// goToLunch()