Title: Duplicate exports.* = assignments in CommonJS output in some cases · Issue #58772 · microsoft/TypeScript · GitHub
Open Graph Title: Duplicate exports.* = assignments in CommonJS output in some cases · Issue #58772 · microsoft/TypeScript
X Title: Duplicate exports.* = assignments in CommonJS output in some cases · Issue #58772 · microsoft/TypeScript
Description: 🔎 Search Terms commonjs, exports, function 🕗 Version & Regression Information This changed in #58489. ⏯ Playground Link Thanks for merging I'm still seeing an odd behavior I think is related: here's the minimal repro I could find - bug w...
Open Graph Description: 🔎 Search Terms commonjs, exports, function 🕗 Version & Regression Information This changed in #58489. ⏯ Playground Link Thanks for merging I'm still seeing an odd behavior I think is related: here'...
X Description: 🔎 Search Terms commonjs, exports, function 🕗 Version & Regression Information This changed in #58489. ⏯ Playground Link Thanks for merging I'm still seeing an odd behavior I think is relate...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/58772
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Duplicate exports.* = assignments in CommonJS output in some cases","articleBody":"### 🔎 Search Terms\r\n\r\ncommonjs, exports, function\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This changed in https://github.com/microsoft/TypeScript/pull/58489.\r\n\r\n\r\n\r\n### ⏯ Playground Link\r\n\r\nThanks for merging I'm still seeing an odd behavior I think is related: here's the minimal repro I could find - [bug workbench link](https://www.typescriptlang.org/dev/bug-workbench/?target=1&module=1#code/PTAEAEGcAsHsHcCiBbAlgF3QUwCYDFUAbLALlGQENUA7AOnUgCgQJlYcBXYsgY1mTbUAVk2ZhwAMyJZqFZKXJU6DRqmQAHWACd0oAN6g8sWKAC+oCVv6gARLWBTiAWngZoTrAA9NOm4y8+uhIc1DzoqLDUoDxaWBTYRrAAFACUZIn6jKDZoLHoHFpReqYA3Iym-t7aunoxcQnGoBSQ0bHxWIkAagBMpYxiEI4ycgpDLm4eVTr0TAHVoDTYWhIUPFiGjcX9QA) \r\n\r\n### 💻 Code\r\n\r\n```ts\r\n// @showEmittedFile: main.ts\r\n// @module: commonjs\r\n\r\n// @filename: main.ts\r\nimport { Foo } from \"./file-with-export\"\r\nexport function createFoo(): Foo {\r\n return {};\r\n}\r\nexport {createFoo as createFooV2};\r\n\r\n// @filename: file-with-export.ts\r\nexport interface Foo {}\r\n```\r\n\r\n\r\n### 🙁 Actual behavior\r\n\r\nmain.js has two exports for `createFoo` and `createFooV2`:\r\n\r\n``` ts\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.createFoo = createFoo;\r\nexports.createFooV2 = createFoo;\r\nexports.createFoo = createFoo;\r\nexports.createFooV2 = createFoo;\r\nfunction createFoo() {\r\n return {};\r\n}\r\n```\r\n\r\n### 🙂 Expected behavior\r\n\r\n``` ts\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.createFoo = createFoo;\r\nexports.createFooV2 = createFoo;\r\nfunction createFoo() {\r\n return {};\r\n}\r\n```\r\n\r\n### Additional information about the issue\r\n\r\nI believe this is a result of the fix for https://github.com/microsoft/TypeScript/issues/58473. (I still appreciate having these duplicate exports rather than the compiler dropping the exports entirely 😃 )\r\n\r\nIn the debugger, I see that this `exportedFunctions` (https://github.com/microsoft/TypeScript/blob/506f3e26c3c8af7e4de38996656c947050e68567/src/compiler/transformers/utilities.ts#L108) set contains two separate `createFoo` nodes.\r\n\r\nIf I remove the `export {createFoo as createFooV2}` from the repro, or remove the declared return type `: Foo`, I get the expected behavior.\r\n\r\nThis was uncovered by testing the latest TS version in Google (https://github.com/Microsoft/TypeScript/issues/58685)","author":{"url":"https://github.com/lauraharker","@type":"Person","name":"lauraharker"},"datePublished":"2024-06-04T17:46:48Z","url":"https://github.com/microsoft/TypeScript/issues/58772"}
| 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:5c865004-8ad0-120b-4979-b097d30830f1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B198:293016:2453B3A:30386DE:6B0588DF |
| html-safe-nonce | 8482151c8a0f25862a2a43cefcf221e4ebb6f35dfd5706538eed35b6288d52d0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTk4OjI5MzAxNjoyNDUzQjNBOjMwMzg2REU6NkIwNTg4REYiLCJ2aXNpdG9yX2lkIjoiMjc1NTYwMjY4MzM0NzE3NTY0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 384eec34bdbc0d4ed711f3bba326cb38b0f7eadd5b281600fd6edf828f4b5a98 |
| hovercard-subject-tag | issue:2334063529 |
| 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/58772/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2b13d2ecc63014dce9a709ba91c19131cbe08c5bd3188ed2442c89a34dbe7d40/microsoft/TypeScript/issues/58772 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2b13d2ecc63014dce9a709ba91c19131cbe08c5bd3188ed2442c89a34dbe7d40/microsoft/TypeScript/issues/58772 |
| og:image:alt | 🔎 Search Terms commonjs, exports, function 🕗 Version & Regression Information This changed in #58489. ⏯ Playground Link Thanks for merging I'm still seeing an odd behavior I think is related: here'... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lauraharker |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9b4256ac5f3e310e7945ef5b71c9cb9e264357b1eb20e91d369ed6502a4c486c |
| 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 | f089e689ad324655ac44bf6cdbc04d976105b374 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width