{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1806","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1806/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1806/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1806/events","html_url":"https://github.com/Microsoft/TypeScript/issues/1806","id":55472925,"number":1806,"title":"add type-guard for `void`","user":{"login":"fdecampredon","id":864201,"avatar_url":"https://avatars.githubusercontent.com/u/864201?v=3","gravatar_id":"","url":"https://api.github.com/users/fdecampredon","html_url":"https://github.com/fdecampredon","followers_url":"https://api.github.com/users/fdecampredon/followers","following_url":"https://api.github.com/users/fdecampredon/following{/other_user}","gists_url":"https://api.github.com/users/fdecampredon/gists{/gist_id}","starred_url":"https://api.github.com/users/fdecampredon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fdecampredon/subscriptions","organizations_url":"https://api.github.com/users/fdecampredon/orgs","repos_url":"https://api.github.com/users/fdecampredon/repos","events_url":"https://api.github.com/users/fdecampredon/events{/privacy}","received_events_url":"https://api.github.com/users/fdecampredon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-26T11:37:05Z","updated_at":"2015-01-27T19:28:28Z","closed_at":null,"body":"There is a type that is quite interesting in typescript `void | {}`, this type has some unique behavior, everything can be assigned to this type, but the compiler does not infer any property for this type unlike for `{}` that inherits the basic object properties, the difference with `{}` is subtile but still pretty interesting: \r\n\r\n```typescript\r\nfunction func1(val: {} ) {\r\n    val.hasOwnProperty('hello'); // no error\r\n}\r\nfunction func2(val: {} | void) {\r\n    val.hasOwnProperty('hello');  // error:  Property 'hasOwnProperty' does not exist on type 'void | {}'.\r\n}\r\n```\r\nHowever there is not typeguard for `void`, it could be interesting to add some type guards for this case: \r\n\r\n* `typeof val !== 'undefined'`\r\n* `val !== undefined`\r\n*  `val != undefined`\r\n* `val != null`\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/71711185","html_url":"https://github.com/Microsoft/TypeScript/issues/1806#issuecomment-71711185","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1806","id":71711185,"user":{"login":"danquirk","id":7121557,"avatar_url":"https://avatars.githubusercontent.com/u/7121557?v=3","gravatar_id":"","url":"https://api.github.com/users/danquirk","html_url":"https://github.com/danquirk","followers_url":"https://api.github.com/users/danquirk/followers","following_url":"https://api.github.com/users/danquirk/following{/other_user}","gists_url":"https://api.github.com/users/danquirk/gists{/gist_id}","starred_url":"https://api.github.com/users/danquirk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danquirk/subscriptions","organizations_url":"https://api.github.com/users/danquirk/orgs","repos_url":"https://api.github.com/users/danquirk/repos","events_url":"https://api.github.com/users/danquirk/events{/privacy}","received_events_url":"https://api.github.com/users/danquirk/received_events","type":"User","site_admin":false},"created_at":"2015-01-27T19:28:28Z","updated_at":"2015-01-27T19:28:28Z","body":"So how would this differ from your proposal for ```object``` as a primitive? https://github.com/Microsoft/TypeScript/issues/1809 It seems like you either want to type func2's argument as ```object``` or be able to use ```{} | void``` for a similar effect?"}}