Skip to content

Conversation

cexbrayat
Copy link
Member

shallowMount now has the same signatures than mount, to which it delegates the heavy work.

`shallowMount` now has the same signatures than `mount`, to which it delegates the heavy work.
Copy link
Member

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment (question, actually)

thanks!

src/mount.ts Outdated
}

// Functional component
export function shallowMount<TestedComponent extends FunctionalComponent>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are the same can we not share the type somehow? Or is this not possible? (Eg, are we not copy-pasting the same 50 or so lines twice?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question, but I don't know how we could easily do that. @pikax maybe?

Copy link
Member

@pikax pikax May 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is a bit tricky and dirty, but we could have something like this:

export const shallowMount: typeof mount = (...args) => {
  mount(args[0], { ...args[1], shallow: true })
}

Typescript complains about it, but we can cast the function to unknown first

EDIT: The args are not required, we can have two arguments as we have in mount, but we can't infer the correct type on the implementation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pikax I pushed an extra commit with your suggestion 👍 TSD is happy, so it's good enough for me :)

@lmiller1990 lmiller1990 merged commit 556f2d6 into vuejs:master May 18, 2020
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

Successfully merging this pull request may close these issues.

3 participants