Extending react hook useState for use in event handlers
I must admit that my experience with typescript and react.js is quite limited so my review will be limited to basic syntax points. This code seems straight-forward. It makes good use of arrow functions and destruction assignment. There are just a couple suggestions I will make below.


if (typeof e?.stopPropagation === 'function') e.stopPropagation();



It is best to include brackets around the block, even if it is all on one line:

if (typeof e?.stopPropagation === 'function') { e.stopPropagation(); }


Some believe such blocks should never be on one line. If you are going to do it on one line, you could use short-circuiting:

typeof e?.stopPropagation === 'function' &amp;&amp; e.stopPropagation();




This block can be simplified somewhat:


if (typeof value === 'boolean') {
    // @ts-ignore
    return [value, setter, booleanAgg(value, setter, makeSetter)]
} else if (typeof value === 'string') {
    // @ts-ignore
    return [value, setter, stringAgg(value, setter)];
} else if (typeof value === 'number') {
    // @ts-ignore
    return [value, setter, numberAgg(value, setter)];
} else {
    throw new Error('Only boolean, string and number is supported');
}



The else keywords can be avoided because preceding blocks have return statements.'

if (typeof value === 'boolean') {
    // @ts-ignore
    return [value, setter, booleanAgg(value, setter, makeSetter)]
} 
if (typeof value === 'string') {
    // @ts-ignore
    return [value, setter, stringAgg(value, setter)];
} 
if (typeof value === 'number') {
    // @ts-ignore
    return [value, setter, numberAgg(value, setter)];
}
throw new Error('Only boolean, string and number is supported');