Title: Error using before transforms on files with decorators and class constructor parameter · Issue #17551 · microsoft/TypeScript · GitHub
Open Graph Title: Error using before transforms on files with decorators and class constructor parameter · Issue #17551 · microsoft/TypeScript
X Title: Error using before transforms on files with decorators and class constructor parameter · Issue #17551 · microsoft/TypeScript
Description: Description of the bug: When using any before transform on a file containing a class with both: a decorator a constructor parameter with a class type An error will be thrown (TypeError: Cannot read property 'exports' of undefined at reso...
Open Graph Description: Description of the bug: When using any before transform on a file containing a class with both: a decorator a constructor parameter with a class type An error will be thrown (TypeError: Cannot read...
X Description: Description of the bug: When using any before transform on a file containing a class with both: a decorator a constructor parameter with a class type An error will be thrown (TypeError: Cannot read...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/17551
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error using before transforms on files with decorators and class constructor parameter","articleBody":"**Description of the bug:** \r\n\r\nWhen using any before transform on a file containing a class with both:\r\n- a decorator\r\n- a constructor parameter with a class type\r\n\r\nAn error will be thrown (`TypeError: Cannot read property 'exports' of undefined at resolveNameHelper`).\r\n\r\nThis error goes away if:\r\n- the transform is removed\r\n- the transform is moved from `before` to `after`\r\n- the decorator is removed\r\n- the constructor type is changed from a class to a basic type (`boolean`, `number`, etc).\r\n\r\n**TypeScript Version:** 2.4.2\r\n\r\n**Code**\r\n\r\n```ts\r\nfunction classDecorator\u003cT extends { new(...args: any[]): {} }>(constructor: T) {\r\n return class extends constructor { }\r\n}\r\n\r\nclass SomeClass {}\r\n\r\n@classDecorator\r\nexport class AppComponent {\r\n constructor(test: SomeClass) { }\r\n}\r\n\r\n'change me';\r\n```\r\nReproduction of this bug requires using the transforms API.\r\n\r\nI have prepared a repository with a simple reproduction that runs this file: https://github.com/filipesilva/ts-transform-decorator-bug/blob/master/test.ts\r\n\r\n```\r\ngit clone https://github.com/filipesilva/ts-transform-decorator-bug\r\ncd ts-transform-decorator-bug\r\nnpm install\r\nnpm test\r\n```\r\n\r\n\r\n\r\n**Expected behavior:**\r\nFile is emitted without errors.\r\n\r\n**Actual behavior:**\r\nAn error is thrown:\r\n```\r\nD:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:27546\r\n var moduleExports = getSymbolOfNode(location).exports;\r\n ^\r\nTypeError: Cannot read property 'exports' of undefined\r\n at resolveNameHelper (D:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:27546:70)\r\n at resolveName (D:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:27491:20)\r\n at resolveEntityName (D:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:28152:26)\r\n at Object.getTypeReferenceSerializationKind (D:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:47726:31)\r\n at serializeTypeReferenceNode (D:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:52219:30)\r\n at serializeTypeNode (D:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:52167:28)\r\n at serializeTypeOfNode (D:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:52039:28)\r\n at serializeParameterTypesOfNode (D:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:52074:42)\r\n at addOldTypeMetadata (D:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:51962:98)\r\n at addTypeMetadata (D:\\sandbox\\ts-transform-decorator-bug\\node_modules\\typescript\\lib\\typescript.js:51953:17)\r\n```\r\n\r\n/cc @rbuckton ","author":{"url":"https://github.com/filipesilva","@type":"Person","name":"filipesilva"},"datePublished":"2017-08-01T14:43:05Z","url":"https://github.com/microsoft/TypeScript/issues/17551"}
| 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:9a83e605-6b55-5f07-2f01-6bc6262278f8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD5C:154D88:1D57AA6:257CE23:6B01A206 |
| html-safe-nonce | 5028880b0c1f432433cb2313bb8daf7af89bcc8675d14eb5125d8ffe044a2985 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDVDOjE1NEQ4ODoxRDU3QUE2OjI1N0NFMjM6NkIwMUEyMDYiLCJ2aXNpdG9yX2lkIjoiNjY3NTQyMTk3MjA2ODkzNDE1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7f2403c081725a20230848650afd1352f315be3dcee924ed50130b0a0db4bce5 |
| hovercard-subject-tag | issue:247093287 |
| 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/17551/issue_layout |
| twitter:image | https://opengraph.githubassets.com/86fba456a3a55f6998c2e5f455584bf381115869eeb2ab90e503079bf058a10a/microsoft/TypeScript/issues/17551 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/86fba456a3a55f6998c2e5f455584bf381115869eeb2ab90e503079bf058a10a/microsoft/TypeScript/issues/17551 |
| og:image:alt | Description of the bug: When using any before transform on a file containing a class with both: a decorator a constructor parameter with a class type An error will be thrown (TypeError: Cannot read... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | filipesilva |
| 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