Title: Suggestion: The `object` primitive type · Issue #1809 · microsoft/TypeScript · GitHub
Open Graph Title: Suggestion: The `object` primitive type · Issue #1809 · microsoft/TypeScript
X Title: Suggestion: The `object` primitive type · Issue #1809 · microsoft/TypeScript
Description: The object primitive type This proposal describe a new primitive type for typescript object. Use case JavaScript core api contains some functions that takes object as parameter : Object.getPrototypeOf Object.getOwnPropertyDescriptor Obje...
Open Graph Description: The object primitive type This proposal describe a new primitive type for typescript object. Use case JavaScript core api contains some functions that takes object as parameter : Object.getPrototyp...
X Description: The object primitive type This proposal describe a new primitive type for typescript object. Use case JavaScript core api contains some functions that takes object as parameter : Object.getPrototyp...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/1809
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Suggestion: The `object` primitive type","articleBody":"# The `object` primitive type\n\nThis proposal describe a new primitive type for typescript `object`. \n## Use case\n\nJavaScript core api contains some functions that takes `object` as parameter : \n- `Object.getPrototypeOf`\n- `Object.getOwnPropertyDescriptor`\n- `Object.create`\n- ...etc\n\nCurrently there is no way in typescript to prevent passing other primitive type (`string`, `number`, etc ...) to those functions.\nFor example `Object.create('string')` is a perfectly valid typescript statement, even if it will ends up with an error.\nCreating a new `object` primitive type would allows to model more correctly the signature of those function, and every function that share similar constraint.\n## Type Checking\n### Assignability\n\nThe `object` type is the equivalent of `{}` minus the assignability of other basic type, that means that : \n- any other basic types are not assignable to `object`\n- any non-basic type is assignable to `object`\n- object is only assignable to `{}` and `any`\n\nThis behavior is coherant to how javascript works, the type represent every value that respect the constraint `typeof value === 'object'` plus `undefined`.\n### Type guard\n\nA new type guard has to be introduced for `object` : `typeof value === 'object'`.\nOptionally the compiler could also accept comparaison with the `Object` function cast : `Object(value) === value`.\n","author":{"url":"https://github.com/fdecampredon","@type":"Person","name":"fdecampredon"},"datePublished":"2015-01-26T15:42:11Z","url":"https://github.com/microsoft/TypeScript/issues/1809"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8617e350-e951-d916-4d3a-061dda875f07 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8AAC:3FF2FE:384308:4E0744:6B008C4B |
| html-safe-nonce | 46b3ddba5f7e4f47fee40aa7e6d67e73ecc55fab93250f36ddc1b2cd83c289f4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QUFDOjNGRjJGRTozODQzMDg6NEUwNzQ0OjZCMDA4QzRCIiwidmlzaXRvcl9pZCI6IjM5NzY4MDc5NTMxNDI0MTg1MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f2f5aa182d9c357f4d99c8af30533c23e0aa95e2d74a2ad5e31e34494741443a |
| hovercard-subject-tag | issue:55496982 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/1809/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ef9f0ff3d3b6b000f8fcf3b6c5c2b40e048c66fd1ca162a5b4a1992d4747c1fc/microsoft/TypeScript/issues/1809 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ef9f0ff3d3b6b000f8fcf3b6c5c2b40e048c66fd1ca162a5b4a1992d4747c1fc/microsoft/TypeScript/issues/1809 |
| og:image:alt | The object primitive type This proposal describe a new primitive type for typescript object. Use case JavaScript core api contains some functions that takes object as parameter : Object.getPrototyp... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fdecampredon |
| hostname | github.com |
| expected-hostname | github.com |
| None | c710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | be616a2a6ec1c609d6e002896dff5352d5c5f28b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width