René's URL Explorer Experiment


Title: Confusing error messages, invalid intellisense and no auto-complete with Tagged Unions that use string based Discriminators · Issue #10849 · microsoft/TypeScript · GitHub

Open Graph Title: Confusing error messages, invalid intellisense and no auto-complete with Tagged Unions that use string based Discriminators · Issue #10849 · microsoft/TypeScript

X Title: Confusing error messages, invalid intellisense and no auto-complete with Tagged Unions that use string based Discriminators · Issue #10849 · microsoft/TypeScript

Description: VsCode: 1.5.1 Typescript: 2.0.2 Window 10: 1607 I create a group of tagged unions that discriminate on the 'bundle' property which then causes a further discrimination on the values of the 'id' property: export module ModIcons_climacons ...

Open Graph Description: VsCode: 1.5.1 Typescript: 2.0.2 Window 10: 1607 I create a group of tagged unions that discriminate on the 'bundle' property which then causes a further discrimination on the values of the 'id' pro...

X Description: VsCode: 1.5.1 Typescript: 2.0.2 Window 10: 1607 I create a group of tagged unions that discriminate on the 'bundle' property which then causes a further discrimination on the values of the ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Confusing error messages, invalid intellisense and no auto-complete with Tagged Unions that use string based Discriminators","articleBody":"\u003c!-- BUGS: Please use this template. -->\n\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\n\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\n- VsCode:  **1.5.1**\n- Typescript: **2.0.2**\n- Window 10: **1607**\n\nI create a group of tagged unions that discriminate on the **'bundle'** property which then causes a further discrimination on the values of the **'id'** property:\n\n``` ts\nexport module ModIcons_climacons {\n    export type DIcons_climacons = 'cloud' | 'cloud.sun' | 'cloud.moon' | 'rain' | 'rain.cloud' | 'rain.sun' | 'rain.cloud.sun' | 'rain.moon';\n\n    export interface IIcons_climacons {\n        bundle: \"climacons\";\n        id: DIcons_climacons;\n    }\n}\nexport module ModIcons_devicon {\n    export type DIcons_devicon = 'postgresql-plain' | 'postgresql-plain-wordmark' | 'postgresql-plain.colore' \n    | 'postgresql-plain-wordmark.colore' | 'nodejs-plain';\n\n    export interface IIcons_devicon {\n        bundle: \"devicon\";\n        id: DIcons_devicon;\n    }\n}\n\nexport module ModIcons_dripicons {\n    export type DIcons_dripicons = 'align-center' | 'align-justify' | 'align-left' | 'align-right' | 'arrow-down' | 'arrow-left' | 'arrow-thin-down' | 'arrow-right' | 'arrow-thin-left' | 'arrow-thin-up' | 'arrow-up' | 'attachment' | 'arrow-thin-right' | 'code' | 'cloud' | 'chevron-right' | 'chevron-up';\n\n    export interface IIcons_dripicons {\n        bundle: \"dripicons\";\n        id: DIcons_dripicons;\n    }\n}\n\nexport module ModIcons_feather {\n    export type DIcons_feather = 'eye' | 'paper-clip' | 'mail' | 'toggle' | 'layout' | 'link' | 'bell' | 'lock' | 'unlock' | 'ribbon' | 'image' | 'signal' | 'target' | 'clipboard' | 'clock' | 'watch' | 'air-play' | 'camera' | 'video' | 'disc' | 'printer' | 'monitor' | 'server' | 'cog' | 'heart' | 'paragraph' | 'align-justify' | 'align-left' | 'align-center' | 'align-right' | 'book' | 'layers' | 'stack' | 'stack-2' | 'paper' | 'paper-stack' | 'search' | 'zoom-in' | 'zoom-out' | 'reply' | 'circle-plus' | 'circle-minus' | 'circle-check' | 'circle-cross' | 'square-plus' | 'square-minus' | 'square-check' | 'square-cross' | 'microphone' | 'record' | 'skip-back' | 'rewind' | 'play' | 'pause' | 'stop' | 'fast-forward' | 'skip-forward' | 'shuffle' | 'repeat' | 'folder' | 'umbrella' | 'moon' | 'thermometer' | 'drop' | 'sun' | 'cloud' | 'cloud-upload' | 'cloud-download';\n\n    export interface IIcons_feather {\n        bundle: \"feather\";\n        id: DIcons_feather;\n    }\n}\n\n```\n\nI then create a tagged type union of the interfaces above with one additional interface of the same shape but that allows any value in the **'id'** property:\n\n``` ts\n\nexport interface IIconGlyphUnsafe {\n    bundle: 'unsafe';\n    id: string;\n}\n\nexport type UAll_Icons =  iconsBase.IIconGlyphUnsafe | ModIcons_climacons.IIcons_climacons | ModIcons_devicon.IIcons_devicon \n| ModIcons_feather.IIcons_feather | ModIcons_dripicons.IIcons_dripicons;\n\n```\n# Case 1\n\nI consume the tagged union in a simple example like so:\n\n``` ts\nclass Hello {\n\n  props: Icons.UAll_Icons;\n\n  Test() {\n    this.props = {\n    };\n\n  }\n}\n```\n\nHowever, I get the following error message:\n\n\u003cimg width=\"432\" alt=\"image1-dripicons-highlighted\" src=\"https://cloud.githubusercontent.com/assets/3457767/18414891/88fd9486-77a9-11e6-964b-c958268ca399.png\">\n\nThe message on line 2 is arbitrarily stating the type is not assignable to **'IIcons_dripicon'** which is 1 of the 5 tagged union types.\n\n**Expected behavior:** The message should state the type is not assignable to one of the five union types like \n\n>  iconsBase.IIconGlyphUnsafe | ModIcons_climacons.IIcons_climacons | ModIcons_devicon.IIcons_devicon \n> | ModIcons_feather.IIcons_feather | ModIcons_dripicons.IIcons_dripicons\n# Case 2\n\nNow when I actually specify the **'bundle'** property which acts as the tag for this union with a value that is **not** part of the union's discriminator I get the following even further confusing message:\n\n\u003cimg width=\"565\" alt=\"image2-badtoken-dripicons-again\" src=\"https://cloud.githubusercontent.com/assets/3457767/18414892/9345bc8e-77a9-11e6-9648-c06b9dccd7da.png\">\n\nSo the messages on line 3 & 4 state that **'bundle'** property has the invalid value **'someBadToken'** and that it is not assignable to **'\"dripicons\"'**.\n\n**Expected behavior:** The message should state that the **'bundle'** property is not assignable to any of the following 5 possible values:\n\n> \"unsafe\" | \"climacons\" | \"devicon\" | \"dripicons\" | \"feather\"\n\n**Another Expected behavior:** The **bundle'** property should be highlighted at this stage with the not assignable message with all of the values listed above.\n\n**Another Expected behavior:** Auto-complete should be available with the list of appropriately scoped **'bundle'** property values.\n# Case 3\n\nWhen I begin to input the **'id'** property I get an intellisense tooltip that shows invalid values based on the value of the **'bundle'** property, see this screenshot:\n\n\u003cimg width=\"470\" alt=\"image4-bad-intellisense-for-id-property\" src=\"https://cloud.githubusercontent.com/assets/3457767/18414921/7837fedc-77ab-11e6-9dca-835fcfe65314.png\">\n\nWhat is being shown is a listing of all possible **'id'** values across the entire type union .\n\n**Expected behavior:**  The **'id'** values should scope to the interface specified in **'bundle'**.  In this case it should only show values from **'devicon'** interface.\n\n**Another Expected behavior:** Auto-complete should be available with the list of appropriately scoped **'id'** property values.\n# Source Code of Example\n\nThe source code for this issue is available here:\n\n[Typescript-Play.zip](https://github.com/Microsoft/TypeScript/files/465744/Typescript-Play.zip)\n\nI also just want to say that is a very powerful and welcome feature and has enabled some extremely powerful scenarios for our code.\n\nKeep up the great work!\n","author":{"url":"https://github.com/KavanShaban","@type":"Person","name":"KavanShaban"},"datePublished":"2016-09-11T03:25:37Z","url":"https://github.com/microsoft/TypeScript/issues/10849"}

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:6672f736-bce4-4977-2cd1-a82f97ef9f24
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCFFE:14700E:A1F9DA:CF4906:6B00F1A7
html-safe-nonce5859543baed51aaf771c46e72bb33508e153c3dbec92353107d32ed6d9090cb1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkZFOjE0NzAwRTpBMUY5REE6Q0Y0OTA2OjZCMDBGMUE3IiwidmlzaXRvcl9pZCI6IjEzNTQ4MzY1MjE4MDY1MjQ4MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaccff3321565223a7f807819d6947ae9d415f82963412d60ed845c78143c8c673d
hovercard-subject-tagissue:176217087
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/10849/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5f4dc637f603138862b47f7eb46e750144d173cd8a9c805a1e6cab97d5ad5b39/microsoft/TypeScript/issues/10849
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5f4dc637f603138862b47f7eb46e750144d173cd8a9c805a1e6cab97d5ad5b39/microsoft/TypeScript/issues/10849
og:image:altVsCode: 1.5.1 Typescript: 2.0.2 Window 10: 1607 I create a group of tagged unions that discriminate on the 'bundle' property which then causes a further discrimination on the values of the 'id' pro...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKavanShaban
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
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
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/10849#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F10849
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%2F10849
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/10849
Reloadhttps://github.com/microsoft/TypeScript/issues/10849
Reloadhttps://github.com/microsoft/TypeScript/issues/10849
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests308 (308)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/10849
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/10849
Confusing error messages, invalid intellisense and no auto-complete with Tagged Unions that use string based Discriminatorshttps://github.com/microsoft/TypeScript/issues/10849#top
https://github.com/KavanShaban
Kavan Shaban (KavanShaban)https://github.com/KavanShaban
on Sep 11, 2016https://github.com/microsoft/TypeScript/issues/10849#issue-176217087
https://cloud.githubusercontent.com/assets/3457767/18414891/88fd9486-77a9-11e6-964b-c958268ca399.png
https://cloud.githubusercontent.com/assets/3457767/18414892/9345bc8e-77a9-11e6-9648-c06b9dccd7da.png
https://cloud.githubusercontent.com/assets/3457767/18414921/7837fedc-77ab-11e6-9dca-835fcfe65314.png
Typescript-Play.ziphttps://github.com/Microsoft/TypeScript/files/465744/Typescript-Play.zip
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
on May 24, 2017https://github.com/microsoft/TypeScript/issues/10849#event-1094703830
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
on Sep 20, 2019https://github.com/microsoft/TypeScript/issues/10849#event-2651626127
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Sep 20, 2019https://github.com/microsoft/TypeScript/issues/10849#issuecomment-533722064
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Sep 20, 2019https://github.com/microsoft/TypeScript/issues/10849#event-2651626919
microsofthttps://github.com/microsoft
on Oct 21, 2025https://github.com/microsoft/TypeScript/issues/10849#event-20415339575
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/10849
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/10849
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.