Title: Proposal: Union types should emit metadata arrays · Issue #9916 · microsoft/TypeScript · GitHub
Open Graph Title: Proposal: Union types should emit metadata arrays · Issue #9916 · microsoft/TypeScript
X Title: Proposal: Union types should emit metadata arrays · Issue #9916 · microsoft/TypeScript
Description: Problem Currently, metadata type information is not emitted on union types. When you try to get metadata type information of union types you always get an Object. Returning an array of types would be more useful. Proposal Union types sho...
Open Graph Description: Problem Currently, metadata type information is not emitted on union types. When you try to get metadata type information of union types you always get an Object. Returning an array of types would ...
X Description: Problem Currently, metadata type information is not emitted on union types. When you try to get metadata type information of union types you always get an Object. Returning an array of types would ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/9916
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: Union types should emit metadata arrays","articleBody":"# Problem\n\nCurrently, metadata type information is not emitted on union types. When you try to get metadata type information of union types you always get an **Object**.\nReturning an array of types would be more useful.\n# Proposal\n\nUnion types should emit metadata array.\n# Examples\n## Union types\n\n``` ts\nfunction Decorator(constructor: Function) {}\n\n@Decorator\nclass Foo {\n constructor(param: number | string) {}\n}\n```\n\n_~>Compiled_\n\n**Currently**\n\n``` js\nFoo = __decorate([\n Decorator, \n __metadata('design:paramtypes', [Object])\n ], Foo);\n```\n\n**Proposal**\n\n``` js\nFoo = __decorate([\n Decorator, \n __metadata('design:paramtypes', [[Number, String]])\n ], Foo);\n```\n## String Literal Types\n\n``` ts\n\nfunction Decorator(constructor: Function) { }\n\n@Decorator\nclass Foo {\n constructor(param: 'North' | 'East' | 'South' | 'West') { }\n}\n```\n\n_~>Compiled_\n\n**Currently**\n\n``` js\nFoo = __decorate([\n Decorator, \n __metadata('design:paramtypes', [Object])\n ], Foo);\n```\n\n**Proposal**\n\n``` js\nFoo = __decorate([\n Decorator, \n __metadata('design:paramtypes', [[ 'North', 'East', 'South', 'West']])\n ], Foo);\n```\n## Null\n\n``` ts\nfunction Decorator(constructor: Function) { }\n\n@Decorator\nclass Foo {\n constructor(param: string | null) { }\n}\n```\n\n_~>Compiled_\n\n**Currently**\n\n``` js\nFoo = __decorate([\n Decorator, \n __metadata('design:paramtypes', [Object])\n ], Foo);\n```\n\n**Proposal**\n\n``` js\nFoo = __decorate([\n Decorator, \n __metadata('design:paramtypes', [[String, null]])\n ], Foo);\n```\n## Undefined\n\n``` ts\nfunction Decorator(constructor: Function) { }\n\n@Decorator\nclass Foo {\n constructor(param: string | undefined) { }\n}\n```\n\n_~>Compiled_\n\n**Currently**\n\n``` js\nFoo = __decorate([\n Decorator, \n __metadata('design:paramtypes', [Object])\n ], Foo);\n```\n\n**Proposal**\n\n``` js\nFoo = __decorate([\n Decorator, \n __metadata('design:paramtypes', [String])\n ], Foo);\n```\n# Use case\n\nFor example, when you want the type information to generate your database tables.\n\n``` ts\nclass Age {\n\n @Attribute\n public name :string; // VARCHAR\n\n\n @Attribute\n public gender : ['male', 'female']; // ENUM('male', 'female')\n}\n```\n","author":{"url":"https://github.com/Neme","@type":"Person","name":"Neme"},"datePublished":"2016-07-24T01:32:33Z","url":"https://github.com/microsoft/TypeScript/issues/9916"}
| 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:6567083c-0960-b731-68b2-5659e1469c54 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8920:2270F4:7ABD55:A536E4:6B00DD40 |
| html-safe-nonce | 0016811c8d67a9d4823e5ff5d67dc0ee64e50376cb19c800b5b5b9dcf62908c4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTIwOjIyNzBGNDo3QUJENTU6QTUzNkU0OjZCMDBERDQwIiwidmlzaXRvcl9pZCI6IjU2MDE3OTcyNTAzNTIyMDkyMTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b6fa0ebde8e9dc718ebe1583b45cb88acc172d8de2404c7815ff9e57d9ffa0a3 |
| hovercard-subject-tag | issue:167212008 |
| 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/9916/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7861ba8e17d7cf5c8b4dfcab8925249e051dc5f026ee44c2ba5adc79fbd82ba1/microsoft/TypeScript/issues/9916 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7861ba8e17d7cf5c8b4dfcab8925249e051dc5f026ee44c2ba5adc79fbd82ba1/microsoft/TypeScript/issues/9916 |
| og:image:alt | Problem Currently, metadata type information is not emitted on union types. When you try to get metadata type information of union types you always get an Object. Returning an array of types would ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Neme |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width