Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect inferred type with allowUndefinedOverrides: false #33

Open
tippfelher opened this issue Jan 24, 2025 · 1 comment
Open

Incorrect inferred type with allowUndefinedOverrides: false #33

tippfelher opened this issue Jan 24, 2025 · 1 comment

Comments

@tippfelher
Copy link

import { merge } from "ts-deepmerge";

const a: { o: string } = { o: "Hello" };

const b: { o?: string } = {};

const c = merge.withOptions({ allowUndefinedOverrides: false }, a, b);

// this is incorrect
//   c is of type { o: string | undefined }
// but should be
//   { o: string }
// since c.o can never be undefined
@voodoocreation
Copy link
Owner

voodoocreation commented Jan 24, 2025

Hey, this is a duplicate of this issue - unfortunately I wasn't able to get the types to work as you're expecting here, (more details provided in my replies on the other issue), but contributions are always welcome if you'd like to give it a go and open a PR! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants