Title: Report use before definition for parameter types used in decorated classes and methods with --emitDecoratorMetadata · Issue #4114 · microsoft/TypeScript · GitHub
Open Graph Title: Report use before definition for parameter types used in decorated classes and methods with --emitDecoratorMetadata · Issue #4114 · microsoft/TypeScript
X Title: Report use before definition for parameter types used in decorated classes and methods with --emitDecoratorMetadata · Issue #4114 · microsoft/TypeScript
Description: I have the following code: @decorator class A { constructor(param : B) { } } class B { } function decorator(target: any) { return target; } console.log(Reflect.getMetadata("design:paramtypes", A)); The expected output should be: [functio...
Open Graph Description: I have the following code: @decorator class A { constructor(param : B) { } } class B { } function decorator(target: any) { return target; } console.log(Reflect.getMetadata("design:paramtypes", A));...
X Description: I have the following code: @decorator class A { constructor(param : B) { } } class B { } function decorator(target: any) { return target; } console.log(Reflect.getMetadata("design:paramtypes&q...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/4114
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Report use before definition for parameter types used in decorated classes and methods with --emitDecoratorMetadata","articleBody":"I have the following code:\n\n```\n@decorator\nclass A {\n constructor(param : B) {\n\n }\n}\n\nclass B {\n\n}\n\nfunction decorator(target: any) {\n return target;\n}\n\nconsole.log(Reflect.getMetadata(\"design:paramtypes\", A));\n```\n\nThe expected output should be: `[function B()]`, but the actual output is `[undefined]`. The issue is related to the definition order in the resulting js file, in which there is the following code:\n\n```\nvar A = (function () {\n function A(param) {\n }\n A = __decorate([\n decorator, \n __metadata('design:paramtypes', [B])\n ], A);\n return A;\n})();\nvar B = (function () {\n function B() {\n }\n return B;\n})();\n```\n\nSince A is defined by a IIFE, in its execution scope B is not yet defined, so the generated metadata is incorrectly set to undefined. The only workaround I can use now is to declare B before A.\n","author":{"url":"https://github.com/pcan","@type":"Person","name":"pcan"},"datePublished":"2015-08-01T12:05:53Z","url":"https://github.com/microsoft/TypeScript/issues/4114"}
| 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:6bfeacf4-ec2d-ed5f-53f4-dca764bb5183 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9308:3CBB3E:1A0534B:211EBB4:6B018F83 |
| html-safe-nonce | 781b0d9a9cabd77f4710646f6b1112420235ee04d8544826f56174873c154de6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzA4OjNDQkIzRToxQTA1MzRCOjIxMUVCQjQ6NkIwMThGODMiLCJ2aXNpdG9yX2lkIjoiNTAwNTE2MTcyNjY5NDQ5NDA4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a9ede2ec615fdf7135909701b3732bbd32840f771a88e1d49beaded400f8fcf0 |
| hovercard-subject-tag | issue:98532894 |
| 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/4114/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e4a214c5599ae5d2632b97a5cdc10a42eb0ba63e5970085fde38b0e283400d63/microsoft/TypeScript/issues/4114 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e4a214c5599ae5d2632b97a5cdc10a42eb0ba63e5970085fde38b0e283400d63/microsoft/TypeScript/issues/4114 |
| og:image:alt | I have the following code: @decorator class A { constructor(param : B) { } } class B { } function decorator(target: any) { return target; } console.log(Reflect.getMetadata("design:paramtypes", A));... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pcan |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width