Typescript TSX and generic parameters

To get it to understand it’s a type parameter and not a JSX element, you can add a comma after the type parameter:

const f = <T1,>(arg1: T1) => <T2,>(arg2: T2) => {
   return { arg1, arg2 };
};

Or you could use function expressions instead:

const f = function<T1>(arg1: T1) {
    return function<T2>(arg2: T2) {
        return { arg1, arg2 };
    };
};

Or alternatively, in this scenario, this works:

const f = <T1, T2>(arg1: T1) => (arg2: T2) => {
   return { arg1, arg2 };
};

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)