Created
February 13, 2020 15:39
-
-
Save StevenLangbroek/924234cbd404212b7bf0620d10748999 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
interface ThingOptions { | |
owner: string; | |
title: string; | |
} | |
class Thing { | |
// this is fine | |
constructor({ owner, title = 'Thing' }) { | |
} | |
// if you need to do something async for construction: | |
static async create(options: ThingOptions): Promise<Thing> { | |
const dep = await getDep(options.owner); | |
return new Thing({ ...options, dep }); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment