-
-
Save rbiggs/a243817a7800fc45721dbbe0d0eadec4 to your computer and use it in GitHub Desktop.
TypeScript Interfaces
This file contains 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
/** Definition for item. */ | |
interface Item { | |
key: number; | |
value: string; | |
} | |
/** The property "items" is an array of type Item. */ | |
interface State { | |
newKey: number; | |
inputValue: string; | |
items: Item[]; | |
} | |
/** This type's methods return Message objects that are sent to the program's update method and processed by the action methods.*/ | |
interface ActionMethods { | |
updateInputValue:(value: string) => State; | |
addItem: () => State; | |
deleteItem: (key: number) => State; | |
useFetchedData: (data: State) => State; | |
} | |
/** This is the type for the object of methods used in Msg.match of the update function to trigger the correct actions for the received message. */ | |
interface MessageUnion { | |
match: (msg: Message, Object: ActionMethods) => State; | |
updateInputValue: (value: string) => State; | |
addItem: () => State; | |
deleteItem: (key: number) => State; | |
useFetchedData: (data: State) => State; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment