Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/corePublic

types(defineComponent): Support for GlobalComponents, typed Directives and respectexpose on defineComponent#3399

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
yyx990803 merged 43 commits intovuejs:minorfrompikax:types/refactor_defineComponent
Apr 25, 2024

Conversation

@pikax
Copy link
Member

@pikaxpikax commentedMar 9, 2021
edited
Loading

fix#3367

Changes

  • Support for typedComponents - to allow extraction of the components available
  • Support for typedDirectives andComponentCustomDirectives (aka global directives)
  • Initial support for typedexposed - this is a bit different from the actual implementation, this types will allow the exposed vue internal component types
  • Improvements onDirective type, allowing to specify the modifiers and the expected argument.

Directive usage

NowDirectives will hold more types to help the extensions:

exporttypeDirective<HostElement=any,// host Element type, eg: `HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement`Value=any,// value typed, eg: `string` or `number`Modifiersextendsstring=string,// possible modifiers, eg: `'trim' | 'number' | 'lazy'`Argextendsstring=string,// possible `arg`, eg: `string` or `'passive' | 'other'`>=// implementation|ObjectDirective<HostElement,Value,Arg,Modifiers>|FunctionDirective<HostElement,Value,Arg,Modifiers>// vmodel type implementationDirective<HTMLInputElement|HTMLTextAreaElement,any,'trim'|'number'|'lazy'>

antfu, HcySunYang, posva, yue4u, DannyFeliz, Hebilicious, John60676, IonianPlayboy, onx2, async0x42, and 60 more reacted with thumbs up emojiragokan, 202780181, kriskw1999, sadeghbarati, wobsoriano, Rock070, fanckush, mitjans, bbpalm, and zecka reacted with hooray emojiHcySunYang, johnsoncodehk, Niputi, gertqin, antfu, DannyFeliz, Hebilicious, John60676, IonianPlayboy, onx2, and 16 more reacted with heart emojiworstpractice, ragokan, kriskw1999, sadeghbarati, fanckush, and mitjans reacted with rocket emojionx2, Hawods, Shinigami92, noxz-dev, ragokan, luojin315, xuzuodong, kriskw1999, sadeghbarati, fanckush, and 2 more reacted with eyes emoji
@pikaxpikax marked this pull request as ready for reviewMarch 9, 2021 12:45
@johnsoncodehk
Copy link
Member

Thanks for this update, custom directives IntelliSense and Type-Checking is coming!

We also needComponentCustomComponents (global components). Similar toJSX.IntrinsicElements but actually it's use for handle different problem.

HcySunYang, odex21, ShineKidd, wobsoriano, Mingeax, and hufaei reacted with thumbs up emojiwebdevomandam reacted with heart emoji

@HcySunYang
Copy link
Member

HcySunYang commentedMar 10, 2021
edited
Loading

We also need ComponentCustomComponents (global components). Similar to JSX.IntrinsicElements but actually it's use for handle different problem.

@johnsoncodehkI think this is worth putting in a new issue for tracking, with as detailed information as possible. 😁

Edit: After reviewing the code, I think it can be implemented in this PR if possible

johnsoncodehk reacted with thumbs up emoji

@pikax
Copy link
MemberAuthor

We also needComponentCustomComponents (global components).

Maybe a better name would be good, any suggestions?

@HcySunYang
Copy link
Member

GlobalComponents andGlobalDirectives?

@johnsoncodehk
Copy link
Member

GlobalComponents andGlobalDirectives?

Look good, but inconsistent...

declare module'vue'{interfaceComponentCustomOptions{}interfaceComponentCustomProperties{}interfaceGlobalComponents{}interfaceGlobalDirectives{}}
ywenhao reacted with thumbs up emoji

@pikax
Copy link
MemberAuthor

Look good, but inconsistent...

It looks inconsistent but they mean different things

  • ComponentCustomOptions : Component custom options when youdefineComponent, eg:onBeforeRouteUpdate
  • ComponentCustomProperties : Customvm properties available on thecomponentInstance, eg:$router
  • GlobalComponents : Components added to theapp/global, available on every component (render), eg:router-view
  • GlobalDirectives : Directives defined to theapp/global, available on every component (render), eg:v-tooltip

As you can see they usually mean different things, altho the Components/Directives are used on the components, they are not enhancing the component interaction, but to provide enhancement to the render.

I mean this is my logic on the naming, might be incorrect 😄

HavingComponentCustomComponents sounds a bit bad 😆

johnsoncodehk, HcySunYang, antfu, posva, ubbcou, hezizi, marekvospel, d1y, tszulc, sadeghbarati, and 2 more reacted with thumbs up emoji

@HcySunYang
Copy link
Member

yeah, they are different.

@pikaxpikax requested a review fromHcySunYangMarch 13, 2021 09:35
@HcySunYangHcySunYang added the 🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed. labelMar 29, 2021
pikaxand others added2 commitsNovember 17, 2023 11:55
# Conflicts:#packages/dts-test/defineComponent.test-d.tsx#packages/runtime-core/src/apiDefineComponent.ts#packages/runtime-core/src/componentPublicInstance.ts
@yyx990803yyx990803 changed the base branch frommain tominorNovember 21, 2023 00:39
@pikax
Copy link
MemberAuthor

/ecosystem-ci run

github-actions[bot] reacted with thumbs up emoji

@vue-bot

This comment was marked as outdated.

# Conflicts:#packages/dts-test/appUse.test-d.ts#packages/dts-test/defineComponent.test-d.tsx#packages/runtime-core/src/apiCreateApp.ts#packages/runtime-core/src/apiDefineComponent.ts#packages/runtime-core/src/componentOptions.ts#packages/runtime-core/src/componentPublicInstance.ts#packages/runtime-core/src/directives.ts#packages/runtime-core/src/index.ts#packages/runtime-dom/src/directives/vModel.ts#packages/runtime-dom/src/directives/vOn.ts#packages/runtime-dom/src/index.ts
@matthew-dean
Copy link

Can this be merged?

vojvodics, Hebilicious, extrem7, and Jaykul reacted with eyes emoji

@matthew-dean
Copy link

matthew-dean commentedJan 29, 2024
edited
Loading

Note, one thing I figured out you can do is simply use TypeScript'ssatisfies to get type-checking for custom directives. For example:

<divv-popover="{    html:true,    title:vm.tooltipTitle(),    placement:'right',    trigger:'click',    content:vm.tooltipContent()    }satisfiesPopoverOptions"></div>

Volar's code syntax coloring ofVue files completely borks if you usesatisfies in that way, but it looks like the technique itself succeeds.

It would be great if there was an ESLint plugin then to force / enforce the use ofsatisfies for any custom directive in the meantime (I guess from theeslint-plugin-vue folks) but that's a separate issue.

Hebilicious reacted with eyes emoji

@pikaxpikax changed the titletypes(defineComponent): support for expose component typestypes(defineComponent): Support for GlobalComponents, typed Directives and respectexpose on defineComponentApr 17, 2024
@pikax
Copy link
MemberAuthor

/ecosystem-ci run

github-actions[bot] reacted with thumbs up emoji

@vue-bot

This comment was marked as outdated.

@vue-bot

This comment was marked as outdated.

@vue-bot
Copy link
Contributor

📝 Ran ecosystem CI:Open

suiteresultlatest scheduled
language-toolsfailurefailure
nuxtsuccessfailure
piniasuccesssuccess
primevuesuccesssuccess
quasarsuccesssuccess
radix-vuesuccesssuccess
routersuccesssuccess
test-utilssuccesssuccess
vantfailuresuccess
vite-plugin-vuesuccesssuccess
vitepresssuccesssuccess
vue-i18nsuccesssuccess
vue-macrossuccesssuccess
vuetifyfailurefailure
vueusesuccesssuccess
vue-simple-compilersuccesssuccess

@yyx990803yyx990803 merged commit4cc9ca8 intovuejs:minorApr 25, 2024
@pikaxpikax deleted the types/refactor_defineComponent branchAugust 11, 2024 22:28
BacLuc added a commit to BacLuc/ecamp3 that referenced this pull requestMar 8, 2025
unplugin-vue-components now generates this file.See:-vuejs/core#3399
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@HcySunYangHcySunYangAwaiting requested review from HcySunYang

@yyx990803yyx990803Awaiting requested review from yyx990803

2 more reviewers

@znckznckznck left review comments

@johnsoncodehkjohnsoncodehkjohnsoncodehk left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed.scope: typesversion: minor

Projects

Status: Merged

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Expose types of locally registered components

14 participants

@pikax@johnsoncodehk@HcySunYang@yyx990803@aradalvand@ShenQingchuan@Maxim-Mazurok@yuntian001@tryforceful@extrem7@FichteFoll@vue-bot@matthew-dean@znck

[8]ページ先頭

©2009-2025 Movatter.jp