{"action":"created","issue":{"url":"https://api.github.com/repos/vuejs/vue/issues/5605","repository_url":"https://api.github.com/repos/vuejs/vue","labels_url":"https://api.github.com/repos/vuejs/vue/issues/5605/labels{/name}","comments_url":"https://api.github.com/repos/vuejs/vue/issues/5605/comments","events_url":"https://api.github.com/repos/vuejs/vue/issues/5605/events","html_url":"https://github.com/vuejs/vue/issues/5605","id":226368753,"number":5605,"title":"Warn when component option should be an object, but is a function","user":{"login":"phoenixeliot","id":491376,"avatar_url":"https://avatars1.githubusercontent.com/u/491376?v=4","gravatar_id":"","url":"https://api.github.com/users/phoenixeliot","html_url":"https://github.com/phoenixeliot","followers_url":"https://api.github.com/users/phoenixeliot/followers","following_url":"https://api.github.com/users/phoenixeliot/following{/other_user}","gists_url":"https://api.github.com/users/phoenixeliot/gists{/gist_id}","starred_url":"https://api.github.com/users/phoenixeliot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phoenixeliot/subscriptions","organizations_url":"https://api.github.com/users/phoenixeliot/orgs","repos_url":"https://api.github.com/users/phoenixeliot/repos","events_url":"https://api.github.com/users/phoenixeliot/events{/privacy}","received_events_url":"https://api.github.com/users/phoenixeliot/received_events","type":"User","site_admin":false},"labels":[{"id":81203481,"url":"https://api.github.com/repos/vuejs/vue/labels/contribution%20welcome","name":"contribution welcome","color":"009800","default":false},{"id":601343890,"url":"https://api.github.com/repos/vuejs/vue/labels/good%20first%20issue","name":"good first issue","color":"6f4fff","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-05-04T18:27:48Z","updated_at":"2018-04-09T11:51:21Z","closed_at":"2017-05-28T08:38:29Z","author_association":"NONE","body":"### What problem does this feature solve?\r\nI often get mixed up on which properties of a component should be functions and which shouldn't, and mistakenly define some as functions when they should have been objects.\r\n\r\nIn the opposite scenario, when a property that needs to be a function is instead an object, we already get a very helpful warning message:\r\n`[Vue warn]: The \"data\" option should be a function that returns a per-instance value in component definitions. `\r\n\r\nBut if you define the `watch`, `methods`, `created`, or `computed` properties (and probably some others) as functions instead, Vue either silently fails to use the property at all, or gives a confusing error message. I've spent an embarrassing amount of my Vue dev time because of this simple mistake.\r\n\r\nHere's what those ones do if the value is a function instead of an object:\r\n\r\n`watch` will simply be ignored if it's a function instead of an object.\r\n\r\n`components` will prevent any children from rendering and log this message: `Unknown custom element: <child-component> - did you register the component correctly? For recursive components, make sure to provide the \"name\" option. (found in root instance)`\r\n\r\n`methods` will cause a runtime error with this message: `[Vue warn]: Property or method \"someMethod\" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in root instance)`\r\n\r\n`computed` — similar error `methods`\r\n\r\nMost of these errors are at least somewhat misleading as to what the real problem is.\r\n\r\nThe main benefit of a warning for this kind of mistake would be to spend less time futzing around with fixing the boilerplate after getting it slightly wrong.\r\n\r\n### What does the proposed API look like?\r\nIf a component is initialized with any properties whose values are functions, but should be objects, emit a warning similar to the warning for `data`. eg:\r\n\r\n`[Vue warn]: The \"computed\" option should be an object, not a function, in component definitions.`\r\n\r\n<!-- generated by vue-issues. DO NOT REMOVE -->"},"comment":{"url":"https://api.github.com/repos/vuejs/vue/issues/comments/379725426","html_url":"https://github.com/vuejs/vue/issues/5605#issuecomment-379725426","issue_url":"https://api.github.com/repos/vuejs/vue/issues/5605","id":379725426,"user":{"login":"Mostafa123sh","id":37097632,"avatar_url":"https://avatars1.githubusercontent.com/u/37097632?v=4","gravatar_id":"","url":"https://api.github.com/users/Mostafa123sh","html_url":"https://github.com/Mostafa123sh","followers_url":"https://api.github.com/users/Mostafa123sh/followers","following_url":"https://api.github.com/users/Mostafa123sh/following{/other_user}","gists_url":"https://api.github.com/users/Mostafa123sh/gists{/gist_id}","starred_url":"https://api.github.com/users/Mostafa123sh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mostafa123sh/subscriptions","organizations_url":"https://api.github.com/users/Mostafa123sh/orgs","repos_url":"https://api.github.com/users/Mostafa123sh/repos","events_url":"https://api.github.com/users/Mostafa123sh/events{/privacy}","received_events_url":"https://api.github.com/users/Mostafa123sh/received_events","type":"User","site_admin":false},"created_at":"2018-04-09T11:51:21Z","updated_at":"2018-04-09T11:51:21Z","author_association":"NONE","body":"you must put your data inside bracket and then return it "}}
{"actor":{"display_login":"Mostafa123sh"}}