Title: Using startsWith & endsWith to narrow type · Issue #46958 · microsoft/TypeScript · GitHub
Open Graph Title: Using startsWith & endsWith to narrow type · Issue #46958 · microsoft/TypeScript
X Title: Using startsWith & endsWith to narrow type · Issue #46958 · microsoft/TypeScript
Description: lib Update Request Configuration Check My compilation target is ES2020 and my lib is ES2020. Missing / Incorrect Definition startsWith & endsWith doesn't narrow the the type, it just returns a boolean. Sample Code interface BuiltinPaymen...
Open Graph Description: lib Update Request Configuration Check My compilation target is ES2020 and my lib is ES2020. Missing / Incorrect Definition startsWith & endsWith doesn't narrow the the type, it just returns a bool...
X Description: lib Update Request Configuration Check My compilation target is ES2020 and my lib is ES2020. Missing / Incorrect Definition startsWith & endsWith doesn't narrow the the type, it just return...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/46958
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using startsWith & endsWith to narrow type","articleBody":"# lib Update Request\r\n\r\n## Configuration Check\r\n\r\nMy compilation *target* is `ES2020` and my *lib* is `ES2020`.\r\n\r\n## Missing / Incorrect Definition\r\n\r\n`startsWith` & `endsWith` doesn't narrow the the type, it just returns a boolean.\r\n\r\n## Sample Code\r\n\r\n```typescript\r\ninterface BuiltinPaymentMethod {\r\n id: `builtin-${string}`\r\n // ...\r\n}\r\n\r\n// ...\r\n\r\ndeclare const id: string\r\n\r\nif (id.startsWith('builtin-')) {\r\n // Here I want `id` to be typed as `builtin-${string}`\r\n}\r\n```\r\n\r\n## Documentation Link\r\n\r\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith\r\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith\r\n\r\n## Pull Request\r\n\r\nhttps://github.com/microsoft/TypeScript/pull/46959 🚀 ","author":{"url":"https://github.com/LinusU","@type":"Person","name":"LinusU"},"datePublished":"2021-11-30T17:07:04Z","url":"https://github.com/microsoft/TypeScript/issues/46958"}
| 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:d568fda8-558d-b46f-9054-3ba109b5825f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A6F6:392C58:14CEA4:1BA12F:6B04CA99 |
| html-safe-nonce | 956689d6d571697da0b55137119986ee69dd8cead266dbcc749b43c1ddceba72 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkY2OjM5MkM1ODoxNENFQTQ6MUJBMTJGOjZCMDRDQTk5IiwidmlzaXRvcl9pZCI6Ijc2NjAxMTI1OTY5ODg5MDYxMzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | aa834b0a5a3d2541c28644fdf0865f854ca1f94d70162114193c195547d42e44 |
| hovercard-subject-tag | issue:1067475082 |
| 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/46958/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f598b36380f2c84c53b2c9846a0f459162eb6e99d866a7c012a4108618d94f16/microsoft/TypeScript/issues/46958 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f598b36380f2c84c53b2c9846a0f459162eb6e99d866a7c012a4108618d94f16/microsoft/TypeScript/issues/46958 |
| og:image:alt | lib Update Request Configuration Check My compilation target is ES2020 and my lib is ES2020. Missing / Incorrect Definition startsWith & endsWith doesn't narrow the the type, it just returns a bool... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LinusU |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27ed421e5c2dac040a37529b5b9191edcc4a3de70521471e81fb4b4d9dc2aa7d |
| 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 | 63dc19014c621c67306d7899c04c78dcd0d95803 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width