René's URL Explorer Experiment


Title: Breaking changes associated with Union Types · Issue #868 · microsoft/TypeScript · GitHub

Open Graph Title: Breaking changes associated with Union Types · Issue #868 · microsoft/TypeScript

X Title: Breaking changes associated with Union Types · Issue #868 · microsoft/TypeScript

Description: This issue tracks the set of breaking changes that result from the change to union types #824 to implement the suggestion #805. The issues here will be formalized further once an official spec update is done, until then it will mostly se...

Open Graph Description: This issue tracks the set of breaking changes that result from the change to union types #824 to implement the suggestion #805. The issues here will be formalized further once an official spec upda...

X Description: This issue tracks the set of breaking changes that result from the change to union types #824 to implement the suggestion #805. The issues here will be formalized further once an official spec upda...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Breaking changes associated with Union Types","articleBody":"This issue tracks the set of breaking changes that result from the change to union types #824 to implement the suggestion #805. The issues here will be formalized further once an official spec update is done, until then it will mostly serve as an easy reference for the type of coding patterns that have broken for various reasons.\n#### Multiple Best Common Type Candidates\n\nGiven multiple viable candidates from a Best Common Type computation we now choose an item (depending on the compiler's implementation) rather than the first item.\n\n``` ts\nvar a: { x: number; y?: number };\nvar b: { x: number; z?: number };\n\n// was { x: number; z?: number; }[]\n// now { x: number; y?: number; }[]\nvar bs = [b, a]; \n```\n\nThis can happen in a variety of circumstances. A shared set of required properties and a disjoint set of other properties (optional or otherwise), empty types, compatible signature types (including generic and non-generic signatures when type parameters are stamped out with `any`).\n\n**Recommendation**\nProvide a type annotation if you need a specific type to be chosen\n\n``` ts\nvar bs: { x: number; y?: number; z?: number }[] = [b, a];\n```\n#### Generic Type Inference\n\nUsing different types for multiple arguments of type T is now an error, even with constraints involved:\n\n``` ts\ndeclare function foo\u003cT>(x: T, y:T): T;\nvar r = foo(1, \"\"); // r used to be {}, now this is an error\n```\n\nWith constraints:\n\n``` ts\ninterface Animal { x }\ninterface Giraffe extends Animal { y }\ninterface Elephant extends Animal { z }\nfunction f\u003cT extends Animal>(x: T, y: T): T { return undefined; }\nvar g: Giraffe;\nvar e: Elephant;\nf(g, e);\n```\n\nSee https://github.com/Microsoft/TypeScript/pull/824#discussion_r18665727 for explanation.\n\n**Recommendations**\nSpecify an explicit type parameter if the mismatch was intentional:\n\n``` ts\nvar r = foo\u003c{}>(1, \"\"); // Emulates 1.0 behavior\nvar r = foo\u003cstring|number>(1, \"\"); // Most useful\nvar r = foo\u003cany>(1, \"\"); // Easiest\nf\u003cAnimal>(g, e);\n```\n\n_or_ rewrite the function definition to specify that mismatches are OK:\n\n``` ts\ndeclare function foo\u003cT,U>(x: T, y:U): T|U;\nfunction f\u003cT extends Animal, U extends Animal>(x: T, y: U): T|U { return undefined; }\n```\n#### Generic Rest Parameters\n\nYou cannot use hetergeneous argument types anymore:\n\n``` ts\nfunction makeArray\u003cT>(...items: T[]): T[] { return items; }\nvar r = makeArray(1, \"\"); // used to return {}[], now an error\n```\n\nLikewise for `new Array(...)`\n\n**Recommendations**\nDeclare a back-compat signature if the 1.0 behavior was desired:\n\n``` ts\nfunction makeArray\u003cT>(...items: T[]): T[];\nfunction makeArray(...items: {}[]): {}[];\nfunction makeArray\u003cT>(...items: T[]): T[] { return items; }\n```\n#### Overload Resolution with Type Argument Inference\n\n``` ts\nvar f10: \u003cT>(x: T, b: () => (a: T) => void, y: T) => T;\nvar r9 = f10('', () => (a => a.foo), 1); // r9 was any, now this is an error\n```\n\n**Recommendations**\nManually specify a type parameter\n\n``` ts\nvar r9 = f10\u003cany>('', () => (a => a.foo), 1);\n```\n#### Promises\n\nThis used to not have an error:\n\n``` ts\ninterface Promise\u003cT> {\n    then\u003cU>(success?: (value: T) => Promise\u003cU>, error?: (error: any) => Promise\u003cU>, progress?: (progress: any) => void): Promise\u003cU>;\n    then\u003cU>(success?: (value: T) => Promise\u003cU>, error?: (error: any) => U, progress?: (progress: any) => void): Promise\u003cU>;\n    then\u003cU>(success?: (value: T) => U, error?: (error: any) => Promise\u003cU>, progress?: (progress: any) => void): Promise\u003cU>;\n    then\u003cU>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise\u003cU>;\n    done\u003cU>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;\n}\n\ninterface IPromise\u003cT> {\n    then\u003cU>(success?: (value: T) => IPromise\u003cU>, error?: (error: any) => IPromise\u003cU>, progress?: (progress: any) => void): IPromise\u003cU>;\n    then\u003cU>(success?: (value: T) => IPromise\u003cU>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise\u003cU>;\n    then\u003cU>(success?: (value: T) => U, error?: (error: any) => IPromise\u003cU>, progress?: (progress: any) => void): IPromise\u003cU>;\n    then\u003cU>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise\u003cU>;\n    done? \u003cU>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;\n}\n\ndeclare function f1(x: number): IPromise\u003cnumber>;\ndeclare function f2(x: number): Promise\u003cnumber>;\nvar p: Promise\u003cnumber>;\nvar r = p.then(f2, f1, f1).then(f1, f1, f1);\n//                                 ^^\n// error TS2345: Argument of type '(x: number) => IPromise\u003cnumber>' is not assignable to parameter of type '(value: IPromise\u003cnumber>) => IPromise\u003cnumber>'.\n```\n","author":{"url":"https://github.com/danquirk","@type":"Person","name":"danquirk"},"datePublished":"2014-10-10T01:01:33Z","url":"https://github.com/microsoft/TypeScript/issues/868"}

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:bef8fb2b-eb60-f450-1e5b-55a316394601
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8A8A:2BB4ED:3B02DF:515F4A:6B008C49
html-safe-nonce921b73c23453296696c2e475fa6b67485ded47accdd86a700242afc2ce5d3860
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QThBOjJCQjRFRDozQjAyREY6NTE1RjRBOjZCMDA4QzQ5IiwidmlzaXRvcl9pZCI6IjkxODE5NDM3Mzc1OTU0OTc1NDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacad58f0156f289bc0ad68803769d930b05977bde78a9ef0a8546ce66d04b58712
hovercard-subject-tagissue:45435707
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/868/issue_layout
twitter:imagehttps://opengraph.githubassets.com/96e143d58f0780f428c1cf06514378a6cbaecf2735ec0e1564d827954ba8a1b5/microsoft/TypeScript/issues/868
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/96e143d58f0780f428c1cf06514378a6cbaecf2735ec0e1564d827954ba8a1b5/microsoft/TypeScript/issues/868
og:image:altThis issue tracks the set of breaking changes that result from the change to union types #824 to implement the suggestion #805. The issues here will be formalized further once an official spec upda...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedanquirk
hostnamegithub.com
expected-hostnamegithub.com
Nonec710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08
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
releasebe616a2a6ec1c609d6e002896dff5352d5c5f28b
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/868#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F868
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%2F868
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/868
Reloadhttps://github.com/microsoft/TypeScript/issues/868
Reloadhttps://github.com/microsoft/TypeScript/issues/868
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests309 (309)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/868
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/868
Breaking changes associated with Union Typeshttps://github.com/microsoft/TypeScript/issues/868#top
Breaking ChangeWould introduce errors in existing codehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Breaking%20Change%22
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22By%20Design%22
TypeScript 1.4https://github.com/microsoft/TypeScript/milestone/6
https://github.com/danquirk
Dan Quirk (danquirk)https://github.com/danquirk
on Oct 10, 2014https://github.com/microsoft/TypeScript/issues/868#issue-45435707
#824https://github.com/microsoft/TypeScript/pull/824
#805https://github.com/microsoft/TypeScript/issues/805
#824 (comment)https://github.com/microsoft/TypeScript/pull/824#discussion_r18665727
Dan Quirk (danquirk)https://github.com/danquirk
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22By%20Design%22
Breaking ChangeWould introduce errors in existing codehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Breaking%20Change%22
on Oct 10, 2014https://github.com/microsoft/TypeScript/issues/868#event-176683679
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Oct 10, 2014https://github.com/microsoft/TypeScript/issues/868#issuecomment-58615806
https://github.com/JsonFreeman
Jason Freeman (JsonFreeman)https://github.com/JsonFreeman
on Oct 12, 2014https://github.com/microsoft/TypeScript/issues/868#issuecomment-58771233
https://github.com/danquirk
Dan Quirk (danquirk)https://github.com/danquirk
on Oct 13, 2014https://github.com/microsoft/TypeScript/issues/868#issuecomment-58938971
https://github.com/JsonFreeman
Jason Freeman (JsonFreeman)https://github.com/JsonFreeman
on Oct 13, 2014https://github.com/microsoft/TypeScript/issues/868#issuecomment-58939666
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
TypeScript 1.4https://github.com/microsoft/TypeScript/milestone/6
on Jan 20, 2015https://github.com/microsoft/TypeScript/issues/868#event-221880028
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Mar 24, 2015https://github.com/microsoft/TypeScript/issues/868#event-263730284
microsofthttps://github.com/microsoft
on Jun 18, 2018https://github.com/microsoft/TypeScript/issues/868#event-1686909403
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/868
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/868
Breaking ChangeWould introduce errors in existing codehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Breaking%20Change%22
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22By%20Design%22
TypeScript 1.4https://github.com/microsoft/TypeScript/milestone/6
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.