Created
April 14, 2022 04:49
-
-
Save jasonbyrne/5f86e5b36e1bb84fc482936deefe0668 to your computer and use it in GitHub Desktop.
Get and Change
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
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