René's URL Explorer Experiment


Title: Narrowing does not work for constrained template arguments in JS · Issue #38309 · microsoft/TypeScript · GitHub

Open Graph Title: Narrowing does not work for constrained template arguments in JS · Issue #38309 · microsoft/TypeScript

X Title: Narrowing does not work for constrained template arguments in JS · Issue #38309 · microsoft/TypeScript

Description: TypeScript Version: 3.8.3 Search Terms: jsdoc template narrow Code /** * @template {string | string[]} T * @param {T} a */ function foo(a) { if (Array.isArray(a)) { a.map; // somewhat correctly narrowed to (T & any[]) } else { a.substr; ...

Open Graph Description: TypeScript Version: 3.8.3 Search Terms: jsdoc template narrow Code /** * @template {string | string[]} T * @param {T} a */ function foo(a) { if (Array.isArray(a)) { a.map; // somewhat correctly nar...

X Description: TypeScript Version: 3.8.3 Search Terms: jsdoc template narrow Code /** * @template {string | string[]} T * @param {T} a */ function foo(a) { if (Array.isArray(a)) { a.map; // somewhat correctly nar...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Narrowing does not work for constrained template arguments in JS","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!--\r\nPlease try to reproduce the issue with the latest published version. It may have already been fixed.\r\nFor npm: `typescript@next`\r\nThis is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly\r\n-->\r\n**TypeScript Version:**  3.8.3\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** jsdoc template narrow\r\n\r\n**Code**\r\n\r\n```js\r\n/**\r\n * @template {string | string[]} T\r\n * @param {T} a \r\n */\r\nfunction foo(a) {\r\n\tif (Array.isArray(a)) {\r\n\t\ta.map; // somewhat correctly narrowed to (T & any[])\r\n\t} else {\r\n\t\ta.substr; // Error, not narrowed at all (T)\r\n\t}\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n1. in the if-branch, `a` is narrowed to `string[]`\r\n2. in the else-branch, `a` is narrowed to `string`\r\n\r\n**Actual behavior:**\r\n1. in the if-branch, `a` is narrowed to `T & any[]`\r\n2. in the else-branch, `a` is NOT narrowed\r\n\r\n**Playground Link:** This is JS, so the playground doesn't work\r\n\r\n**Related Issues:** Constraint support was added in #24600\r\n","author":{"url":"https://github.com/AlCalzone","@type":"Person","name":"AlCalzone"},"datePublished":"2020-05-03T14:14:33Z","url":"https://github.com/microsoft/TypeScript/issues/38309"}

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:286a1f9e-85ef-3931-bb2e-a723ecae2fb8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAA52:313081:D820B:11E4CA:6B0182D6
html-safe-nonce19bfd4552c5bcb1afeb0a517b985e2f135607d1132e5ad3939910091d2d6bad2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTUyOjMxMzA4MTpEODIwQjoxMUU0Q0E6NkIwMTgyRDYiLCJ2aXNpdG9yX2lkIjoiOTExMjY1OTM2MDk5MDk4Njk2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac84a18cd86094e6d84a889e3308f2944886a2af36098a9cca89530ed01e7256a7
hovercard-subject-tagissue:611423331
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/38309/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d9de04bd43dd7d91b4d12a7de4526a8a71bdf68dc2afbfdfd0666ec8506c165f/microsoft/TypeScript/issues/38309
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d9de04bd43dd7d91b4d12a7de4526a8a71bdf68dc2afbfdfd0666ec8506c165f/microsoft/TypeScript/issues/38309
og:image:altTypeScript Version: 3.8.3 Search Terms: jsdoc template narrow Code /** * @template {string | string[]} T * @param {T} a */ function foo(a) { if (Array.isArray(a)) { a.map; // somewhat correctly nar...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameAlCalzone
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/38309#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F38309
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%2F38309
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/38309
Reloadhttps://github.com/microsoft/TypeScript/issues/38309
Reloadhttps://github.com/microsoft/TypeScript/issues/38309
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/38309
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/38309
Narrowing does not work for constrained template arguments in JShttps://github.com/microsoft/TypeScript/issues/38309#top
https://github.com/weswigham
BlockedA fix for this issue is blocked on another fix being in placehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Blocked%22
Design LimitationConstraints of the existing architecture prevent this from being fixedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Design%20Limitation%22
RescheduledThis issue was previously scheduled to an earlier milestonehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Rescheduled%22
TypeScript 5.1.0https://github.com/microsoft/TypeScript/milestone/178
https://github.com/AlCalzone
AlCalzonehttps://github.com/AlCalzone
on May 3, 2020https://github.com/microsoft/TypeScript/issues/38309#issue-611423331
#24600https://github.com/microsoft/TypeScript/pull/24600
Nexthttps://github.com/microsoft/TypeScript/issues/38309?timeline_page=1
https://github.com/IllusionMH
Andrii Dieiev (IllusionMH)https://github.com/IllusionMH
on May 4, 2020https://github.com/microsoft/TypeScript/issues/38309#issuecomment-623410135
TS nightly reprohttps://www.typescriptlang.org/play/index.html?ts=4.0.0-dev.20200503#code/GYVwdgxgLglg9mABMOcA8AVRBTAHlbMAEwGdESoAnGMAc0QB9yqbaBtAXQD4AKAQwBciDAEpEAbwCwAKACQMYIh4BBSpT4BPAHQwSq9Rv4ixUubL5aAtnwAOAbkQB6R+TiXsAdwAWfKIghwatjQADYaiGB8anAe2ESIUHBKWABkiHxgGpwiMrIAvjghJNgSueZaJCAARhSUDs6IAKLRlAA0EXB+kdGx8b7pISHJOXJ5MmPSQA
https://github.com/AlCalzone
AlCalzonehttps://github.com/AlCalzone
on May 7, 2020https://github.com/microsoft/TypeScript/issues/38309#issuecomment-625345252
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jun 5, 2020https://github.com/microsoft/TypeScript/issues/38309#issuecomment-639836070
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
Wesley Wigham (@weswigham)https://github.com/weswigham
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 Jun 5, 2020https://github.com/microsoft/TypeScript/issues/38309#event-3413388465
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Wesley Wigham (weswigham)https://github.com/weswigham
on Jun 5, 2020https://github.com/microsoft/TypeScript/issues/38309#event-3413388598
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.0https://github.com/microsoft/TypeScript/milestone/114
on Jun 5, 2020https://github.com/microsoft/TypeScript/issues/38309#event-3413388894
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.0https://github.com/microsoft/TypeScript/milestone/114
Typescript 4.0.1https://github.com/microsoft/TypeScript/milestone/123
on Jun 29, 2020https://github.com/microsoft/TypeScript/issues/38309#event-3493750408
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
RescheduledThis issue was previously scheduled to an earlier milestonehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Rescheduled%22
on Aug 31, 2020https://github.com/microsoft/TypeScript/issues/38309#event-3710483130
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.0.1https://github.com/microsoft/TypeScript/milestone/123
TypeScript 4.1.0https://github.com/microsoft/TypeScript/milestone/124
on Aug 31, 2020https://github.com/microsoft/TypeScript/issues/38309#event-3710485214
https://github.com/weswigham
Wesley Wigham (weswigham)https://github.com/weswigham
on Oct 22, 2020https://github.com/microsoft/TypeScript/issues/38309#issuecomment-714755108
#29317https://github.com/microsoft/TypeScript/pull/29317
Wesley Wigham (weswigham)https://github.com/weswigham
Design LimitationConstraints of the existing architecture prevent this from being fixedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Design%20Limitation%22
BlockedA fix for this issue is blocked on another fix being in placehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Blocked%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 Oct 22, 2020https://github.com/microsoft/TypeScript/issues/38309#event-3911097785
Andrew Branch (andrewbranch)https://github.com/andrewbranch
TypeScript 4.3.1https://github.com/microsoft/TypeScript/milestone/138
on Apr 2, 2021https://github.com/microsoft/TypeScript/issues/38309#event-4546279496
https://github.com/n9
n9https://github.com/n9
on Jun 8, 2021https://github.com/microsoft/TypeScript/issues/38309#issuecomment-856968036
TS Playhttps://www.typescriptlang.org/play#code/DYUwLgBAHgXBCuA7A1og9gd0QWAFAEsAzCACgEISoJ9EBnMAQ0QGMQ1iBBAJy4YE8AlAIgBvPBAnQIAXggBtALp4AvnigA6UIgDmYABZA
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.3.1https://github.com/microsoft/TypeScript/milestone/138
TypeScript 4.4.1 (RC)https://github.com/microsoft/TypeScript/milestone/144
on Jun 18, 2021https://github.com/microsoft/TypeScript/issues/38309#event-4910944723
Andrew Branch (andrewbranch)https://github.com/andrewbranch
TypeScript 4.4.1 (RC)https://github.com/microsoft/TypeScript/milestone/144
TypeScript 4.5.0https://github.com/microsoft/TypeScript/milestone/147
on Aug 31, 2021https://github.com/microsoft/TypeScript/issues/38309#event-5229240475
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.5.0https://github.com/microsoft/TypeScript/milestone/147
TypeScript 4.6.0https://github.com/microsoft/TypeScript/milestone/151
on Dec 15, 2021https://github.com/microsoft/TypeScript/issues/38309#event-5768063441
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.6.0https://github.com/microsoft/TypeScript/milestone/151
TypeScript 4.6.1https://github.com/microsoft/TypeScript/milestone/158
on Feb 3, 2022https://github.com/microsoft/TypeScript/issues/38309#event-6005887473
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.6.1https://github.com/microsoft/TypeScript/milestone/158
TypeScript 4.8.0https://github.com/microsoft/TypeScript/milestone/163
on May 13, 2022https://github.com/microsoft/TypeScript/issues/38309#event-6608004957
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.8.0https://github.com/microsoft/TypeScript/milestone/163
TypeScript 5.1.0https://github.com/microsoft/TypeScript/milestone/178
on Feb 1, 2023https://github.com/microsoft/TypeScript/issues/38309#event-8413679599
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Feb 24, 2024https://github.com/microsoft/TypeScript/issues/38309#event-11909314475
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/38309
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/38309
Wesley Wigham (weswigham)https://github.com/weswigham
BlockedA fix for this issue is blocked on another fix being in placehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Blocked%22
Design LimitationConstraints of the existing architecture prevent this from being fixedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Design%20Limitation%22
RescheduledThis issue was previously scheduled to an earlier milestonehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Rescheduled%22
TypeScript 5.1.0https://github.com/microsoft/TypeScript/milestone/178
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.