How to expect a specific Typescript function template as an Angular component input

Advertisements I have one Angular component which has the following input @Input() filterColumnFunction?: FilterColumnFunction; This function type (‘template’) is the following export type FilterColumnFunction = <T>(columnFilters: { [key: string]: string }, items: T[]) => T[]; The given function to the component is filterColumnFunction = (columnFilters: { [key: string]: string }, items: MyDto[]): MyDto[] => {… Read More How to expect a specific Typescript function template as an Angular component input

List class wrapped by Map class do not support generic types in JAVA?

Advertisements class definition public interface ITest { Long foo(); } public class Test implements ITest{ @Override public Long foo() { return 0L; } } methods public Map<Long, List<? extends ITest>> moo() { List<Test> a = List.of(new Test()); Map<Long, List<? extends ITest>> b = Map.of(1L, a); return b; } public Map<Long, List<? extends ITest>> koo() {… Read More List class wrapped by Map class do not support generic types in JAVA?

Utility type to extract `Foo` from `type Bar = Set<Foo>` with just `Bar`

Advertisements I am looking for a utility type that will allow me to extract the generic parameter of a set, but I only have available the typed set, so basically type Bar = Set<Foo>; type Baz = SomethingMagic<Bar>; // Baz should equal Foo >Solution : You can do that with the infer keyword: type SomethingMagic<T>… Read More Utility type to extract `Foo` from `type Bar = Set<Foo>` with just `Bar`

Why String can't be returned from a method with return type <T extends Comparable<T>> T?

Advertisements Given that public final class String implements java.io.Serializable, Comparable<String>, CharSequence, Constable, ConstantDesc { … Why a String return is not valid? >Solution : You misunderstand what this means. You apparently think it means: "T is anything that is a Comparable or some subtype of it". This is incorrect. after all, that concept is represented… Read More Why String can't be returned from a method with return type <T extends Comparable<T>> T?

What is the approach to handle optional class members?

Advertisements Processing large amounts of data (gigabytes) I use indexes to data arrays. Since access to data could lead to cache inefficiency, I want to cache some data from array together with the index which gives dramatic speedup for operations through indexes. The amount of cached data is compile-time choice which should include zero amount… Read More What is the approach to handle optional class members?