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

feat: chain call #231

Merged
merged 7 commits into from
Jun 8, 2023
Merged

feat: chain call #231

merged 7 commits into from
Jun 8, 2023

Conversation

alexzhang1030
Copy link
Member

@alexzhang1030 alexzhang1030 commented Jan 25, 2023

Description

Extends defineProps, support call withDefaults as a chain:

<script setup lang="ts">
import { defineProps } from 'unplugin-vue-macros/macros' assert { type: 'macro' }

const { foo } = defineProps<{
  foo?: string
}>().withDefaults({
  foo: '111',
})
</script>
<template></template>

will compiles to

<script setup lang="ts">
const { foo } = withDefaults(defineProps<{
  foo?: string
}>(), {
  foo: '111'
})
</script>
<template></template>

Linked Issues

closes #214

Additional context

@stackblitz
Copy link

stackblitz bot commented Jan 25, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2023

🦋 Changeset detected

Latest commit: cbfaafc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@vue-macros/chain-call Patch
@vue-macros/common Patch
unplugin-vue-macros Patch
@vue-macros/api Patch
@vue-macros/better-define Patch
@vue-macros/define-emit Patch
@vue-macros/define-models Patch
unplugin-vue-define-options Patch
@vue-macros/define-prop Patch
@vue-macros/define-props-refs Patch
@vue-macros/define-props Patch
@vue-macros/define-render Patch
@vue-macros/define-slots Patch
@vue-macros/export-expose Patch
@vue-macros/export-props Patch
@vue-macros/hoist-static Patch
@vue-macros/named-template Patch
@vue-macros/reactivity-transform Patch
@vue-macros/setup-block Patch
@vue-macros/setup-component Patch
@vue-macros/setup-sfc Patch
@vue-macros/short-emits Patch
@vue-macros/short-vmodel Patch
@vue-macros/volar Patch
@vue-macros/nuxt Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel vercel bot temporarily deployed to Preview January 25, 2023 16:58 Inactive
@sxzz
Copy link
Member

sxzz commented Jan 27, 2023

I just introduced a new macro definePropsRefs, and we can also add chain methods to this macro.

@alexzhang1030
Copy link
Member Author

I just introduced a new macro definePropsRefs, and we can also add chain methods to this macro.

Great, I will update later

@vercel vercel bot temporarily deployed to Preview January 30, 2023 01:32 Inactive
@vercel vercel bot temporarily deployed to Preview January 30, 2023 01:34 Inactive
@vercel vercel bot temporarily deployed to Preview January 30, 2023 01:41 Inactive
@alexzhang1030
Copy link
Member Author

Hey @sxzz I synced this branch with main branch, but volar cannot compat with ts@5, so Vue server crashed. How can I resolve this ? 🤔

@sxzz
Copy link
Member

sxzz commented Jan 30, 2023

@alexzhang1030 I just rebased commits and fixed CI error. Don't forget to reset to the latest commit before pushing.

@vercel vercel bot temporarily deployed to Preview January 30, 2023 10:53 Inactive
@vercel vercel bot temporarily deployed to Preview January 31, 2023 02:07 Inactive
@alexzhang1030
Copy link
Member Author

waiting for this #255

@vercel vercel bot temporarily deployed to Preview February 1, 2023 01:42 Inactive
@vercel vercel bot temporarily deployed to Preview February 1, 2023 01:50 Inactive
@vercel vercel bot temporarily deployed to Preview February 1, 2023 07:35 Inactive
@vercel vercel bot temporarily deployed to Preview February 1, 2023 07:36 Inactive
@vercel vercel bot temporarily deployed to Preview February 1, 2023 07:37 Inactive
@vercel vercel bot temporarily deployed to Preview February 1, 2023 07:38 Inactive
@vercel vercel bot temporarily deployed to Preview February 1, 2023 07:52 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage February 26, 2023 06:39 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros February 26, 2023 06:39 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage February 26, 2023 06:39 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros February 26, 2023 06:41 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage February 26, 2023 06:59 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage February 26, 2023 07:01 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros February 26, 2023 07:02 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros April 26, 2023 04:13 Inactive
@socket-security
Copy link

New and updated dependency changes detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives1 Size Publisher
ast-kit ⬆️ 0.5.2...0.6.2 None +0/-0 39.2 kB sxzz

Footnotes

  1. https://docs.socket.dev

@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros June 8, 2023 15:32 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage June 8, 2023 15:32 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros June 8, 2023 15:34 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage June 8, 2023 15:35 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros June 8, 2023 16:34 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage June 8, 2023 16:45 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros June 8, 2023 16:45 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage June 8, 2023 16:48 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros June 8, 2023 16:48 Inactive
@sxzz
Copy link
Member

sxzz commented Jun 8, 2023

Tweaked this PR a lot.

  • Must import manually for overriding the macro from Vue core.
import { defineProps } from 'unplugin-vue-macros/macros' assert { type: 'macro' }
  • Removed definePropsRefs support.

@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros June 8, 2023 21:25 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage June 8, 2023 21:26 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros June 8, 2023 21:28 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage June 8, 2023 21:28 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros June 8, 2023 21:32 Inactive
@vercel vercel bot temporarily deployed to Preview – unplugin-vue-macros-coverage June 8, 2023 21:32 Inactive
@sxzz sxzz merged commit 23b789f into vue-macros:main Jun 8, 2023
8 checks passed
@github-actions github-actions bot mentioned this pull request Jun 8, 2023
@alexzhang1030 alexzhang1030 deleted the feat/chain-call branch June 9, 2023 02:03
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.

defineProps().withDefault() chain call
2 participants