Skip to content

Instantly share code, notes, and snippets.

@StevenLangbroek
Created February 13, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StevenLangbroek/924234cbd404212b7bf0620d10748999 to your computer and use it in GitHub Desktop.
Save StevenLangbroek/924234cbd404212b7bf0620d10748999 to your computer and use it in GitHub Desktop.
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