{"action":"created","issue":{"url":"https://api.github.com/repos/ternjs/tern/issues/958","repository_url":"https://api.github.com/repos/ternjs/tern","labels_url":"https://api.github.com/repos/ternjs/tern/issues/958/labels{/name}","comments_url":"https://api.github.com/repos/ternjs/tern/issues/958/comments","events_url":"https://api.github.com/repos/ternjs/tern/issues/958/events","html_url":"https://github.com/ternjs/tern/issues/958","id":282085449,"node_id":"MDU6SXNzdWUyODIwODU0NDk=","number":958,"title":"computedRet not used for completions","user":{"login":"jameshoward","id":202539,"node_id":"MDQ6VXNlcjIwMjUzOQ==","avatar_url":"https://avatars3.githubusercontent.com/u/202539?v=4","gravatar_id":"","url":"https://api.github.com/users/jameshoward","html_url":"https://github.com/jameshoward","followers_url":"https://api.github.com/users/jameshoward/followers","following_url":"https://api.github.com/users/jameshoward/following{/other_user}","gists_url":"https://api.github.com/users/jameshoward/gists{/gist_id}","starred_url":"https://api.github.com/users/jameshoward/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jameshoward/subscriptions","organizations_url":"https://api.github.com/users/jameshoward/orgs","repos_url":"https://api.github.com/users/jameshoward/repos","events_url":"https://api.github.com/users/jameshoward/events{/privacy}","received_events_url":"https://api.github.com/users/jameshoward/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-12-14T12:33:21Z","updated_at":"2018-07-15T11:43:24Z","closed_at":null,"author_association":"NONE","body":"Given the definitions below, the completions returned for text 'Builder.' shows `addQuery` as a `fn()` with no return type.\r\n\r\n```json\r\n{\r\n\t\"!name\": \"builder\",\r\n\t\"Builder\": {\r\n\t\t\"addQuery\": {\r\n\t\t\t\"!type\": \"fn() -> !this\",\r\n\t\t\t\"!doc\": \"I am an object\"\r\n\t\t},\r\n\t\t\"build\": {\r\n\t\t\t\"!type\": \"fn() ->!this\",\r\n\t\t\t\"!doc\": \"I am an object\"\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\nI've done some digging and it looks like the `!this` results in a retType of ANull and sets `computedRet` to a function that returns the first argument. When building completions (`addCompletion`) the type comes from `infer.toString`, which doesn't add a return type if `this.retval.isEmpty()`. Since `ANull`'s `isEmpty` method always returns `true`, the return type is not added."},"comment":{"url":"https://api.github.com/repos/ternjs/tern/issues/comments/405085514","html_url":"https://github.com/ternjs/tern/issues/958#issuecomment-405085514","issue_url":"https://api.github.com/repos/ternjs/tern/issues/958","id":405085514,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTA4NTUxNA==","user":{"login":"itaipelles","id":24319457,"node_id":"MDQ6VXNlcjI0MzE5NDU3","avatar_url":"https://avatars2.githubusercontent.com/u/24319457?v=4","gravatar_id":"","url":"https://api.github.com/users/itaipelles","html_url":"https://github.com/itaipelles","followers_url":"https://api.github.com/users/itaipelles/followers","following_url":"https://api.github.com/users/itaipelles/following{/other_user}","gists_url":"https://api.github.com/users/itaipelles/gists{/gist_id}","starred_url":"https://api.github.com/users/itaipelles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itaipelles/subscriptions","organizations_url":"https://api.github.com/users/itaipelles/orgs","repos_url":"https://api.github.com/users/itaipelles/repos","events_url":"https://api.github.com/users/itaipelles/events{/privacy}","received_events_url":"https://api.github.com/users/itaipelles/received_events","type":"User","site_admin":false},"created_at":"2018-07-15T11:43:24Z","updated_at":"2018-07-15T11:43:24Z","author_association":"NONE","body":"I actually ran into this issue in cases that are a bit more complex, for example like Promise.resolve:\r\nhttps://github.com/ternjs/tern/blob/master/defs/ecmascript.json#L22\r\nAgain, since the return type is !custom, toString does not indicate any return type."}}
{"actor":{"display_login":"itaipelles"}}