Title: TS7 JSDoc `@overload` is ignored on `const` arrow function (works in 6.0.2, not in 7.0.2) · Issue #65558 · microsoft/TypeScript · GitHub
Open Graph Title: TS7 JSDoc `@overload` is ignored on `const` arrow function (works in 6.0.2, not in 7.0.2) · Issue #65558 · microsoft/TypeScript
X Title: TS7 JSDoc `@overload` is ignored on `const` arrow function (works in 6.0.2, not in 7.0.2) · Issue #65558 · microsoft/TypeScript
Description: 🔎 Search Terms JSDoc, overload, TS7 🕗 Version & Regression Information This changed between versions 6.0.3 and 7.0.2 ⏯ Playground Link No response 💻 Code main.js: #!/usr/bin/env node /** * @overload * @param {"a"} x * @returns {string} *...
Open Graph Description: 🔎 Search Terms JSDoc, overload, TS7 🕗 Version & Regression Information This changed between versions 6.0.3 and 7.0.2 ⏯ Playground Link No response 💻 Code main.js: #!/usr/bin/env node /** * @overloa...
X Description: 🔎 Search Terms JSDoc, overload, TS7 🕗 Version & Regression Information This changed between versions 6.0.3 and 7.0.2 ⏯ Playground Link No response 💻 Code main.js: #!/usr/bin/env node /** * @ove...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/65558
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TS7 JSDoc `@overload` is ignored on `const` arrow function (works in 6.0.2, not in 7.0.2)","articleBody":"### 🔎 Search Terms\n\nJSDoc, overload, TS7\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 6.0.3 and 7.0.2\n\n\n### ⏯ Playground Link\n\n_No response_\n\n### 💻 Code\n\n`main.js`:\n```js\n#!/usr/bin/env node\n/**\n * @overload\n * @param {\"a\"} x\n * @returns {string}\n */\n/**\n * @overload\n * @param {\"b\"} x\n * @returns {number}\n */\n/**\n * @param {\"a\" | \"b\"} x\n * @returns {string | number}\n */\nconst f = x => {\n if (x === \"a\") return \"100\";\n else if (x === \"b\") return 10;\n\n return x;\n}\n\n/**\n * @overload\n * @param {\"a\"} x\n * @returns {string}\n */\n/**\n * @overload\n * @param {\"b\"} x\n * @returns {number}\n */\n/**\n * @param {\"a\" | \"b\"} x\n * @returns {string | number}\n */\nfunction g(x) {\n if (x === \"a\") return \"100\";\n else if (x === \"b\") return 10;\n\n return x;\n}\n\nconsole.log(parseInt(f(\"a\"), 10));\nconsole.log(parseInt(g(\"a\"), 10));\n\n```\n`tsconfig.json`:\n```jsonc\n{\n \"compilerOptions\": {\n \"rootDir\": \".\",\n \"module\": \"EsNext\",\n \"target\": \"ES2025\",\n\n \"strict\": true,\n \"noEmit\": true,\n \"allowJs\": true,\n \"checkJs\": true,\n }\n}\n\n```\n\n`package.json`:\n```json\n{\n \"devDependencies\": {\n \"typescript6\": \"npm:typescript@6.0.3\",\n \"typescript7\": \"npm:typescript@7.0.2\"\n }\n}\n\n```\n\n### 🙁 Actual behavior\n\nWith TypeScript 7.0.2, the JSDoc `@overload` tags on a `const` arrow function are ignored. The function is typed from its implementation signature instead, so `f(\"a\")` returns `string | number` rather than `string`.\n\nHovering `f` in tsserver shows:\n\n```ts\nconst f: (x: \"a\" | \"b\") => string | number\n```\n\nwith no `(+1 overload)` suffix. As a result, `parseInt(f(\"a\"), 10)` fails:\n\n```\nerror TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'.\nType 'number' is not assignable to type 'string'.\n```\n\nThis is wrong because:\n- The identical overloads work in TypeScript 6.0.3 (no error).\n- The identical overloads work in 7.0.2 when declared with `function g(x) {}` instead of `const f = x => {}`.\n\n### 🙂 Expected behavior\n\n`@overload` tags should be recognized on a `const` arrow function, the same way as in TypeScript 6.0.2.\n\nHovering `f` should show the overload signatures:\n\n```ts\nconst f: {\n (x: \"a\"): string;\n (x: \"b\"): number;\n}\n```\n\nso `f(\"a\")` returns `string` and `parseInt(f(\"a\"), 10)` type-checks without errors.\n\nThis is expected because:\n- The same code produces the type above in TypeScript 6.0.2.\n- The same overloads on a `function` declaration (`g` in the example) already work in 7.0.2, so the declaration form alone should not change the result.\n\n### Additional information about the issue\n\n## Versions\n\n- typescript 6.0.3: no error\n- typescript 7.0.2: error on the `f(\"a\")` line only\n- Node: v26.9.0\n- OS: Windows 11 26H2\n\n## Environment\nReproduced in a clean Docker container:\n\n```Dockerfile\nFROM node:26-slim\nWORKDIR /app\nCOPY package*.json .\nRUN npm i\nCOPY . .\nCMD [\"sh\", \"run.sh\"]\n\n```\n- Image: node:26-slim (Node v26.13.1)\n- typescript 6.0.3: no error\n- typescript 7.0.2: error on the `f(\"a\")` line only\n\n## Workaround\n\nDeclaring the function with `function f(x) {}` instead of `const f = x => {}` makes the overloads work in 7.0.2.","author":{"url":"https://github.com/abc-abc-ab","@type":"Person","name":"abc-abc-ab"},"datePublished":"2026-11-18T05:13:21Z","url":"https://github.com/microsoft/TypeScript/issues/65558"}
| 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:c81af9d8-9f87-ff0e-5d16-9711be59e0b3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD02:22DB35:9AFA79:C9A440:6B00E144 |
| html-safe-nonce | a27f5a41b2224a089ee16634b011fc8ab14d9ccc09c1b8ebe100173fda309238 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDAyOjIyREIzNTo5QUZBNzk6QzlBNDQwOjZCMDBFMTQ0IiwidmlzaXRvcl9pZCI6IjQ0NzU1MTczOTc4MTc2ODAxOTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b98f290fe9778c4cbc07313c2e1d98b27332f4e24b43346875e01ea61a6700f9 |
| hovercard-subject-tag | issue:6460502796 |
| 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/65558/issue_layout |
| twitter:image | https://opengraph.githubassets.com/de2086379fbc792b3102c714fb74093fc1b2086e230f2100649a68ba8761b426/microsoft/TypeScript/issues/65558 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/de2086379fbc792b3102c714fb74093fc1b2086e230f2100649a68ba8761b426/microsoft/TypeScript/issues/65558 |
| og:image:alt | 🔎 Search Terms JSDoc, overload, TS7 🕗 Version & Regression Information This changed between versions 6.0.3 and 7.0.2 ⏯ Playground Link No response 💻 Code main.js: #!/usr/bin/env node /** * @overloa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abc-abc-ab |
| 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