merge-anything
merge-anything copied to clipboard
Wrong types inferred when using partial interfaces
import { merge } from 'merge-anything';
interface Pokemon {
name: string;
type: string;
}
const original: Pokemon = { name: 'Squirtle', type: 'water' };
const updatePokemon = (partial: Partial<Pokemon>) => {
const evolution = merge(original, partial);
return evolution; // resolved as `Partial<Pokemon>` when it should be `Pokemon`
};
https://stackblitz.com/edit/vitejs-vite-myssqmhr?file=src%2Fmain.ts,package.json&terminal=dev
@ivancuric PRs welcome