Skip to content

Instantly share code, notes, and snippets.

@jasonbyrne
Created April 14, 2022 04:49
Show Gist options
  • Save jasonbyrne/5f86e5b36e1bb84fc482936deefe0668 to your computer and use it in GitHub Desktop.
Save jasonbyrne/5f86e5b36e1bb84fc482936deefe0668 to your computer and use it in GitHub Desktop.
Get and Change
class FoodItem {
constructor(private opts: FoodProperties) {}
public get<T extends keyof FoodProperties>(property: T): FoodProperties[T] {
return this.opts[property];
}
public change<T extends keyof FoodProperties>(
property: T,
value: FoodProperties[T]
) {
this.opts[property] = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment