Created
June 26, 2018 15:11
-
-
Save atrunelle/ecb9a0f941e88c5d78b7d7ec59ca8c04 to your computer and use it in GitHub Desktop.
Typescript interface and readability
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
export interface IAnswer { | |
answer: string; | |
description: string; | |
} | |
export interface IFunFact { | |
text: string; | |
number: number | string; | |
} | |
export interface IQuestion { | |
text: string; | |
answer: IAnswer; | |
funFact: IFunFact; | |
} | |
const question: IQuestion = { | |
text: 'Do you eat chocolate?', | |
answer: { | |
answer: 'yes', | |
description: ''. | |
}, | |
funFact: { | |
number: '100%' | |
text: 'replied yes', | |
} | |
}; | |
function getAnswer(question: IQuestion): IAnwser { | |
return question.answer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment