|
|
|
|
|
by davidatbu
1153 days ago
|
|
> What's wrong with TypeScript. I love typescript, but, from my PoV, what I miss in typescript is: - An actually sound type system: This is a big one. Can you figure out why this[0] is unsound? - I regularly have to do `as ` assertions, and I know it's not because I'm bad at typescript because it's often the recommended solution from cream-of-the-crop tS libraries for certain issues. - Traits - new-types - Algebraic data types: Option and Result. 'nuff said. - Pattern matching: :cheff's kiss: [0] export function useSetter<T, K extends keyof T>(
state: T,
setState: (n: T) => void,
key: K
) {
return useCallback(
(val: T[K]) => setState({ ...state, [key]: val }),
[key, setState, state]
);
}
|
|