Skip to content

Instantly share code, notes, and snippets.

@oscar60310
Created December 29, 2020 03:50
Show Gist options
  • Save oscar60310/013bfb72702ce98b5e2aa3aaec605b9e to your computer and use it in GitHub Desktop.
Save oscar60310/013bfb72702ce98b5e2aa3aaec605b9e to your computer and use it in GitHub Desktop.
Property be a function and a object in same time
// ref https://stackoverflow.com/questions/12766528/build-a-function-object-with-properties-in-typescript
class Snadbox {
public test = Object.assign(() => this.runTest('RUN'), {
skip: () => this.runTest('test')
})
private runTest = (mode: string) => console.log(`Test in mode ${mode}`);
}
const sandbox = new Snadbox();
sandbox.test();
sandbox.test.skip();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment