Title: Type 'null' is not assignable to type 'T extends T ? null : Omit
Open Graph Title: Type 'null' is not assignable to type 'T extends T ? null : Omit
X Title: Type 'null' is not assignable to type 'T extends T ? null : Omit
Description: 🔎 Search Terms "conditional type equality", "transitive generic type equality" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed https://github.com/Microsoft/TypeScript/wiki/FAQ ⏯ Playground...
Open Graph Description: 🔎 Search Terms "conditional type equality", "transitive generic type equality" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed https://github.com/Mi...
X Description: 🔎 Search Terms "conditional type equality", "transitive generic type equality" 🕗 Version & Regression Information This is the behavior in every version I tried, and I review...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/60076
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type 'null' is not assignable to type 'T extends T ? null : Omit\u003cT, keyof T>'","articleBody":"### 🔎 Search Terms\n\n\"conditional type equality\", \"transitive generic type equality\"\n\n### 🕗 Version & Regression Information\n\n- This is the behavior in every version I tried, and I reviewed https://github.com/Microsoft/TypeScript/wiki/FAQ\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?ts=5.7.0-dev.20240926#code/C4TwDgpgBAKhC2YA2BDYEA8MB8UC8UAFGCgE4rwDOAXLAJT64BuA9gJYAmA3AFA9sA7dKQBmKAMbQAQoI6CA5gAUyFSlADePKFHgRKlFPIi1KwUgt4BfPoOFjJUAEoQBHCOYFKVVDVqhgPYABZPQMjWjhEVHQMAQBXJCRsKz5xFgFTKAAjWQVI5DRjWAQCmJlXBWVyKlw8P2JvGihyuU8q1QY8XDSMliQIADokFnkG6soB3X1DCDpeHh7M0hc3D3l86KKNwoxnV3dKxtr6knHaPdXD8c7cU9UBgNsQ6aNCeMS5vhE4gXFgNnS2VkWAANFBFFAIAAPdCuNRVf4oJBYbDYQjACIlTYosFgWiKBiabSLYDZFg-DjbdD4Ig3DSWXjaZbAOKkARkilU6AoNQ-ADWAhYAHd2TzilEdhDobCOGoYFAAPxQd5IKC0ADy8DYwFBUD5EBALBE4NRKR431+-0By32pBR6MxEpiOFxETotFYnF82mAxE+1nNPz+APZNtWAHEXAdxEikCB7RjxaVMC7-G7vVASRzXFyaTlXOjcZ8mSt3IQwwdPFywepHkJnmEillyTmsYVLP6vkGraHS6QAMqQcRsERsGOJECEQl+LPNzlt6kEfMcQjLvILiA1qaN2gAchELBYu47jKgFdI5b766dm40deCoRmtDnrZvJ54AfPkYE0djk7XVYbluj7hFA+6HsenznoOEDDqO45xlOXBAA\n\n### 💻 Code\n\n```ts\r\ntype Template\u003cT> = (params: T) => void;\r\n\r\ninterface BindingParams {\r\n message: string;\r\n}\r\n\r\ninterface RenderingParams {\r\n printMessage: Template\u003cnull>;\r\n}\r\n\r\nconst bindingTemplate: Template\u003cBindingParams> =\r\n (params: BindingParams) => console.log(params.message);\r\n\r\nconst renderingTemplate: Template\u003cRenderingParams> =\r\n (params: RenderingParams) => params.printMessage(null);\r\n\r\nfunction bind\u003cT, P extends Partial\u003cT>>(t: Template\u003cT>, p: P) {\r\n const boundTemplate = () => {};\r\n return boundTemplate as unknown as Template\u003cP extends T ? null : Omit\u003cT, keyof P>>;\r\n}\r\n\r\nfunction render\u003cT>(t: Template\u003cT>, p: T): void {\r\n t(p);\r\n}\r\n\r\nfunction renderGenerically\u003cT>(t: Template\u003cT>, p: T) {\r\n const boundTemplate = bind(t, p);\r\n render(renderingTemplate, {printMessage: boundTemplate});\r\n}\r\n\r\nfunction renderSpecifically() {\r\n const boundTemplate = bind(bindingTemplate, {message: 'foo'});\r\n render(renderingTemplate, {printMessage: boundTemplate});\r\n}\r\n\r\nrenderGenerically(bindingTemplate, {message: 'foo'});\r\nrenderSpecifically();\r\n```\r\n\n\n### 🙁 Actual behavior\n\nGot the error:\r\n```\r\nType 'null' is not assignable to type 'T extends T ? null : Omit\u003cT, keyof T>'\r\n```\r\n\r\nSeems like the TS compiler should be able to figure out that `T extends T` is `true`?\n\n### 🙂 Expected behavior\n\nNo error. Since `T extends T` should be `true`, `null` should be assignable to `null`\n\n### Additional information about the issue\n\nThis may be related to https://github.com/Microsoft/TypeScript/issues/27024#issue-358956816 (?)","author":{"url":"https://github.com/jacobamills","@type":"Person","name":"jacobamills"},"datePublished":"2024-09-26T18:56:12Z","url":"https://github.com/microsoft/TypeScript/issues/60076"}
| 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:fb92c3c5-e074-88ed-f0c4-a03315caf85a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1A8:29AEE8:15B301A:1CE6CBB:6B013656 |
| html-safe-nonce | cacaee38943625894a88292c97447a25dfe4fa267b35d61b0d5179d4615c3ddf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUE4OjI5QUVFODoxNUIzMDFBOjFDRTZDQkI6NkIwMTM2NTYiLCJ2aXNpdG9yX2lkIjoiNDI3OTgxODQyODQ1MTIwNjc0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 99a765e1dd54a65c5cb36d8f91b5401d64a1a187ae173f8df5a997de52a54389 |
| hovercard-subject-tag | issue:2551324885 |
| 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/60076/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5cd2aaefb92363a0c83d6254736d369c828d22fcd9b64b343c8ea8d80e9af3e0/microsoft/TypeScript/issues/60076 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5cd2aaefb92363a0c83d6254736d369c828d22fcd9b64b343c8ea8d80e9af3e0/microsoft/TypeScript/issues/60076 |
| og:image:alt | 🔎 Search Terms "conditional type equality", "transitive generic type equality" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed https://github.com/Mi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jacobamills |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width