Skip to content

Instantly share code, notes, and snippets.

@tswistak
Created January 16, 2019 10:30
Show Gist options
  • Save tswistak/4c2f45452ca0ed762b7d51442b422ef4 to your computer and use it in GitHub Desktop.
Save tswistak/4c2f45452ca0ed762b7d51442b422ef4 to your computer and use it in GitHub Desktop.
Avoiding any in TypeScript, listing 5
class Settings {
setting1: boolean = true;
setting2: string = '';
setting3: number = 1;
constructor(obj: Partial<Settings>) {
Object.assign(this, obj);
}
}
const obj = new Settings({ setting3: 2 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment