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

Rename createComponent to defineComponent#549

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

Conversation

chrisvfritz
Copy link
Contributor

I think "define" is more accurate than "create" in this case, since nothing is really being created per se - the function just returns the same object. But itis useful for defining a component, to get better typings.

I think it would also be helpful to reserve the "define" prefix (or some other verb) for any future functions that only exist for typings, to help differentiate them from functions that create a new instance of something.

Thoughts?

rigor789, clemvnt, brandonpittman, aztalbot, academici, hiendv, a631807682, fnlctrl, eriktisme, jacekkarczmarczyk, and 2 more reacted with thumbs up emojidanyadev and paulyoung5 reacted with thumbs down emoji
@CyberAP
Copy link
Contributor

withComponentAnnotations?

RobertWHurst reacted with thumbs up emoji

@yyx990803
Copy link
Member

How about justcomponent? (Since in v3 there's no globalVue.component anymore)

import{component}from'vue'constApp=component({// ...})
thecrypticace, sqal, aztalbot, stefnotch, and gartmeier reacted with thumbs up emojidamianstasik reacted with thumbs down emoji

@thecrypticace
Copy link
Contributor

I was thinking this exact thing.component seems reasonable.

aztalbot reacted with thumbs up emoji

@chrisvfritz
Copy link
ContributorAuthor

chrisvfritz commentedDec 20, 2019
edited
Loading

I'm good withwithComponentAnnotations - or perhaps preferably,annotateComponent - as an alternative, since it also gives us a pattern we can follow for type annotation functions like this. The only reason I still likedefine better isannotate is harder to spell, especially for our international users.

I worry thatcomponent would be even worse thancreateComponent because coming from Vue 2, most people would probably expect it to do the same thing asVue.component. It also doesn't provide a pattern to hint to users that it's just for typings. Plus, it works very differently from other verb-less functions likereactive,ref,computed, etc, which all return a new instance of the thing they describe.

damianstasik, jacekkarczmarczyk, and aztalbot reacted with thumbs up emoji

@CyberAP
Copy link
Contributor

CyberAP commentedDec 20, 2019
edited
Loading

True that, trying to google what does Vue.component do could lead to irrelevant results. Also JSFiddle and Codepen projects extensively use that to play with components.

@chrisvfritz
Copy link
ContributorAuthor

@CyberAP That's true! Googlingcomponent would be pretty difficult.

@yyx990803
Copy link
Member

Ok in this case I'm fine withdefineComponent. When using TS you'd get this auto-imported so a bit of verbosity doesn't really matter.

annotateComponent sounds inaccurate to me, because technically it provides type inference, not adding "annotations" to the component.

znck, aztalbot, fnlctrl, stefnotch, juliomrqz, Higemura, and Saganic reacted with thumbs up emoji

@yyx990803yyx990803 merged commit1c4cdd8 intovuejs:masterDec 22, 2019
@BinarySpike
Copy link

Reading some guides online that havecreateComponent and I got

Module '"../../../node_modules/vue/dist/vue"' has no exported member 'createComponent'. Did you mean 'ConcreteComponent'?ts(2724)

Saw the merge and thought, "I wonder if it's renamed" and yes it is. 👍

The correct import is

import { defineComponent } from 'vue';

I guess I should have read this first:https://v3.vuejs.org/guide/typescript-support.html#defining-vue-components

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@chrisvfritz@CyberAP@yyx990803@thecrypticace@BinarySpike

[8]ページ先頭

©2009-2025 Movatter.jp