merge-anything icon indicating copy to clipboard operation
merge-anything copied to clipboard

Wrong types inferred when using partial interfaces

Open ivancuric opened this issue 9 months ago • 1 comments

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 avatar Feb 07 '25 10:02 ivancuric

@ivancuric PRs welcome

mesqueeb avatar Feb 08 '25 02:02 mesqueeb