Title: TypeScript 7.0.2: Incorrect namespace qualification in import aliases (import =) · Issue #65581 · microsoft/TypeScript · GitHub
Open Graph Title: TypeScript 7.0.2: Incorrect namespace qualification in import aliases (import =) · Issue #65581 · microsoft/TypeScript
X Title: TypeScript 7.0.2: Incorrect namespace qualification in import aliases (import =) · Issue #65581 · microsoft/TypeScript
Description: 🔎 Search Terms Bug Report TypeScript Version: 7.0.2 Description TypeScript 7.0.2 incorrectly emits an unqualified namespace reference when using an import = alias inside a nested namespace. The compiler resolves the symbol correctly but ...
Open Graph Description: 🔎 Search Terms Bug Report TypeScript Version: 7.0.2 Description TypeScript 7.0.2 incorrectly emits an unqualified namespace reference when using an import = alias inside a nested namespace. The com...
X Description: 🔎 Search Terms Bug Report TypeScript Version: 7.0.2 Description TypeScript 7.0.2 incorrectly emits an unqualified namespace reference when using an import = alias inside a nested namespace. The com...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/65581
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TypeScript 7.0.2: Incorrect namespace qualification in import aliases (import =)","articleBody":"### 🔎 Search Terms\n\n## Bug Report\n\n**TypeScript Version:** 7.0.2\n\n### Description\n\nTypeScript 7.0.2 incorrectly emits an unqualified namespace reference when using an `import =` alias inside a nested namespace.\n\nThe compiler resolves the symbol correctly but produces JavaScript that throws a `ReferenceError` at runtime.\n\nThis works correctly in TypeScript 6 and also works in TypeScript 7 when using an explicitly qualified namespace or replacing the alias with a `const` declaration.\n\n### Minimal Reproduction\n\n```typescript\nnamespace DX.SCPModule.VendorNavigator {\n export class Result {\n value = 42;\n }\n}\n\nnamespace DX.Mvc.OrganizationSearch {\n import Result = SCPModule.VendorNavigator.Result;\n\n export const result = new Result();\n}\n```\n\nCompile with TypeScript 7.0.2 using:\n\n```bash\ntsc --ignoreConfig repro.ts --target es2020 --module es2020\n```\n\n### Actual Behavior\n\nTypeScript 7 emits:\n\n```javascript\nvar Result = SCPModule.VendorNavigator.Result;\n```\n\nThis produces:\n\n```text\nReferenceError: SCPModule is not defined\n```\n\nThe `SCPModule` variable is scoped to a different namespace IIFE and is not accessible at this location.\n\n### Expected Behavior\n\nThe compiler should emit the fully qualified reference:\n\n```javascript\nvar Result = DX.SCPModule.VendorNavigator.Result;\n```\n\nThis is the behavior observed with TypeScript 6.\n\n### Workarounds\n\nBoth of the following work correctly in TypeScript 7.0.2:\n\n**Explicit qualification:**\n\n```typescript\nimport Result = DX.SCPModule.VendorNavigator.Result;\n```\n\n**Using a const instead of an import alias:**\n\n```typescript\nconst Result = SCPModule.VendorNavigator.Result;\n```\n\nThe second workaround correctly emits:\n\n```javascript\nconst Result = DX.SCPModule.VendorNavigator.Result;\n```\n\nThis suggests the issue is specific to `import =` alias emission rather than general namespace reference resolution.\n\n### Related Issues\n\n- microsoft/typescript-go#961\n- microsoft/typescript-go#2846\n\nPR #2846 fixed related namespace qualification issues, but this particular `import =` alias scenario appears to remain broken in TypeScript 7.0.2.\n\n### 🕗 Version & Regression Information\n\n- This changed between versions ______ and _______\n- This changed in commit or PR _______\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________\n- I was unable to test this on prior versions because _______\n\n\n### ⏯ Playground Link\n\n_No response_\n\n### 💻 Code\n\n```ts\n// Your code here\n```\n\n\n### 🙁 Actual behavior\n\nTypeScript 7.0.2 incorrectly emits an unqualified namespace reference when using an `import =` alias inside a nested namespace.\n\nGiven:\n\n```typescript\nnamespace DX.Mvc.OrganizationSearch {\n import Result = SCPModule.VendorNavigator.Result;\n}\n```\n\nThe compiler generates:\n\n```javascript\nvar Result = SCPModule.VendorNavigator.Result;\n```\n\nThis causes a runtime `ReferenceError: SCPModule is not defined`, because `SCPModule` is not accessible in the current JavaScript scope.\n\nThe issue does not occur when replacing `import =` with `const` or explicitly qualifying the namespace with `DX`.\n\n### 🙂 Expected behavior\n\nTypeScript 7 should correctly resolve and emit the fully qualified namespace reference, as TypeScript 6 does.\n\nExpected JavaScript output:\n\n```javascript\nvar Result = DX.SCPModule.VendorNavigator.Result;\n```\n\nThe generated JavaScript should execute without a `ReferenceError`, without requiring explicit namespace qualification in the TypeScript source.\n\n### Additional information about the issue\n\n_No response_","author":{"url":"https://github.com/pirobox","@type":"Person","name":"pirobox"},"datePublished":"2026-11-19T15:11:32Z","url":"https://github.com/microsoft/TypeScript/issues/65581"}
| 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:96c38e78-a756-ab6b-e01d-d4ceee35cc19 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C18E:31B4CC:959C5D:C6E49E:6B00E1C8 |
| html-safe-nonce | f78d8bb13005ce2506e2cc3b40eea368b5376b3a3972c0ca695996a0f782e210 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMThFOjMxQjRDQzo5NTlDNUQ6QzZFNDlFOjZCMDBFMUM4IiwidmlzaXRvcl9pZCI6IjkyMTA5NzUzMTU2Mjk3NjA5NjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2be81e78233a9493e2ad16f184c768c9e3799c812346719c5554ecdd960a1598 |
| hovercard-subject-tag | issue:6492672740 |
| 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/65581/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c4fd09fcf75256931b4cb641af5f963a8eb9fb723fa9acb223ab7e2e6d3322dc/microsoft/TypeScript/issues/65581 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c4fd09fcf75256931b4cb641af5f963a8eb9fb723fa9acb223ab7e2e6d3322dc/microsoft/TypeScript/issues/65581 |
| og:image:alt | 🔎 Search Terms Bug Report TypeScript Version: 7.0.2 Description TypeScript 7.0.2 incorrectly emits an unqualified namespace reference when using an import = alias inside a nested namespace. The com... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pirobox |
| 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