Learn TypeScript
Quiz
Quiz
Test your knowledge on generic types with this quiz.
We have a type within our codebase for a comment:
type Comment = { comment: string; email: string;}
What generic type can we use with Comment
that would create a type equivalent to the type below:
type ReadonlyComment = { readonly comment: string; readonly email: string;}
The function below counts the occurrences of an item in an array:
function countDisinct(itemToCount, array) { return array.filter(item => item === itemToCount).length}
How can we make this strongly-typed?