Skip to content

Instantly share code, notes, and snippets.

@ratbeard
Last active March 1, 2019 22:28
Show Gist options
  • Save ratbeard/c6d6c307008028bfdf5a0bccc3c1674b to your computer and use it in GitHub Desktop.
Save ratbeard/c6d6c307008028bfdf5a0bccc3c1674b to your computer and use it in GitHub Desktop.
/*
griz asks:
something I didn't get
question isn't in the object passed in, and the order of the args doesn't match
seems like that'd be a type error?
*/
export function MatchingQuestion({ onSelectChoice, onBreakMatch, questionState }: {
question: MatchingQuestionUI;
questionState: MatchingQuestionState;
onSelectChoice: (choice: MatchingChoice) => void;
onBreakMatch: (choice: MatchingChoice) => void;
}) {
// Equiv to =>
interface Argz {
question: MatchingQuestionUI;
questionState: MatchingQuestionState;
onSelectChoice: (choice: MatchingChoice) => void;
onBreakMatch: (choice: MatchingChoice) => void;
}
export function MatchingQuestion({ onSelectChoice, onBreakMatch, questionState }: Argz) {
// Equiv to =>
interface Argz {
question: MatchingQuestionUI;
questionState: MatchingQuestionState;
onSelectChoice: (choice: MatchingChoice) => void;
onBreakMatch: (choice: MatchingChoice) => void;
}
export function MatchingQuestion(props: Argz) {
const { onSelectChoice, onBreakMatch, questionState } = props
// So, its ok to not be destructuring all the properties out of the given props, and the order doesn't matter.
// Though the unused `question` prop should be deleted out of the inline interface def. 🧹
// And I generally try to sort stuff alphabetically. `highlight lines, cmd+shift+p, Sort Lines Ascending)` for lines,
// manually for props w/in a destructure. Though *GOD DAMNIT* I am merely human 🧜🏻‍♂️
@justinmchase
Copy link

For example I'd do this:

{
userId: string,
name: string,
profile: IUserProfile
}

Eff alphabetizing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment