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

withDefaults merge object union #10594

Closed
th1m0 opened this issue Mar 26, 2024 · 1 comment
Closed

withDefaults merge object union #10594

th1m0 opened this issue Mar 26, 2024 · 1 comment

Comments

@th1m0
Copy link
Contributor

th1m0 commented Mar 26, 2024

Vue version

3.4.21

Link to minimal reproduction

play.vuejs.org

Steps to reproduce

withDefaults(
  defineProps<
    {
      def: string
    } & (
      | {
          type: 'hello'
          results: string
        }
      | {
          type: 'world'
          results: number
        }
    )
  >(),
  {
    def: 'default value!',
  }
)

What is expected?

Expected type from this would be:

type ExpectedType = {
    readonly def: string;
    readonly type: 'hello';
    readonly results: string;
} | {
    readonly def: string;
    readonly type: 'world';
    readonly results: number;
}

What is actually happening?

type actualType = {
    readonly type: "hello" | "world";
    readonly results: string | number;
    readonly def: string;
}

System Info

No response

Any additional comments?

The problem is with Typescripts utility type Omit. See: microsoft/TypeScript#54451 and microsoft/TypeScript#53169

@davidmatter
Copy link
Contributor

Same as #9336 right? Seems like this one was first

@github-actions github-actions bot locked and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants