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 return type when mixing optional and non-optional keys #451

Closed
RebeccaStevens opened this issue May 12, 2024 · 1 comment · Fixed by #452
Closed

Incorrect return type when mixing optional and non-optional keys #451

RebeccaStevens opened this issue May 12, 2024 · 1 comment · Fixed by #452
Labels
Priority: Medium This issue may be useful, and needs some attention. Status: In Progress Issue is currently being resolved by a developer. Status: Released It's now live. Type: Bug Inconsistencies or issues which will cause a problem for users or implementors.

Comments

@RebeccaStevens
Copy link
Owner

RebeccaStevens commented May 12, 2024

Expected behavior

const foo: { a: true; b: string } = { a: true, b: "n" };
const bar: { a: false; b?: number } = { a: false };
const result = merge(foo, bar);

console.log(result.a); // false
//                 ^? a: false
console.log(result.b); // "n"
//                 ^? b: string | number | undefined

Actual behavior

const foo: { a: true; b: string } = { a: true, b: "n" };
const bar: { a: false; b?: number } = { a: false };
const result = merge(foo, bar);

console.log(result.a); // false
//                 ^? a: false
console.log(result.b); // "n"
//                 ^? b: number | undefined
@RebeccaStevens RebeccaStevens added Status: Investigation Needed Issue need to be investigated further. Type: Bug Inconsistencies or issues which will cause a problem for users or implementors. Priority: Medium This issue may be useful, and needs some attention. labels May 12, 2024
@RebeccaStevens RebeccaStevens changed the title Discriminated unions can cause incorrect return types Incorrect return type May 14, 2024
@RebeccaStevens RebeccaStevens changed the title Incorrect return type Incorrect return type when mixing optional and non-optional keys May 14, 2024
@RebeccaStevens RebeccaStevens added Status: In Progress Issue is currently being resolved by a developer. and removed Status: Investigation Needed Issue need to be investigated further. labels May 19, 2024
Copy link

🎉 This issue has been resolved in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the Status: Released It's now live. label May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium This issue may be useful, and needs some attention. Status: In Progress Issue is currently being resolved by a developer. Status: Released It's now live. Type: Bug Inconsistencies or issues which will cause a problem for users or implementors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant