Title: asserts that return type is null | Generic
Open Graph Title: asserts that return type is null | Generic
X Title: asserts that return type is null | Generic
Description: Bug Report 🔎 Search Terms asserts generic null asserts array null 🕗 Version & Regression Information This is the behavior in every version I tried (3.7 on the playground as asserts did appear in 3.7 IIRC), and I reviewed the FAQ for entr...
Open Graph Description: Bug Report 🔎 Search Terms asserts generic null asserts array null 🕗 Version & Regression Information This is the behavior in every version I tried (3.7 on the playground as asserts did appear in 3....
X Description: Bug Report 🔎 Search Terms asserts generic null asserts array null 🕗 Version & Regression Information This is the behavior in every version I tried (3.7 on the playground as asserts did appear i...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/49588
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"asserts that return type is null | Generic\u003cT> is reported as `null` and lose the generic","articleBody":"# Bug Report\r\n\r\n\u003c!--\r\n Please fill in each section completely. Thank you!\r\n-->\r\n\r\n### 🔎 Search Terms\r\n\r\n\u003c!--\r\n What search terms did you use when trying to find an existing bug report?\r\n List them here so people in the future can find this one more easily.\r\n-->\r\n- asserts generic null \r\n- asserts array null \r\n\r\n### 🕗 Version & Regression Information\r\n\r\n\u003c!-- When did you start seeing this bug occur?\r\n\r\n\"Bugs\" that have existed in TS for a long time are very likely to be FAQs; refer to\r\n https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs\r\n\r\nIf possible, please try testing the nightly version of TS to see if it's already been fixed.\r\nFor npm: `typescript@next`\r\nThis is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly\r\n\r\nNote: The TypeScript Playground can be used to try older versions of TypeScript.\r\n\r\nPlease keep and fill in the line that best applies:\r\n-->\r\n- This is the behavior in every version I tried (3.7 on the playground as asserts did appear in 3.7 IIRC), and I reviewed the FAQ for entries about null asserts\r\n\r\n### ⏯ Playground Link\r\n\r\n\u003c!--\r\n A link to a TypeScript Playground \"Share\" link which shows this behavior\r\n\r\n The TypeScript Workbench can be used for more complex setups, try\r\n https://www.typescriptlang.org/dev/bug-workbench/\r\n\r\n As a last resort, you can link to a repo, but these will be slower for us to investigate.\r\n-->\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?ts=4.8.0-dev.20220616#code/C4TwDgpgBAKglgYwNYWFAvFA3gXwFCiSyIrAAycAzmpgHYCuANo1AD5QCCATlwIYgAealzi0A5m2LJUAPjx4AZvVoJgcAPa0ovSpQhdgAJQiNeazQElKAOXXBrTRgIBqMgBQA3AFxRnkhswAlD46egaUUB5QVFC2tA7MvABGjBAuMtj4SirmWqH6RiZmGrRWCYwA8lwU1BUKAMrAIuKePtx8gsKiEuzw0sAZ7AGMwdq6BRFRMe38Qk3dg1DDmYrKqiVQwBDUNcB1xqa5bmr9uz59pLuB2HhQmySouwDct1AA9G93XwB6APzyd3yBgOxUsNkcVV2dUazTExwe5CowECAPupyRLzuHy+dz+r2xEAAHpBVBAACabcDQGIAA2W7BmnXm4hkNLw+AIVKkpBBuQwS0cki64kkF1QqxyGyBhUOJTKEK4MO6rQFzCFzJ63NQo2lk2iEWFmuWuHk2XWmk22xloNo8P6B3OCN5JWuWFeJx5Jkx70+OLxr2lzrB5SqSpaHtQBxR7qdXvxvp+-yxnzJ6m2UAA7uouEgoApRNAM3BgAALdT0NA0xlsjmiLZcBS8BDQADiEFo+kQAhgGTddw8vEY9Ag5xeHLNfMDRVy8uYVTbHZECGhGpVC87CDmsNFCMWwx143CkX1UHXS63C38gpNnKIYuAZ8Q-Ppp-bG4vIt6u4l5q0W2oj4IHapCAY6-SAa6MbgW+S7etifr-AGh7WjO4JzlwgErrCwGoBB8ZTrKwZ2OUOEPjBiDRncEZkYuiBwQmuJJj6UBEiSWwUoQ1IRHSgrsIBH5iKy7JAA)\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well-->\r\n```ts\r\ninterface Generic\u003cT> { value: T; }\r\ntype Ticket = {}\r\ntype TicketGeneric = null | Generic\u003cstring | Ticket>\r\n\r\nfunction assertRelationIsNullOrGenericOfString(v: Generic\u003cstring | Ticket> | null): asserts v is Generic\u003cstring> | null {}\r\n\r\nfunction testGeneric(ticketGeneric: TicketGeneric) {\r\n assertRelationIsNullOrGenericOfString(ticketGeneric)\r\n\r\n ticketGeneric; // expected type is `null | Generic\u003cstring>` but gave `null`\r\n}\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nWhen an asserter return `null` or a Generic, it is reported as `null`.\r\nIt does this for every generic, even `Array\u003cstring>`. If the return type is not a generic, it does work fine (with `null | string` for exemple)\r\n\r\n### 🙂 Expected behavior\r\n\r\nIt should be marked as `null | Generic\u003cstring>`\r\n\r\nThank you!\r\n","author":{"url":"https://github.com/jdeniau","@type":"Person","name":"jdeniau"},"datePublished":"2022-06-17T07:18:22Z","url":"https://github.com/microsoft/TypeScript/issues/49588"}
| 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:38d389d8-00bc-d5ee-2321-7c5c5ba47b8d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1A6:CC1A4:ACDC7A:DD4776:6B00F54D |
| html-safe-nonce | 9e38dc05d51fbefe9b85e3cb88d3c1839c2a7ad27319327c41f8e7ef8d1eb563 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUE2OkNDMUE0OkFDREM3QTpERDQ3NzY6NkIwMEY1NEQiLCJ2aXNpdG9yX2lkIjoiODMwMjg2NjI1NDM4MjMzOTMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | bb31f377dc0cb8b0a068ae332cd118a477c118deb2656bb9cd4108bb1660e92d |
| hovercard-subject-tag | issue:1274665585 |
| 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/49588/issue_layout |
| twitter:image | https://opengraph.githubassets.com/340de0b8f9de67abfb796cf2e62d9a21aae81d1291ce20fdc8f7c3be65db661b/microsoft/TypeScript/issues/49588 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/340de0b8f9de67abfb796cf2e62d9a21aae81d1291ce20fdc8f7c3be65db661b/microsoft/TypeScript/issues/49588 |
| og:image:alt | Bug Report 🔎 Search Terms asserts generic null asserts array null 🕗 Version & Regression Information This is the behavior in every version I tried (3.7 on the playground as asserts did appear in 3.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jdeniau |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width