{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1809","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1809/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1809/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1809/events","html_url":"https://github.com/Microsoft/TypeScript/issues/1809","id":55496982,"number":1809,"title":"Suggestion: The `object` primitive type","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":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Accepting%20PRs","name":"Accepting PRs","color":"009800"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Suggestion","name":"Suggestion","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-01-26T15:42:11Z","updated_at":"2015-12-17T19:39:44Z","closed_at":null,"body":"# The `object` primitive type\r\n\r\nThis proposal describe a new primitive type for typescript `object`. \r\n\r\n## Use case\r\n\r\nJavaScript core api contains some functions that takes `object` as parameter : \r\n \r\n* `Object.getPrototypeOf`\r\n* `Object.getOwnPropertyDescriptor`\r\n* `Object.create`\r\n* ...etc\r\n\r\nCurrently there is no way in typescript to prevent passing other primitive type (`string`, `number`, etc ...) to those functions.\r\nFor example  ```Object.create('string')``` is a perfectly valid typescript statement, even if it will ends up with an error.\r\nCreating a new `object` primitive type would allows to model more correctly the signature of those function, and every function that share similar constraint.\r\n\r\n\r\n## Type Checking\r\n\r\n### Assignability\r\n\r\nThe `object` type is the equivalent of `{}` minus the assignability of other basic type, that means that : \r\n\r\n* any other basic types are not assignable to `object`\r\n* any non-basic type is assignable to `object`\r\n* object is only assignable to `{}` and `any`\r\n\r\nThis behavior is coherant to how javascript works, the type represent every value that respect the constraint `typeof value === 'object'` plus `undefined`.\r\n\r\n### Type guard\r\n\r\nA new type guard has to be introduced for `object` : `typeof value === 'object'`.\r\nOptionally the compiler could also accept comparaison with the `Object` function cast : `Object(value) === value`.\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/165559257","html_url":"https://github.com/Microsoft/TypeScript/issues/1809#issuecomment-165559257","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1809","id":165559257,"user":{"login":"falsandtru","id":3143368,"avatar_url":"https://avatars.githubusercontent.com/u/3143368?v=3","gravatar_id":"","url":"https://api.github.com/users/falsandtru","html_url":"https://github.com/falsandtru","followers_url":"https://api.github.com/users/falsandtru/followers","following_url":"https://api.github.com/users/falsandtru/following{/other_user}","gists_url":"https://api.github.com/users/falsandtru/gists{/gist_id}","starred_url":"https://api.github.com/users/falsandtru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/falsandtru/subscriptions","organizations_url":"https://api.github.com/users/falsandtru/orgs","repos_url":"https://api.github.com/users/falsandtru/repos","events_url":"https://api.github.com/users/falsandtru/events{/privacy}","received_events_url":"https://api.github.com/users/falsandtru/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T19:39:44Z","updated_at":"2015-12-17T19:39:44Z","body":"Great. I want to use this type in TS1.8."}}