Title: TS7 fails assign type predicates via the JSDoc `@type` tag to functions without an explicit `function` keyword · Issue #65549 · microsoft/TypeScript · GitHub
Open Graph Title: TS7 fails assign type predicates via the JSDoc `@type` tag to functions without an explicit `function` keyword · Issue #65549 · microsoft/TypeScript
X Title: TS7 fails assign type predicates via the JSDoc `@type` tag to functions without an explicit `function` keyword · Issue #65549 · microsoft/TypeScript
Description: 🔎 Search Terms predicate,TS7 🕗 Version & Regression Information This changed between versions 6 and 7 (tested on 7.1.0-beta) ⏯ Playground Link No response 💻 Code /** @type {(el: Node) => el is HTMLElement} */ const func1 = (el) => el ins...
Open Graph Description: 🔎 Search Terms predicate,TS7 🕗 Version & Regression Information This changed between versions 6 and 7 (tested on 7.1.0-beta) ⏯ Playground Link No response 💻 Code /** @type {(el: Node) => el is HTML...
X Description: 🔎 Search Terms predicate,TS7 🕗 Version & Regression Information This changed between versions 6 and 7 (tested on 7.1.0-beta) ⏯ Playground Link No response 💻 Code /** @type {(el: Node) => el ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/65549
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TS7 fails assign type predicates via the JSDoc `@type` tag to functions without an explicit `function` keyword","articleBody":"### 🔎 Search Terms\n\npredicate,TS7\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 6 and 7 (tested on 7.1.0-beta)\n\n\n### ⏯ Playground Link\n\n_No response_\n\n### 💻 Code\n\n```js\n/** @type {(el: Node) => el is HTMLElement} */\nconst func1 = (el) => el instanceof HTMLElement && el.className === \"foo\";\n\n/** @type {(el: Node) => el is HTMLElement} */\nconst func2 = (el) => el instanceof HTMLElement;\n\n/**\n * @param {Node} el\n * @returns {el is HTMLElement}\n */\nconst func3 = (el) => el instanceof HTMLElement && el.className === \"foo\";\n\n/** @type {(el: Node) => el is HTMLElement} */\nfunction func4 (el) {\n return el instanceof HTMLElement && el.className === \"foo\";\n}\n```\n\n\n### 🙁 Actual behavior\n\nThe `func1` example fails to assign the predicate, throwing an error instead\n```\nerror TS2322: Type '(el: Node) => boolean' is not assignable to type '(el: Node) => el is HTMLElement'.\n Signature '(el: Node): boolean' must be a type predicate.\n\nconst func1 = (el) => el instanceof HTMLElement && el.className === \"foo\";\n```\n\n### 🙂 Expected behavior\n\nAll four functions are correctly declared as type predicates and live happily ever after\n\n### Additional information about the issue\n\nThe issue here (TS failing to assign a function return type as a type predicate) consists of the following elements:\n* The function is annotated via the `@type` JSDoc tag\n* The function must lack an explicit `function` keyword in its declaration\n* The actual code must be, for lack of a better description, of \"reasonable\" complexity, _e.g._ more than just an `instanceof` check (see the Code section).","author":{"url":"https://github.com/bananarama92","@type":"Person","name":"bananarama92"},"datePublished":"2026-11-17T16:45:06Z","url":"https://github.com/microsoft/TypeScript/issues/65549"}
| 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:25ccbbfe-6cb3-eae6-2e46-3b9b893706a8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AFE2:EDA7A:6898E8:86C609:6B00E135 |
| html-safe-nonce | 406278f1198245874a16a5d1223c1476d9f18d53161d9b42637857905cbc87d2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkUyOkVEQTdBOjY4OThFODo4NkM2MDk6NkIwMEUxMzUiLCJ2aXNpdG9yX2lkIjoiNTU3MzkwMjcwMDQ4NTA3NTI1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 65c09993ee1750d864faa38c3fc60cf2a9fa2ec66a4770bea7f10a6996257f50 |
| hovercard-subject-tag | issue:6449490784 |
| 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/65549/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1934b3b6fb5d187e189b18244c37750bae5e565ee6ee7c96eef099add6d7cdf0/microsoft/TypeScript/issues/65549 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1934b3b6fb5d187e189b18244c37750bae5e565ee6ee7c96eef099add6d7cdf0/microsoft/TypeScript/issues/65549 |
| og:image:alt | 🔎 Search Terms predicate,TS7 🕗 Version & Regression Information This changed between versions 6 and 7 (tested on 7.1.0-beta) ⏯ Playground Link No response 💻 Code /** @type {(el: Node) => el is HTML... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bananarama92 |
| 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