René's URL Explorer Experiment


Title: `extends enum` test for use in conditional types · Issue #24293 · microsoft/TypeScript · GitHub

Open Graph Title: `extends enum` test for use in conditional types · Issue #24293 · microsoft/TypeScript

X Title: `extends enum` test for use in conditional types · Issue #24293 · microsoft/TypeScript

Description: Search Terms enum isEnum mapped-types conditional-types enum-test extends-enum Suggestion Rephrased from : https://stackoverflow.com/questions/50452032/typescript-enum-type-check-for-conditional-types Here's what I kinda want, but it is ...

Open Graph Description: Search Terms enum isEnum mapped-types conditional-types enum-test extends-enum Suggestion Rephrased from : https://stackoverflow.com/questions/50452032/typescript-enum-type-check-for-conditional-ty...

X Description: Search Terms enum isEnum mapped-types conditional-types enum-test extends-enum Suggestion Rephrased from : https://stackoverflow.com/questions/50452032/typescript-enum-type-check-for-conditional-ty...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/24293

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`extends enum` test for use in conditional types","articleBody":"## Search Terms\r\n\r\nenum isEnum mapped-types conditional-types enum-test extends-enum\r\n\r\n## Suggestion\r\n\r\nRephrased from : https://stackoverflow.com/questions/50452032/typescript-enum-type-check-for-conditional-types\r\n\r\nHere's what I kinda want, but it is not syntactically valid:\r\n\r\n```typescript\r\nenum Features {\r\n  \"A\" = 1,\r\n  \"B\" = 2,\r\n  \"C\" = 2\r\n}\r\n\r\ntype EnumOrString\u003cT> = T extends enum\r\n  ? T | keyof T\r\n  : T\r\n\r\ndeclare function getData(featureFilter: EnumOrString\u003ctypeof Features>[]): Features[]\r\n```\r\n\r\n`getData` takes an array of the enum values or the enum keys but returns only the enum values.\r\n\r\nI also would want to extend this to mapped types similar to `DeepPartial` so that any nested enums all get this treatment - without having to have separate hierarchies of types partitioned by Request and Response.  [Example on Playground](https://www.typescriptlang.org/play/#src=export%20type%20DeepEnumish%3CT%3E%20%3D%0D%0A%20%20%20%20T%20extends%20any%5B%5D%20%3F%20DeepEnumishArray%3CT%5Bnumber%5D%3E%20%3A%0D%0A%20%20%20%20T%20extends%20enum%20%3F%20T%20%7C%20keyof%20T%20%3A%0D%0A%20%20%20%20T%20extends%20object%20%3F%20DeepEnumishObject%3CT%3E%20%3A%0D%0A%20%20%20%20T%3B%0D%0A%0D%0Aexport%20interface%20DeepEnumishArray%3CT%3E%20extends%20Array%3CDeepEnumish%3CT%3E%3E%20%7B%7D%0D%0A%0D%0Aexport%20type%20DeepEnumishObject%3CT%3E%20%3D%20%7B%0D%0A%20%20%20%20%5BP%20in%20keyof%20T%5D%3A%20DeepEnumish%3CT%5BP%5D%3E%3B%0D%0A%7D%0D%0A%0D%0Adeclare%20function%20roundtripPayload(criteria%20%3A%20DeepEnumish%3CPayload%3E)%3A%20Payload)\r\n\r\n## Use Cases\r\n\r\nI make calls to restful services that accept enum values as either the number value OR the string key, but the services always return just the number value.   I could ignore the ability to send strings, but some code would have to be rewritten because it happens to cache values by these key names.\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n* [x] This wouldn't be a breaking change in existing TypeScript / JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. new expression-level syntax)","author":{"url":"https://github.com/JasonKleban","@type":"Person","name":"JasonKleban"},"datePublished":"2018-05-21T15:51:27Z","url":"https://github.com/microsoft/TypeScript/issues/24293"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:448196fb-4e30-228a-e927-598bfcf7f199
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB880:2270F4:22D18AD:2E3467A:6B018C4E
html-safe-noncec160552cbb25a06f83d115e325773501cbbb267d858ee8f1aca59a9e3ead7617
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODgwOjIyNzBGNDoyMkQxOEFEOjJFMzQ2N0E6NkIwMThDNEUiLCJ2aXNpdG9yX2lkIjoiMzY4NTk4NzY1NTg3NjcwOTQ1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmace456edccddc3d10040cda376bad94a49802d2254ad9cf67ef12b1f5e5f23bea2
hovercard-subject-tagissue:324966407
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/24293/issue_layout
twitter:imagehttps://opengraph.githubassets.com/149d5073e18e01dc4fb1a602e0f6443c99181a70dd0fd51bf8044e2d049e9ff0/microsoft/TypeScript/issues/24293
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/149d5073e18e01dc4fb1a602e0f6443c99181a70dd0fd51bf8044e2d049e9ff0/microsoft/TypeScript/issues/24293
og:image:altSearch Terms enum isEnum mapped-types conditional-types enum-test extends-enum Suggestion Rephrased from : https://stackoverflow.com/questions/50452032/typescript-enum-type-check-for-conditional-ty...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJasonKleban
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/24293#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F24293
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F24293
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/24293
Reloadhttps://github.com/microsoft/TypeScript/issues/24293
Reloadhttps://github.com/microsoft/TypeScript/issues/24293
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/24293
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/24293
extends enum test for use in conditional typeshttps://github.com/microsoft/TypeScript/issues/24293#top
Needs More InfoThe issue still hasn't been fully clarifiedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20More%20Info%22
https://github.com/JasonKleban
JasonKlebanhttps://github.com/JasonKleban
on May 21, 2018https://github.com/microsoft/TypeScript/issues/24293#issue-324966407
https://stackoverflow.com/questions/50452032/typescript-enum-type-check-for-conditional-typeshttps://stackoverflow.com/questions/50452032/typescript-enum-type-check-for-conditional-types
Example on Playgroundhttps://www.typescriptlang.org/play/#src=export%20type%20DeepEnumish%3CT%3E%20%3D%0D%0A%20%20%20%20T%20extends%20any%5B%5D%20%3F%20DeepEnumishArray%3CT%5Bnumber%5D%3E%20%3A%0D%0A%20%20%20%20T%20extends%20enum%20%3F%20T%20%7C%20keyof%20T%20%3A%0D%0A%20%20%20%20T%20extends%20object%20%3F%20DeepEnumishObject%3CT%3E%20%3A%0D%0A%20%20%20%20T%3B%0D%0A%0D%0Aexport%20interface%20DeepEnumishArray%3CT%3E%20extends%20Array%3CDeepEnumish%3CT%3E%3E%20%7B%7D%0D%0A%0D%0Aexport%20type%20DeepEnumishObject%3CT%3E%20%3D%20%7B%0D%0A%20%20%20%20%5BP%20in%20keyof%20T%5D%3A%20DeepEnumish%3CT%5BP%5D%3E%3B%0D%0A%7D%0D%0A%0D%0Adeclare%20function%20roundtripPayload(criteria%20%3A%20DeepEnumish%3CPayload%3E)%3A%20Payload
JasonKlebanhttps://github.com/JasonKleban
on May 21, 2018https://github.com/microsoft/TypeScript/issues/24293#event-1637346526
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on May 21, 2018https://github.com/microsoft/TypeScript/issues/24293#issuecomment-390713574
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
Needs More InfoThe issue still hasn't been fully clarifiedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20More%20Info%22
on May 21, 2018https://github.com/microsoft/TypeScript/issues/24293#event-1637461461
https://github.com/JasonKleban
JasonKlebanhttps://github.com/JasonKleban
on May 21, 2018https://github.com/microsoft/TypeScript/issues/24293#issuecomment-390766112
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on May 21, 2018https://github.com/microsoft/TypeScript/issues/24293#issuecomment-390789650
https://github.com/jcalz
Joe Calzaretta (jcalz)https://github.com/jcalz
on May 22, 2018https://github.com/microsoft/TypeScript/issues/24293#issuecomment-391010945
https://github.com/typescript-bot
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
on Jun 6, 2018https://github.com/microsoft/TypeScript/issues/24293#issuecomment-395148012
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 6, 2018https://github.com/microsoft/TypeScript/issues/24293#event-1666698613
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/24293
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/24293
Needs More InfoThe issue still hasn't been fully clarifiedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20More%20Info%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.