Created
December 29, 2020 03:50
-
-
Save oscar60310/013bfb72702ce98b5e2aa3aaec605b9e to your computer and use it in GitHub Desktop.
Property be a function and a object in same time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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