Title: 7.0 regression: expando property on a function declaration is dropped when a merged namespace exports a type with the same name (TS2339) · Issue #65600 · microsoft/TypeScript · GitHub
Open Graph Title: 7.0 regression: expando property on a function declaration is dropped when a merged namespace exports a type with the same name (TS2339) · Issue #65600 · microsoft/TypeScript
X Title: 7.0 regression: expando property on a function declaration is dropped when a merged namespace exports a type with the same name (TS2339) · Issue #65600 · microsoft/TypeScript
Description: 🔎 Search Terms expando, expando namespace, namespace merge, function namespace merge, property assignment, type-only namespace, TS2339, "does not exist on type", compound component, static property 🕗 Version & Regression Information This...
Open Graph Description: 🔎 Search Terms expando, expando namespace, namespace merge, function namespace merge, property assignment, type-only namespace, TS2339, "does not exist on type", compound component, static property...
X Description: 🔎 Search Terms expando, expando namespace, namespace merge, function namespace merge, property assignment, type-only namespace, TS2339, "does not exist on type", compound component, stati...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/65600
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"7.0 regression: expando property on a function declaration is dropped when a merged namespace exports a type with the same name (TS2339)","articleBody":"### 🔎 Search Terms\n\nexpando, expando namespace, namespace merge, function namespace merge, property assignment, type-only namespace, TS2339, \"does not exist on type\", compound component, static property\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 6.0.3 and 7.0.2 (still present in 7.1.0-beta and 7.1.0-dev.20261120.1)\n- This changed in commit or PR microsoft/typescript-go#2715 (\"Defer binding of expando assignments and give them lower priority\"). `@typescript/native-preview@7.0.0-dev.20260209.1` has no error, `7.0.0-dev.20260210.1` reports it. #2715 is the only expando-related commit between those two builds.\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/v2/?ts=next#code/v2/N4IghgxgLglgbgUwGIwDYJALhAegO4D2ATgNYDOADpAjlGRAQHYBmMA5gHQBWZTIANCFboyWUPmLkqEGnQYt23XoywhgAAgA6IBgFsKaBEQDyFWEzLbM6jdrJQiMaFfUOArgn5aQUMETYIUC7aCGQATAAMYWHa6gC+8QK4hKSU1DhkRBA4MIwAJggAHhx0qsxujNAwTOrMABQAlDZxmiwcYOoAvOoRANytjGC6odIItTbqRRTEUK4AnhRjHd198a0gcYJkCOhVfJig02Qw5owAwgSobroqmABsYYJHJ9WMADK5CABy1wBGRlgAIxbHYIPaMADKviIUAuVxuWAeIN2pyhfigH0Y3z+AMwgM2IEQRGO+zCcSAA\n\n### 💻 Code\n\n```ts\nfunction f() {}\nf.a = 0;\nnamespace f { export type a = 0; }\n```\n\nReal-world shape (this is how Mantine declares its compound components, e.g. `Popover.Target` with a `Popover.Target.Props` type):\n\n```ts\nexport function Popover() { return null; }\nPopover.Target = (x: number) => x;\nPopover.displayName = \"Popover\";\n\nexport namespace Popover {\n export namespace Target {\n export type Props = number;\n }\n}\n\nPopover.Target(1);\nPopover.displayName;\n```\n\n### 🙁 Actual behavior\n\n7.0.2, 7.1.0-beta and 7.1.0-dev.20261120.1:\n\n```\nmin.ts(2,3): error TS2339: Property 'a' does not exist on type '() => void'.\n```\n\n```\nrepro.ts(2,9): error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'.\nrepro.ts(11,9): error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'.\n```\n\nThe value property `a` (or `Target`) is removed from the function's type because the merged namespace has a type-only export with the same name. `displayName`, which has no namespace counterpart, is kept.\n\n### 🙂 Expected behavior\n\nNo error, as in 6.0.3. The namespace member is type-only (a type alias, an interface, or a namespace that contains only types), so it does not declare a value named `a`. The expando assignment is the only value declaration for that name and should still create the property. In 6.0.3, `f.a` is typed as `number` (`const s: string = f.a` reports TS2322 \"Type 'number' is not assignable to type 'string'\").\n\n### Additional information about the issue\n\nFrom reading the binder, an expando is now declared only when the name has no existing non-expando declaration:\n\n```go\n// tsc/internal/binder/binder.go\n// We declare expandos only when there are no non-expando declarations for that name.\nif existing := exports.Get(b.getDeclarationName(node)); existing == nil || existing.Flags()&ast.SymbolFlagsAssignment != 0 {\n```\n\nThis check does not appear to consider whether the existing declaration has a value meaning, so a type alias, an interface or an uninstantiated namespace also suppresses the property. #2715 was prompted by a value conflict (microsoft/typescript-go#2653: a `declare class` static member plus an expando assignment).\n\nResults by variant, each file ending with `const n: number = f.a;` (`--strict --noEmit --target es2022`):\n\n| Variant | 6.0.3 | 7.0.2 |\n| --- | --- | --- |\n| `export type a` in the namespace (minimal repro) | no error | TS2339 |\n| `export interface a {}` in the namespace | no error | TS2339 |\n| `export namespace a {}` (empty) | no error | TS2339 |\n| `export namespace a` containing only types | no error | TS2339 |\n| namespace declared before the function | no error | TS2339 |\n| non-exported `type a` in the namespace | no error | no error |\n| namespace without a member named `a` | no error | no error |\n| no namespace at all | no error | no error |\n| `const f = () => {}` instead of `function f() {}` | no error | no error |\n| property declared in the type (`declare const f: { (): void; a: number }`) | no error | no error |\n| namespace member `a` also contains a value (`export const kind = 0`) | TS2300 Duplicate identifier | TS2322 (different errors, both reject the code) |","author":{"url":"https://github.com/MartinFerret","@type":"Person","name":"MartinFerret"},"datePublished":"2026-11-20T09:52:39Z","url":"https://github.com/microsoft/TypeScript/issues/65600"}
| 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:5dd1088a-947c-babd-c896-7f75de69c654 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E8B0:3F8AB1:9F8709:CEA8E7:6B00E10F |
| html-safe-nonce | 2caf8d4f67a55a6e280262e2d66d5cfc428d9c75bb387c49f6ac8bb09e8f178f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOEIwOjNGOEFCMTo5Rjg3MDk6Q0VBOEU3OjZCMDBFMTBGIiwidmlzaXRvcl9pZCI6IjczOTI3Mzg4NDgzMTQyODYzNTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2ec703d05ba5f00de289508c08f380b22896f46662bb251c30158c537f7cfbc4 |
| hovercard-subject-tag | issue:6509039993 |
| 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/65600/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d9d53bfedfbdc4523f78ac1dce2ae62d8b1337e56e777969ec5dfed38d22228/microsoft/TypeScript/issues/65600 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d9d53bfedfbdc4523f78ac1dce2ae62d8b1337e56e777969ec5dfed38d22228/microsoft/TypeScript/issues/65600 |
| og:image:alt | 🔎 Search Terms expando, expando namespace, namespace merge, function namespace merge, property assignment, type-only namespace, TS2339, "does not exist on type", compound component, static property... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MartinFerret |
| 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