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(types): Add Exposed template to SetupContext #13177

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

michaelcozzolino
Copy link

@michaelcozzolino michaelcozzolino commented Apr 8, 2025

This PR allows the possibility to type expose when using defineComponent with composition api

export const UseVirtualList = defineComponent(
  <T = any>(props: {msg: T}, { slots, expose }: SetupContext<EmitsOptions, SlotsType<{}>, { index: number }>,
  ) => {
        ...
        const index = 2
        expose({index})
})

I added the template wherever it would be needed.
i'm not sure if in packages/runtime-core/src/componentOptions.ts at line 142 it's needed as well, as i already see an Exposed template, but doesn't look like having the type for the one in SetupContext. let me know if everything is fine

Copy link

github-actions bot commented Apr 9, 2025

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB 38.1 kB 34.4 kB
vue.global.prod.js 158 kB 58.3 kB 51.9 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.4 kB 18.2 kB 16.6 kB
createApp 54.4 kB 21.2 kB 19.4 kB
createSSRApp 58.6 kB 22.9 kB 20.9 kB
defineCustomElement 59.2 kB 22.7 kB 20.7 kB
overall 68.5 kB 26.4 kB 24 kB

Copy link

pkg-pr-new bot commented Apr 9, 2025

Open in StackBlitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@13177

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@13177

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@13177

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@13177

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@13177

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@13177

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@13177

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@13177

@vue/shared

npm i https://pkg.pr.new/@vue/shared@13177

vue

npm i https://pkg.pr.new/vue@13177

@vue/compat

npm i https://pkg.pr.new/@vue/compat@13177

commit: 040b0f3

@edison1105 edison1105 requested a review from jh-leong April 9, 2025 00:35
@jh-leong
Copy link
Member

jh-leong commented Apr 9, 2025

Thanks for the PR!

Could you please add test cases for this change in:

  • packages-private/dts-test/defineComponent.test-d.tsx
  • packages-private/dts-test/functionalComponent.test-d.tsx

This would help verify the type behavior.

@michaelcozzolino
Copy link
Author

Thanks for the PR!

Could you please add test cases for this change in:

  • packages-private/dts-test/defineComponent.test-d.tsx
  • packages-private/dts-test/functionalComponent.test-d.tsx

This would help verify the type behavior.

I added a test, but i was able to achieve the goal just partially, the expose keys seem to be typed properly, but the values are not typed at all, do you have any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants