Title: [Bug] Mixin parameters failed to use as Method Parameter types of Inner Classes · Issue #50792 · microsoft/TypeScript · GitHub
Open Graph Title: [Bug] Mixin parameters failed to use as Method Parameter types of Inner Classes · Issue #50792 · microsoft/TypeScript
X Title: [Bug] Mixin parameters failed to use as Method Parameter types of Inner Classes · Issue #50792 · microsoft/TypeScript
Description: 🔎 Search Terms mixin, parameter, class method, type declaration, decorator 🕗 Version & Regression Information This is a crash This is the behavior in every version I tried, and I reviewed the FAQ for entries about mixin & parameter ⏯ Pla...
Open Graph Description: 🔎 Search Terms mixin, parameter, class method, type declaration, decorator 🕗 Version & Regression Information This is a crash This is the behavior in every version I tried, and I reviewed the FAQ f...
X Description: 🔎 Search Terms mixin, parameter, class method, type declaration, decorator 🕗 Version & Regression Information This is a crash This is the behavior in every version I tried, and I reviewed the F...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/50792
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug] Mixin parameters failed to use as Method Parameter types of Inner Classes","articleBody":"## 🔎 Search Terms\r\n\r\nmixin, parameter, class method, type declaration, decorator\r\n\r\n## 🕗 Version & Regression Information\r\n\r\n- This is a crash\r\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about *mixin & parameter*\r\n\r\n## ⏯ Playground Link\r\n\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?#code/MYewdgzgLgBATgUwOYEtoLgLhgWQVACxABMARBUOAQyhDhgF4YAKASkYD4YBvGAXwBQA0JFgA3KgBsUxGgmwAFKtQC2+DOUo06jFuwZdeggQDMArmGBQU4GCpQAPFGAA8AFQ7McJBJOxgEAHcWADow2SgqbCowAE8AbQBdfS43dm4BGCyYYEkqCAgYN2oUWAzsipgAAURUdDhMyqy1QhJmKolpCIQYZwAHMyhsb2JfdP5GrMEKxCgzODAikqgAbgFjXPzCtwRoEd8eSd7iXQAGdaFNgqLdqABhcCg4EElJDBgEBygEMGJC+ycYGYOz2Pkk4z4QA)\r\n\r\n## 💻 Code\r\n\r\n```ts\r\nconst register: MethodDecorator = () => { }\r\n\r\nconst validate: ParameterDecorator = () => { }\r\n\r\nfunction mixin\u003cT>(Model: new (...data: any[]) => T) {\r\n class Trait {\r\n @register\r\n method(@validate input: Model) { }\r\n }\r\n return Trait;\r\n}\r\n\r\nclass TestModel {\r\n id = 0\r\n}\r\n\r\nclass TestController extends mixin(TestModel) { }\r\n```\r\n\r\n## 🙁 Actual behavior\r\n\r\n### Type checking crashed\r\n\r\n```text\r\nerror TS2749: 'Model' refers to a value, but is being used as a type here. Did you mean 'typeof Model'?\r\n\r\n method(@validate input: Model) {\r\n ~~~~~\r\n```\r\n\r\n### Compiled seems to work\r\n\r\n```js\r\nfunction mixin(Model) {\r\n var _a;\r\n class Trait {\r\n method(input) { }\r\n }\r\n __decorate([\r\n register,\r\n __param(0, validate),\r\n __metadata(\"design:type\", Function),\r\n __metadata(\"design:paramtypes\", [typeof (_a = typeof Model !== \"undefined\" && Model) === \"function\" ? _a : Object]),\r\n __metadata(\"design:returntype\", void 0)\r\n ], Trait.prototype, \"method\", null);\r\n return Trait;\r\n}\r\n```\r\n\r\n### 🙂 Expected behavior\r\n\r\nShown sample code works, so that projects with Decorator frameworks will be much simpler, like what my service scaffold does: idea2app/REST-Node-ts#1","author":{"url":"https://github.com/TechQuery","@type":"Person","name":"TechQuery"},"datePublished":"2022-09-15T19:25:18Z","url":"https://github.com/microsoft/TypeScript/issues/50792"}
| 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:35ff9e25-6c18-ad9d-fc27-f34042fa7aca |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C3C:2E124E:23713F8:2D39790:6B018A97 |
| html-safe-nonce | 93b67c13b41aa9cc9fc0e6ad5ef0977436322768f5cd2dc7d81943aedb57e640 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzNDOjJFMTI0RToyMzcxM0Y4OjJEMzk3OTA6NkIwMThBOTciLCJ2aXNpdG9yX2lkIjoiNzczMzYzNzk5NjEwMDAyOTA3OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a276f03785dead666560f1edf13647ae1a14d7787b244ad6e9d07b7f4d525c43 |
| hovercard-subject-tag | issue:1374982548 |
| 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/50792/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9e4475537641c19506acbb2fc490d021633c79e149944852f2471c5dbbc4046f/microsoft/TypeScript/issues/50792 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9e4475537641c19506acbb2fc490d021633c79e149944852f2471c5dbbc4046f/microsoft/TypeScript/issues/50792 |
| og:image:alt | 🔎 Search Terms mixin, parameter, class method, type declaration, decorator 🕗 Version & Regression Information This is a crash This is the behavior in every version I tried, and I reviewed the FAQ f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TechQuery |
| 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