René's URL Explorer Experiment


Title: Referencing ReturnType in generic param, and passing a function that has one param causes incorrect type inference... · Issue #29133 · microsoft/TypeScript · GitHub

Open Graph Title: Referencing ReturnType in generic param, and passing a function that has one param causes incorrect type inference... · Issue #29133 · microsoft/TypeScript

X Title: Referencing ReturnType in generic param, and passing a function that has one param causes incorrect type inference... · Issue #29133 · microsoft/TypeScript

Description: TypeScript Version: 3.3.0-dev.20181129 Search Terms: ReturnType, Generic Param, Generic Function Argument Code //Innocent enough. //Take a T, return a T type Foo = (t: T) => T; //=== NOT using ReturnType in Generi...

Open Graph Description: TypeScript Version: 3.3.0-dev.20181129 Search Terms: ReturnType, Generic Param, Generic Function Argument Code //Innocent enough. //Take a T, return a T type Foo = (t: T) => T; //...

X Description: TypeScript Version: 3.3.0-dev.20181129 Search Terms: ReturnType, Generic Param, Generic Function Argument Code //Innocent enough. //Take a T, return a T type Foo<T extends number> = (t: T) =&...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Referencing ReturnType\u003cFooT> in generic param, and passing a function that has one param causes incorrect type inference...","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n  * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:**  3.3.0-dev.20181129\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** ReturnType, Generic Param, Generic Function Argument\r\n\r\n**Code**\r\n\r\n```ts\r\n//Innocent enough.\r\n//Take a T, return a T\r\ntype Foo\u003cT extends number> = (t: T) => T;\r\n\r\n//=== NOT using ReturnType\u003cFooT> in Generic Parameters ==\r\ndeclare function bar\u003c\r\n    T extends number,\r\n    FooT extends Foo\u003cT>\r\n>(t: T, foo: FooT): ReturnType\u003cFooT>\r\n//OK! `barResult` is of type `3`\r\nconst barResult = bar(\r\n    3 as (3|5),\r\n    () => 3\r\n);\r\n//OK! `barResult2` is of type `3`\r\nconst barResult2 = bar(\r\n    3 as (3|5),\r\n    //`t` is of type `3|5`\r\n    //Return type is 3 \r\n    t => 3\r\n);\r\n\r\n//=== Using ReturnType\u003cFooT> in Generic Parameters ==\r\ndeclare function baz\u003c\r\n    T extends number,\r\n    FooT extends Foo\u003cT>,\r\n    //The same as bar\u003c> but we reference ReturnType\u003cFooT> here\r\n    Ret extends ReturnType\u003cFooT>\r\n>(t: T, foo: FooT, ret: Ret): ReturnType\u003cFooT>\r\n//OK! `bazResult` is of type `3`\r\nconst bazResult = baz(\r\n    3 as (3|5),\r\n    () => 3,\r\n    3\r\n);\r\n//NOT OK! `bazResult2` is of type `3|5`!\r\nconst bazResult2 = baz(\r\n    3 as (3|5),\r\n    //`t` is of type `3|5`\r\n    //Return type is `3`\r\n    t => 3,\r\n    3\r\n);\r\n\r\n//NOT OK! `bazResult3` is of type `3|5`!\r\nconst bazResult3 = baz(\r\n    3 as (3|5),\r\n    //`t` is of type `3|5`\r\n    //Return type is `3`\r\n    //We *force* the return type to be 3\r\n    (t) : 3 => (3 as 3),\r\n    3\r\n);\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n`bazResult2` and `bazResult3` should be of type `3`, the same as `bazResult`\r\n\r\n**Actual behavior:**\r\n\r\n`bazResult2` and `bazResult3` are of type `3|5`, different from `bazResult` (which is of type `3`)\r\n\r\nThe difference between `bazResult` and `bazResult2` is literally 3 characters but it causes the inferred types to be very different.\r\n\r\n**Playground Link:** [Here](http://www.typescriptlang.org/play/#src=%2F%2FInnocent%20enough.%0A%2F%2FTake%20a%20T%2C%20return%20a%20T%0Atype%20Foo%3CT%20extends%20number%3E%20%3D%20(t%3A%20T)%20%3D%3E%20T%3B%0A%0A%2F%2F%3D%3D%3D%20NOT%20using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0Adeclare%20function%20bar%3C%0A%20%20%20%20T%20extends%20number%2C%0A%20%20%20%20FooT%20extends%20Foo%3CT%3E%0A%3E(t%3A%20T%2C%20foo%3A%20FooT)%3A%20ReturnType%3CFooT%3E%0A%2F%2FOK!%20%60barResult%60%20is%20of%20type%20%603%60%0Aconst%20barResult%20%3D%20bar(%0A%20%20%20%203%20as%20(3%7C5)%2C%0A%20%20%20%20()%20%3D%3E%203%0A)%3B%0A%2F%2FOK!%20%60barResult2%60%20is%20of%20type%20%603%60%0Aconst%20barResult2%20%3D%20bar(%0A%20%20%20%203%20as%20(3%7C5)%2C%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%203%20%0A%20%20%20%20t%20%3D%3E%203%0A)%3B%0A%0A%2F%2F%3D%3D%3D%20Using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0Adeclare%20function%20baz%3C%0A%20%20%20%20T%20extends%20number%2C%0A%20%20%20%20FooT%20extends%20Foo%3CT%3E%2C%0A%20%20%20%20%2F%2FThe%20same%20as%20bar%3C%3E%20but%20we%20reference%20ReturnType%3CFooT%3E%20here%0A%20%20%20%20Ret%20extends%20ReturnType%3CFooT%3E%0A%3E(t%3A%20T%2C%20foo%3A%20FooT%2C%20ret%3A%20Ret)%3A%20ReturnType%3CFooT%3E%0A%2F%2FOK!%20%60bazResult%60%20is%20of%20type%20%603%60%0Aconst%20bazResult%20%3D%20baz(%0A%20%20%20%203%20as%20(3%7C5)%2C%0A%20%20%20%20()%20%3D%3E%203%2C%0A%20%20%20%203%0A)%3B%0A%2F%2FNOT%20OK!%20%60bazResult2%60%20is%20of%20type%20%603%7C5%60!%0Aconst%20bazResult2%20%3D%20baz(%0A%20%20%20%203%20as%20(3%7C5)%2C%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%20%603%60%0A%20%20%20%20t%20%3D%3E%203%2C%0A%20%20%20%203%0A)%3B%0A%0A%2F%2FNOT%20OK!%20%60bazResult3%60%20is%20of%20type%20%603%7C5%60!%0Aconst%20bazResult3%20%3D%20baz(%0A%20%20%20%203%20as%20(3%7C5)%2C%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%20%603%60%0A%20%20%20%20%2F%2FWe%20*force*%20the%20return%20type%20to%20be%203%0A%20%20%20%20(t)%20%3A%203%20%3D%3E%20(3%20as%203)%2C%0A%20%20%20%203%0A)%3B)\r\n\r\n-----\r\n\r\nI don't even know how to describe this...\r\n\r\nMy real use case is more complicated than the above example but I *need* the return type of a generic function to be inferred correctly to perform stronger compile-time type checks.\r\n\r\nThe strange thing is that `() => 3` will give me the correct return type, but `t => 3` will not.\r\nIn my own code, using the argument `t` is absolutely necessary.\r\n\r\nAs far as I've seen, this problem only occurs both the following are true,\r\n\r\n1. `ReturnType\u003cFooT>` is used in a generic param constraint\r\n2. The concrete type of `FooT` has parameters (Like `t => 3` has parameters, `() => 3` does not)\r\n\r\nIf either of the above are false, this problem does not occur","author":{"url":"https://github.com/AnyhowStep","@type":"Person","name":"AnyhowStep"},"datePublished":"2018-12-23T18:14:43Z","url":"https://github.com/microsoft/TypeScript/issues/29133"}

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:74d8f2a6-220d-208e-d7f1-3de68bbeacbf
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCD7C:3A4875:29D5F79:37CD9FE:6B01BCFA
html-safe-noncedd19a9590f1d5873b97a98b4f1bf94b3a111ace5f770438335520d3e2f7122f4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDdDOjNBNDg3NToyOUQ1Rjc5OjM3Q0Q5RkU6NkIwMUJDRkEiLCJ2aXNpdG9yX2lkIjoiODQ4NzE1MjcyMzU3MjE0NTQwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac9a4399e08929ea77c1eba3af19a1767a729d50ebd1e41aab837c0fda3537d379
hovercard-subject-tagissue:393770312
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/29133/issue_layout
twitter:imagehttps://opengraph.githubassets.com/43f2d3ea7d8d509a8ad96d61d783d2cac504a999bc9a610c09f0911c883eba9f/microsoft/TypeScript/issues/29133
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/43f2d3ea7d8d509a8ad96d61d783d2cac504a999bc9a610c09f0911c883eba9f/microsoft/TypeScript/issues/29133
og:image:altTypeScript Version: 3.3.0-dev.20181129 Search Terms: ReturnType, Generic Param, Generic Function Argument Code //Innocent enough. //Take a T, return a T type Foo = (t: T) => T; //...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameAnyhowStep
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-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/29133#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F29133
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%2F29133
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/29133
Reloadhttps://github.com/microsoft/TypeScript/issues/29133
Reloadhttps://github.com/microsoft/TypeScript/issues/29133
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/29133
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/29133
Referencing ReturnType in generic param, and passing a function that has one param causes incorrect type inference...https://github.com/microsoft/TypeScript/issues/29133#top
UnactionableThere isn't something we can do with this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Unactionable%22
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on Dec 23, 2018https://github.com/microsoft/TypeScript/issues/29133#issue-393770312
Herehttp://www.typescriptlang.org/play/#src=%2F%2FInnocent%20enough.%0A%2F%2FTake%20a%20T%2C%20return%20a%20T%0Atype%20Foo%3CT%20extends%20number%3E%20%3D%20(t%3A%20T)%20%3D%3E%20T%3B%0A%0A%2F%2F%3D%3D%3D%20NOT%20using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0Adeclare%20function%20bar%3C%0A%20%20%20%20T%20extends%20number%2C%0A%20%20%20%20FooT%20extends%20Foo%3CT%3E%0A%3E(t%3A%20T%2C%20foo%3A%20FooT)%3A%20ReturnType%3CFooT%3E%0A%2F%2FOK!%20%60barResult%60%20is%20of%20type%20%603%60%0Aconst%20barResult%20%3D%20bar(%0A%20%20%20%203%20as%20(3%7C5)%2C%0A%20%20%20%20()%20%3D%3E%203%0A)%3B%0A%2F%2FOK!%20%60barResult2%60%20is%20of%20type%20%603%60%0Aconst%20barResult2%20%3D%20bar(%0A%20%20%20%203%20as%20(3%7C5)%2C%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%203%20%0A%20%20%20%20t%20%3D%3E%203%0A)%3B%0A%0A%2F%2F%3D%3D%3D%20Using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0Adeclare%20function%20baz%3C%0A%20%20%20%20T%20extends%20number%2C%0A%20%20%20%20FooT%20extends%20Foo%3CT%3E%2C%0A%20%20%20%20%2F%2FThe%20same%20as%20bar%3C%3E%20but%20we%20reference%20ReturnType%3CFooT%3E%20here%0A%20%20%20%20Ret%20extends%20ReturnType%3CFooT%3E%0A%3E(t%3A%20T%2C%20foo%3A%20FooT%2C%20ret%3A%20Ret)%3A%20ReturnType%3CFooT%3E%0A%2F%2FOK!%20%60bazResult%60%20is%20of%20type%20%603%60%0Aconst%20bazResult%20%3D%20baz(%0A%20%20%20%203%20as%20(3%7C5)%2C%0A%20%20%20%20()%20%3D%3E%203%2C%0A%20%20%20%203%0A)%3B%0A%2F%2FNOT%20OK!%20%60bazResult2%60%20is%20of%20type%20%603%7C5%60!%0Aconst%20bazResult2%20%3D%20baz(%0A%20%20%20%203%20as%20(3%7C5)%2C%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%20%603%60%0A%20%20%20%20t%20%3D%3E%203%2C%0A%20%20%20%203%0A)%3B%0A%0A%2F%2FNOT%20OK!%20%60bazResult3%60%20is%20of%20type%20%603%7C5%60!%0Aconst%20bazResult3%20%3D%20baz(%0A%20%20%20%203%20as%20(3%7C5)%2C%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%20%603%60%0A%20%20%20%20%2F%2FWe%20*force*%20the%20return%20type%20to%20be%203%0A%20%20%20%20(t)%20%3A%203%20%3D%3E%20(3%20as%203)%2C%0A%20%20%20%203%0A)%3B
AnyhowStephttps://github.com/AnyhowStep
on Dec 23, 2018https://github.com/microsoft/TypeScript/issues/29133#event-2042563187
AnyhowStephttps://github.com/AnyhowStep
on Dec 23, 2018https://github.com/microsoft/TypeScript/issues/29133#event-2042565197
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on Dec 23, 2018https://github.com/microsoft/TypeScript/issues/29133#issuecomment-449655188
Playgroundhttp://www.typescriptlang.org/play/#src=%2F%2FInnocent%20enough.%0A%2F%2FReturns%20a%20T%0Atype%20Foo%3CT%3E%20%3D%20(...args%20%3A%20any%5B%5D)%20%3D%3E%20T%3B%0A%0A%2F%2F%3D%3D%3D%20NOT%20using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0Adeclare%20function%20bar%3C%0A%20%20%20%20FooT%20extends%20Foo%3C3%7C5%3E%0A%3E(foo%3A%20FooT)%3A%20ReturnType%3CFooT%3E%0A%2F%2FOK!%20%60barResult%60%20is%20of%20type%20%603%60%0Aconst%20barResult%20%3D%20bar(%0A%20%20%20%20()%20%3D%3E%203%0A)%3B%0A%2F%2FOK!%20%60barResult2%60%20is%20of%20type%20%603%60%0Aconst%20barResult2%20%3D%20bar(%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%203%20%0A%20%20%20%20t%20%3D%3E%203%0A)%3B%0A%0A%2F%2F%3D%3D%3D%20Using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0Adeclare%20function%20baz%3C%0A%20%20%20%20FooT%20extends%20Foo%3C3%7C5%3E%2C%0A%20%20%20%20%2F%2FThe%20same%20as%20bar%3C%3E%20but%20we%20reference%20ReturnType%3CFooT%3E%20here%0A%20%20%20%20Ret%20extends%20ReturnType%3CFooT%3E%0A%3E(foo%3A%20FooT%2C%20ret%3A%20Ret)%3A%20ReturnType%3CFooT%3E%0A%2F%2FOK!%20%60bazResult%60%20is%20of%20type%20%603%60%0Aconst%20bazResult%20%3D%20baz(%0A%20%20%20%20()%20%3D%3E%203%2C%0A%20%20%20%203%0A)%3B%0A%2F%2FNOT%20OK!%20%60bazResult2%60%20is%20of%20type%20%603%7C5%60!%0Aconst%20bazResult2%20%3D%20baz(%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%20%603%60%0A%20%20%20%20t%20%3D%3E%203%2C%0A%20%20%20%203%0A)%3B%0A%0A%2F%2FNOT%20OK!%20%60bazResult3%60%20is%20of%20type%20%603%7C5%60!%0Aconst%20bazResult3%20%3D%20baz(%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%20%603%60%0A%20%20%20%20%2F%2FWe%20*force*%20the%20return%20type%20to%20be%203%0A%20%20%20%20(t)%20%3A%203%20%3D%3E%20(3%20as%203)%2C%0A%20%20%20%203%20as%203%0A)%3B
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on Dec 23, 2018https://github.com/microsoft/TypeScript/issues/29133#issuecomment-449662209
Playgroundhttp://www.typescriptlang.org/play/#src=%2F%2FInnocent%20enough.%0A%2F%2FReturns%20a%20T%0Atype%20Foo%3CT%3E%20%3D%20(...args%20%3A%20any%5B%5D)%20%3D%3E%20T%3B%0A%0A%2F%2F%3D%3D%3D%20NOT%20using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0Adeclare%20function%20bar%3C%0A%20%20%20%20FooT%20extends%20Foo%3C3%7C5%3E%0A%3E(foo%3A%20FooT)%3A%20ReturnType%3CFooT%3E%0A%2F%2FOK!%20%60barResult%60%20is%20of%20type%20%603%60%0Aconst%20barResult%20%3D%20bar(%0A%20%20%20%20()%20%3D%3E%203%0A)%3B%0A%2F%2FOK!%20%60barResult2%60%20is%20of%20type%20%603%60%0Aconst%20barResult2%20%3D%20bar(%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%203%20%0A%20%20%20%20t%20%3D%3E%203%0A)%3B%0A%0A%2F%2F%3D%3D%3D%20Using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0Adeclare%20function%20baz%3C%0A%20%20%20%20FooT%20extends%20Foo%3C3%7C5%3E%2C%0A%3E(%0A%20%20%20%20foo%3A%20FooT%20%26%20(%0A%20%20%20%20%20%20%20%20ReturnType%3CFooT%3E%20extends%203%20%3F%0A%20%20%20%20%20%20%20%20unknown%20%3A%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Only%203%20allowed%2C%20received%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20ReturnType%3CFooT%3E%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A)%3A%20ReturnType%3CFooT%3E%0A%2F%2FOK!%20%60bazResult%60%20is%20of%20type%20%603%60%0Aconst%20bazResult%20%3D%20baz(%0A%20%20%20%20()%20%3D%3E%203%0A)%3B%0A%2F%2FNOT%20OK!%20%60bazResult2%60%20is%20of%20type%20%603%7C5%60!%0Aconst%20bazResult2%20%3D%20baz(%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%20%603%60%0A%20%20%20%20%2F%2FError%2C%20%5B%22Only%203%20allowed%2C%20received%22%2C%203%20%7C%205%5D%0A%20%20%20%20t%20%3D%3E%203%0A)%3B%0A%0A%2F%2FNOT%20OK!%20%60bazResult3%60%20is%20of%20type%20%603%7C5%60!%0Aconst%20bazResult3%20%3D%20baz(%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0A%20%20%20%20%2F%2FReturn%20type%20is%20%603%60%0A%20%20%20%20%2F%2FWe%20*force*%20the%20return%20type%20to%20be%203%0A%20%20%20%20%2F%2FError%2C%20%5B%22Only%203%20allowed%2C%20received%22%2C%203%20%7C%205%5D%0A%20%20%20%20(t)%20%3A%203%20%3D%3E%20(3%20as%203)%0A)%3B
Wesley Wigham (weswigham)https://github.com/weswigham
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 Dec 25, 2018https://github.com/microsoft/TypeScript/issues/29133#event-2043514539
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on Dec 31, 2018https://github.com/microsoft/TypeScript/issues/29133#issuecomment-450678796
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on Dec 31, 2018https://github.com/microsoft/TypeScript/issues/29133#issuecomment-450679038
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on Dec 31, 2018https://github.com/microsoft/TypeScript/issues/29133#issuecomment-450682035
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on Dec 31, 2018https://github.com/microsoft/TypeScript/issues/29133#issuecomment-450682493
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on Dec 31, 2018https://github.com/microsoft/TypeScript/issues/29133#issuecomment-450694711
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on May 24, 2019https://github.com/microsoft/TypeScript/issues/29133#issuecomment-495752937
Playgroundhttp://www.typescriptlang.org/play/#src=%0D%0A%2F%2FInnocent%20enough.%0D%0A%2F%2FReturns%20a%20T%0D%0Atype%20Foo%3CT%3E%20%3D%20(...args%20%3A%20any%5B%5D)%20%3D%3E%20T%3B%0D%0A%0D%0A%2F%2F%3D%3D%3D%20NOT%20using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0D%0Adeclare%20function%20bar%3C%0D%0A%20%20%20%20FooT%20extends%20Foo%3C3%7C5%3E%0D%0A%3E(foo%3A%20FooT)%3A%20ReturnType%3CFooT%3E%0D%0A%2F%2FOK!%20%60barResult%60%20is%20of%20type%20%603%60%0D%0Aconst%20barResult%20%3D%20bar(%0D%0A%20%20%20%20()%20%3D%3E%203%0D%0A)%3B%0D%0A%2F%2FOK!%20%60barResult2%60%20is%20of%20type%20%603%60%0D%0Aconst%20barResult2%20%3D%20bar(%0D%0A%20%20%20%20%2F%2F%60t%60%20is%20of%20type%20%603%7C5%60%0D%0A%20%20%20%20%2F%2FReturn%20type%20is%203%20%0D%0A%20%20%20%20t%20%3D%3E%203%0D%0A)%3B%0D%0A%0D%0A%2F%2F%3D%3D%3D%20Using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0D%0Adeclare%20function%20baz%3C%0D%0A%20%20%20%20FooT%20extends%20Foo%3C3%7C5%3E%2C%0D%0A%3E(%0D%0A%20%20%20%20foo%3A%20FooT%20%26%20(%0D%0A%20%20%20%20%20%20%20%20ReturnType%3CFooT%3E%20extends%203%20%3F%0D%0A%20%20%20%20%20%20%20%20unknown%20%3A%0D%0A%20%20%20%20%20%20%20%20%5B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Only%203%20allowed%2C%20received%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20ReturnType%3CFooT%3E%0D%0A%20%20%20%20%20%20%20%20%5D%0D%0A%20%20%20%20)%0D%0A)%3A%20ReturnType%3CFooT%3E%0D%0A%2F%2FOK!%20%60bazResult%60%20is%20of%20type%20%603%60%0D%0Aconst%20bazResult%20%3D%20baz(%0D%0A%20%20%20%20()%20%3D%3E%203%0D%0A)%3B%0D%0A%2F%2FNOT%20OK!%20%60bazResult2%60%20is%20of%20type%20%603%7C5%60!%0D%0Aconst%20bazResult2%20%3D%20baz(%0D%0A%20%20%20%20%2F%2FReturn%20type%20is%20%603%60%0D%0A%20%20%20%20%2F%2FError%2C%20%5B%22Only%203%20allowed%2C%20received%22%2C%203%20%7C%205%5D%0D%0A%20%20%20%20t%20%3D%3E%203%0D%0A)%3B%0D%0A%0D%0A%2F%2FNOT%20OK!%20%60bazResult3%60%20is%20of%20type%20%603%7C5%60!%0D%0Aconst%20bazResult3%20%3D%20baz(%0D%0A%20%20%20%20%2F%2FReturn%20type%20is%20%603%60%0D%0A%20%20%20%20%2F%2FWe%20*force*%20the%20return%20type%20to%20be%203%0D%0A%20%20%20%20%2F%2FError%2C%20%5B%22Only%203%20allowed%2C%20received%22%2C%203%20%7C%205%5D%0D%0A%20%20%20%20(t)%20%3A%203%20%3D%3E%20(3%20as%203)%0D%0A)%3B
#30215https://github.com/microsoft/TypeScript/pull/30215
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on May 25, 2019https://github.com/microsoft/TypeScript/issues/29133#issuecomment-495840886
Playgroundhttp://www.typescriptlang.org/play/#src=%0D%0A%0D%0A%2F%2FInnocent%20enough.%0D%0A%2F%2FReturns%20a%20T%0D%0Atype%20Foo%3CT%3E%20%3D%20(...args%20%3A%20any%5B%5D)%20%3D%3E%20T%3B%0D%0A%0D%0A%2F%2F%3D%3D%3D%20Using%20ReturnType%3CFooT%3E%20in%20Generic%20Parameters%20%3D%3D%0D%0Adeclare%20function%20baz%3C%0D%0A%20%20%20%20FooT%20extends%20Foo%3C3%7C5%3E%2C%0D%0A%3E(%0D%0A%20%20%20%20foo%3A%20FooT%0D%0A)%3A%20(%0D%0A%20%20%20%20(this%3A%20(%0D%0A%20%20%20%20%20%20%20%20ReturnType%3CFooT%3E%20extends%203%20%3F%0D%0A%20%20%20%20%20%20%20%20unknown%20%3A%0D%0A%20%20%20%20%20%20%20%20%5B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Only%203%20allowed%2C%20received%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20ReturnType%3CFooT%3E%0D%0A%20%20%20%20%20%20%20%20%5D%0D%0A%20%20%20%20))%20%3D%3E%20ReturnType%3CFooT%3E%0D%0A)%0D%0A%2F%2FOK!%20%60bazResult%60%20is%20of%20type%20%603%60%0D%0Aconst%20bazResult%20%3D%20baz(%0D%0A%20%20%20%20()%20%3D%3E%203%0D%0A)%3B%0D%0A%0D%0A%2F%2FOK!%20%60bazResult2%60%20is%20of%20type%20%603%60%0D%0Aconst%20bazResult2%20%3D%20baz(%0D%0A%20%20%20%20t%20%3D%3E%203%0D%0A)()%3B%0D%0A%0D%0A%2F%2FOK!%20%60bazResult3%60%20is%20of%20type%20%603%60%0D%0Aconst%20bazResult3%20%3D%20baz(%0D%0A%20%20%20%20(t)%20%3A%203%20%3D%3E%20(3%20as%203)%0D%0A)()%3B%0D%0A%0D%0A%2F*%0D%0A%20%20%20%20OK!%20%60bazResult4%60%20is%20of%20type%20%605%60%0D%0A%20%20%20%20%0D%0A%20%20%20%20Error%20as%20expected%2C%0D%0A%20%20%20%20%0D%0A%20%20%20%20The%20'this'%20context%20of%20type%20'void'%20is%20not%20assignable%20to%0D%0A%20%20%20%20method's%20'this'%20of%20type%20'%5B%22Only%203%20allowed%2C%20received%22%2C%205%5D'.%0D%0A*%2F%0D%0Aconst%20bazResult4%20%3D%20baz(%0D%0A%20%20%20%20t%20%3D%3E%205%0D%0A)()%3B
https://user-images.githubusercontent.com/5655961/58364131-5561df00-7e7d-11e9-9788-7b57b79fd907.png
#23689https://github.com/microsoft/TypeScript/issues/23689
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on May 30, 2019https://github.com/microsoft/TypeScript/issues/29133#issuecomment-497365520
Jack Williams (@jack-williams)https://github.com/jack-williams
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
UnactionableThere isn't something we can do with this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Unactionable%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 Aug 22, 2019https://github.com/microsoft/TypeScript/issues/29133#event-2578035036
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Aug 22, 2019https://github.com/microsoft/TypeScript/issues/29133#issuecomment-524102393
AnyhowStephttps://github.com/AnyhowStep
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 22, 2019https://github.com/microsoft/TypeScript/issues/29133#event-2578035422
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/29133
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/29133
UnactionableThere isn't something we can do with this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Unactionable%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.