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

types(slots): Add typed slots #2693

Closed
wants to merge 12 commits into from
Closed

Conversation

pikax
Copy link
Member

@pikax pikax commented Nov 30, 2020

Allow type slots: vuejs/rfcs#192

@pikax pikax marked this pull request as ready for review March 13, 2021 15:59
@pikax pikax mentioned this pull request Mar 13, 2021
# Conflicts:
#	packages/runtime-core/src/componentOptions.ts
@oliverzy
Copy link

oliverzy commented May 9, 2022

Since in Volar 0.34.0, original typed slot support has been removed because of performance reason, could we move this PR forward. I feel this is the last piece of Vue TypeScript tooling support.

It's a big pain for any large scale Vue project.

# Conflicts:
#	packages/compiler-sfc/src/cssVars.ts
#	packages/dts-test/defineComponent.test-d.tsx
#	packages/runtime-core/src/apiDefineComponent.ts
#	packages/runtime-core/src/component.ts
#	packages/runtime-core/src/componentOptions.ts
#	packages/runtime-core/src/componentPublicInstance.ts
#	packages/runtime-core/src/scheduler.ts
Comment on lines +1561 to +1570
// TODO review this part
if (slotsTypeDecl) {
const content = slotsTypeDecl.__fromNormalScript
? script!.content
: scriptSetup.content
args += `: { slots: (${content.slice(
slotsTypeDecl.start!,
slotsTypeDecl.end!
)}), expose: any, emit: any, attrs: any }`
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure about this, this seems that might cause an issue when we have both slot and emit

@pikax
Copy link
Member Author

pikax commented Feb 21, 2023

@yyx990803 Do you mind reviewing this PR?

I need some help on the compiler macro for defineSlots, getting setup-maybe-ref:

  -   "mySlots": "setup-const",
  +   "mySlots": "setup-maybe-ref",

and #2693 (comment)

Comment on lines +743 to +747
slots: null as unknown as {
default: {
Component: ComponentPublicInstance
}
},
Copy link
Member Author

Choose a reason for hiding this comment

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

strict behaviour by default, this behaviour is a breaking change, I can make it less strict if needed

@sxzz
Copy link
Member

sxzz commented Apr 3, 2023

Very grateful for your PR. I didn't even notice this PR before #7982. So I close this.

@sxzz sxzz closed this Apr 3, 2023
@pikax pikax deleted the feat/typed_slots branch November 17, 2023 11:51
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