TypeScript for JavaScript Developers Part 9: Custom Types with Generics

preview_player
Показать описание
In this short clip, a custom type is defined using generics to define a "predicate" or a simple method that takes an item of a certain type and returns a boolean. This simplifies the definition of the "find" function but doesn't change any of the generated JavaScript.
Рекомендации по теме
Комментарии
Автор

Do you "must" use the word Predicate or could it be anything? Can I make something like "type MapByName<T> = (item: T) => String" ?

hakanviajando