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

Omit from #31115 makes all properties required #31190

Closed
InExtremaRes opened this issue May 1, 2019 · 2 comments · Fixed by #31205
Closed

Omit from #31115 makes all properties required #31190

InExtremaRes opened this issue May 1, 2019 · 2 comments · Fixed by #31205
Labels
Bug A bug in TypeScript Domain: Conditional Types The issue relates to conditional types Domain: Mapped Types The issue relates to mapped types Fixed A PR has been merged for this issue

Comments

@InExtremaRes
Copy link

Since the changes of #31115, Omit<T, K> makes all properties of T required.


TypeScript Version: 3.5.0-dev.20190501, 3.4.5

Search Terms: omit optional

Code

type A = {
    a: number;
    b?: string;
};

type B = Omit<A, 'a'>;

Expected behavior: B is { b?: string } ({ b?: string | undefined } with strictNullChecks).

Actual behavior: B is { b: string } ({ b: string | undefined } with strictNullChecks), with property b required.

Playground Link: link

pin @DanielRosenwasser

@DanielRosenwasser DanielRosenwasser added Domain: Conditional Types The issue relates to conditional types Domain: Mapped Types The issue relates to mapped types In Discussion Not yet reached consensus Suggestion An idea for TypeScript labels May 1, 2019
@InExtremaRes
Copy link
Author

InExtremaRes commented May 1, 2019

Just I'd like to remark that, as the playground link shows, when Omit is defined in terms of Pick the produced type preserves optional properties as optional; when it was changed to is own mapped type, all properties become required.

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Fixed A PR has been merged for this issue and removed In Discussion Not yet reached consensus Suggestion An idea for TypeScript labels May 1, 2019
@jcalz
Copy link
Contributor

jcalz commented May 3, 2019

Can we reopen #31104 then? I had some other ideas about it, if it matters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Conditional Types The issue relates to conditional types Domain: Mapped Types The issue relates to mapped types Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants