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(compiler-sfc): support props name to be defined as a string #7803

Merged
merged 55 commits into from May 12, 2023

Conversation

baiwusanyu-c
Copy link
Member

@baiwusanyu-c baiwusanyu-c commented Feb 28, 2023

about: #7802
close: #8291
before:

<script setup lang='ts'>
const {foo = 1 } = defineProps<{
     "foo":number
  }>()
</script>

compile result:

const __sfc__ = /*#__PURE__*/_defineComponent({
  __name: 'App',
  setup(__props, { expose }) {
......

after:

const __sfc__ = /*#__PURE__*/_defineComponent({
  __name: 'App',
 props: {
    foo: { type: Number, required: true, default: 1 }
  },
  setup(__props, { expose }) {
......

@baiwusanyu-c baiwusanyu-c marked this pull request as draft February 28, 2023 15:18
@baiwusanyu-c baiwusanyu-c marked this pull request as ready for review February 28, 2023 15:24
@sxzz sxzz changed the title feat(compiler-sfc): Support props name to be defined as a string feat(compiler-sfc): support props name to be defined as a string Feb 28, 2023
Copy link
Member

@sxzz sxzz left a comment

Choose a reason for hiding this comment

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

I don't think the implementation currently is elegant... 😵‍💫

@sxzz sxzz dismissed their stale review February 28, 2023 16:20

Wrong button...

@baiwusanyu-c baiwusanyu-c requested a review from sxzz March 1, 2023 01:54
Copy link
Member

@sxzz sxzz left a comment

Choose a reason for hiding this comment

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

Consider this case

We should still add quotes

@baiwusanyu-c baiwusanyu-c requested a review from sxzz March 1, 2023 08:03
packages/compiler-sfc/src/compileScript.ts Outdated Show resolved Hide resolved
packages/compiler-sfc/src/compileScript.ts Outdated Show resolved Hide resolved
packages/compiler-sfc/src/compileScript.ts Outdated Show resolved Hide resolved
baiwusanyu-c and others added 5 commits March 6, 2023 10:54
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
Spaces were modified during formatting
@netlify
Copy link

netlify bot commented Apr 5, 2023

Deploy Preview for vue-sfc-playground failed.

Name Link
🔨 Latest commit 44a3e5e
🔍 Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/642d611771fe3d0008f1ad2e

@vercel
Copy link

vercel bot commented Apr 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
sfc-playground ⬜️ Ignored (Inspect) Apr 6, 2023 0:43am

baiwusanyu-c and others added 12 commits April 10, 2023 18:03
…tring

# Conflicts:
#	packages/compiler-sfc/src/compileScript.ts
…tring

# Conflicts:
#	packages/compiler-sfc/src/compileScript.ts
…tring

# Conflicts:
#	packages/compiler-sfc/src/compileScript.ts
…tring

# Conflicts:
#	packages/compiler-sfc/__tests__/__snapshots__/compileScriptPropsTransform.spec.ts.snap
#	packages/compiler-sfc/src/script/defineProps.ts
…tring

# Conflicts:
#	packages/compiler-sfc/__tests__/compileScript/__snapshots__/definePropsDestructure.spec.ts.snap
@yyx990803 yyx990803 merged commit 690ef29 into vuejs:main May 12, 2023
11 checks passed
@baiwusanyu-c baiwusanyu-c deleted the bwsy/feat/propsKeyString branch May 12, 2023 11:12
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.

SFC generate wrong code when use onUpdate:value as defineProps key
5 participants