Skip to content

Wrong types inferred when using partial interfaces #44

@ivancuric

Description

@ivancuric
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions