René's URL Explorer Experiment


Title: Flow type information across *ngFor-like directives · Issue #10510 · angular/angular · GitHub

Open Graph Title: Flow type information across *ngFor-like directives · Issue #10510 · angular/angular

X Title: Flow type information across *ngFor-like directives · Issue #10510 · angular/angular

Description: Alternative proposal for the: Allow template local variables to publish type information so that IDEs can provide better completion Thanks to @chuckjaz for the clever idea. class Person { first: string; last:string; } class MyComp { item...

Open Graph Description: Alternative proposal for the: Allow template local variables to publish type information so that IDEs can provide better completion Thanks to @chuckjaz for the clever idea. class Person { first: st...

X Description: Alternative proposal for the: Allow template local variables to publish type information so that IDEs can provide better completion Thanks to @chuckjaz for the clever idea. class Person { first: st...

Opengraph URL: https://github.com/angular/angular/issues/10510

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Flow type information across *ngFor-like directives","articleBody":"Alternative proposal for the: [Allow template local variables to publish type information so that IDEs can provide better completion](https://github.com/angular/angular/issues/4850)\n\nThanks to @chuckjaz for the clever idea.\n\n```\nclass Person {\n    first: string;\n    last:string;\n}\n\nclass MyComp {\n    items: string[];\n    people: Person[];\n}\n\n\n/**\n * Assume we have template such as this:\n * \u003cdiv *ngFor=\"let person of people; trackBy: foo\">\n *   {{people.length}}{{item.first}}\n * \u003c/div>\n */\n\n// These global variables are here only to flow the type information.\nvar _comp: MyComp;\nvar _peopleLetType = NgFor.extractTypeFromOf(_comp && _comp.people);\n\nclass MyComponentFactory{\n    context: MyComp;\n    ngFor: NgFor\u003ctypeof _peopleLetType> = new NgFor\u003ctypeof _peopleLetType>(new DivInnerFactory());\n    create() {\n        this.ngFor.of = this.context.people;\n    }\n}\n\nclass DivInnerFactory {\n    context: NgForRow\u003ctypeof _peopleLetType>;\n    text: string;\n    create() {\n        this.context.$implicit.first; // expected type OK because $implicit is Person\n        this.context.$implicit.name;  // expected type error because $implicit is Person\n    }\n}\n\nclass NgForRow\u003cT> {\n    $implicit: T;\n}\n\n@Component({\n    // we need some way to hint to the template generated which property to use for type extraction\n    // and which static function to use with that property.\n    typeTransformation: ['of', NgFor.extractTypeFromOf]\n})\nclass NgFor\u003cT>{\n    @Input({typeTransform: NgFor.extractTypeFromOf})\n    of: T[];\n    constructor(factory: Factory) {}\n    static extractTypeFromOf\u003cT>(expr: T[]|Iterable\u003cT>): T {return undefined;}\n}\n\ninterface Factory {\n    create();\n}\ninterface Iterable\u003cT> {}\nfunction Component(a:any): Function { return null; }\nfunction Input(a:any): Function { return null; }\n```\n\nTry it out in [TypeScript playground](http://www.typescriptlang.org/play/index.html#src=class%20Person%20%7B%0D%0A%09first%3A%20string%3B%0D%0A%09last%3Astring%3B%0D%0A%7D%0D%0A%0D%0Aclass%20MyComp%20%7B%0D%0A%09items%3A%20string%5B%5D%3B%0D%0A%09people%3A%20Person%5B%5D%3B%0D%0A%7D%0D%0A%0D%0A%0D%0A%2F**%0D%0A%20*%20Assume%20we%20have%20template%20such%20as%20this%3A%0D%0A%20*%20%3Cdiv%20*ngFor%3D%22let%20person%20of%20people%3B%20trackBy%3A%20foo%22%3E%0D%0A%20*%20%20%20%7B%7Bpeople.length%7D%7D%7B%7Bitem.first%7D%7D%0D%0A%20*%20%3C%2Fdiv%3E%0D%0A%20*%2F%0D%0A%0D%0A%2F%2F%20These%20global%20variables%20are%20here%20only%20to%20flow%20the%20type%20information.%0D%0Avar%20_comp%3A%20MyComp%3B%0D%0Avar%20_peopleLetType%20%3D%20NgFor.extractTypeFromOf%28_comp%20%26%26%20_comp.people%29%3B%0D%0A%0D%0Aclass%20MyComponentFactory%7B%0D%0A%09context%3A%20MyComp%3B%0D%0A%09ngFor%3A%20NgFor%3Ctypeof%20_peopleLetType%3E%20%3D%20new%20NgFor%3Ctypeof%20_peopleLetType%3E%28new%20DivInnerFactory%28%29%29%3B%0D%0A%09create%28%29%20%7B%0D%0A%09%09this.ngFor.of%20%3D%20this.context.people%3B%0D%0A%09%7D%0D%0A%7D%0D%0A%0D%0Aclass%20DivInnerFactory%20%7B%0D%0A%09context%3A%20NgForRow%3Ctypeof%20_peopleLetType%3E%3B%0D%0A%09text%3A%20string%3B%0D%0A%09create%28%29%20%7B%0D%0A%09%09this.context.%24implicit.first%3B%20%2F%2F%20expected%20type%20OK%20because%20%24implicit%20is%20Person%0D%0A%09%09this.context.%24implicit.name%3B%20%20%2F%2F%20expected%20type%20error%20because%20%24implicit%20is%20Person%0D%0A%09%7D%0D%0A%7D%0D%0A%0D%0Aclass%20NgForRow%3CT%3E%20%7B%0D%0A%09%24implicit%3A%20T%3B%0D%0A%7D%0D%0A%0D%0A%40Component%28%7B%0D%0A%09%2F%2F%20we%20need%20some%20way%20to%20hint%20to%20the%20template%20generated%20which%20property%20to%20use%20for%20type%20extraction%0D%0A%09%2F%2F%20and%20which%20static%20function%20to%20use%20with%20that%20property.%0D%0A%09typeTransformation%3A%20%5B'of'%2C%20NgFor.extractTypeFromOf%5D%0D%0A%7D%29%0D%0Aclass%20NgFor%3CT%3E%7B%0D%0A%09%40Input%28%7BtypeTransform%3A%20NgFor.extractTypeFromOf%7D%29%0D%0A%09of%3A%20T%5B%5D%3B%0D%0A%09constructor%28factory%3A%20Factory%29%20%7B%7D%0D%0A%09static%20extractTypeFromOf%3CT%3E%28expr%3A%20T%5B%5D%7CIterable%3CT%3E%29%3A%20T%20%7Breturn%20undefined%3B%7D%0D%0A%7D%0D%0A%0D%0Ainterface%20Factory%20%7B%0D%0A%09create%28%29%3B%0D%0A%7D%0D%0Ainterface%20Iterable%3CT%3E%20%7B%7D%0D%0Afunction%20Component%28a%3Aany%29%3A%20Function%20%7B%20return%20null%3B%20%7D%0D%0Afunction%20Input%28a%3Aany%29%3A%20Function%20%7B%20return%20null%3B%20%7D).\n","author":{"url":"https://github.com/mhevery","@type":"Person","name":"mhevery"},"datePublished":"2016-08-04T23:42:58Z","url":"https://github.com/angular/angular/issues/10510"}

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:1c316617-3995-26dc-6462-4e557fc4c4e8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE3C4:62283:CC0EE1:10FAB55:6B00F7A2
html-safe-noncefacc60aa3bd80200d25e95767a1d765f5cae5d020627ef814b38da29caa209ba
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0M0OjYyMjgzOkNDMEVFMToxMEZBQjU1OjZCMDBGN0EyIiwidmlzaXRvcl9pZCI6IjIyMTIxNzQzMTQwNjM1OTEzMzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac16fd5edfe0e81931343e4025716c32a287d69ce310281a8fa94dd4ced20a39be
hovercard-subject-tagissue:169499040
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/angular/angular/10510/issue_layout
twitter:imagehttps://opengraph.githubassets.com/731eefea10be8106399fcb1c48c02219431d928e8d7a66812cd85e95da2181a6/angular/angular/issues/10510
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/731eefea10be8106399fcb1c48c02219431d928e8d7a66812cd85e95da2181a6/angular/angular/issues/10510
og:image:altAlternative proposal for the: Allow template local variables to publish type information so that IDEs can provide better completion Thanks to @chuckjaz for the clever idea. class Person { first: st...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemhevery
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
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/angular/angular/issues/10510#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F10510
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%2Fangular%2Fangular%2Fissues%2F10510
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=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/10510
Reloadhttps://github.com/angular/angular/issues/10510
Reloadhttps://github.com/angular/angular/issues/10510
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests141 (141)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/10510
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/10510
Flow type information across *ngFor-like directiveshttps://github.com/angular/angular/issues/10510#top
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
freq3: highhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq3%3A%20high%22
https://github.com/mhevery
mheveryhttps://github.com/mhevery
on Aug 4, 2016https://github.com/angular/angular/issues/10510#issue-169499040
Allow template local variables to publish type information so that IDEs can provide better completionhttps://github.com/angular/angular/issues/4850
@chuckjazhttps://github.com/chuckjaz
TypeScript playgroundhttp://www.typescriptlang.org/play/index.html#src=class%20Person%20%7B%0D%0A%09first%3A%20string%3B%0D%0A%09last%3Astring%3B%0D%0A%7D%0D%0A%0D%0Aclass%20MyComp%20%7B%0D%0A%09items%3A%20string%5B%5D%3B%0D%0A%09people%3A%20Person%5B%5D%3B%0D%0A%7D%0D%0A%0D%0A%0D%0A%2F**%0D%0A%20*%20Assume%20we%20have%20template%20such%20as%20this%3A%0D%0A%20*%20%3Cdiv%20*ngFor%3D%22let%20person%20of%20people%3B%20trackBy%3A%20foo%22%3E%0D%0A%20*%20%20%20%7B%7Bpeople.length%7D%7D%7B%7Bitem.first%7D%7D%0D%0A%20*%20%3C%2Fdiv%3E%0D%0A%20*%2F%0D%0A%0D%0A%2F%2F%20These%20global%20variables%20are%20here%20only%20to%20flow%20the%20type%20information.%0D%0Avar%20_comp%3A%20MyComp%3B%0D%0Avar%20_peopleLetType%20%3D%20NgFor.extractTypeFromOf%28_comp%20%26%26%20_comp.people%29%3B%0D%0A%0D%0Aclass%20MyComponentFactory%7B%0D%0A%09context%3A%20MyComp%3B%0D%0A%09ngFor%3A%20NgFor%3Ctypeof%20_peopleLetType%3E%20%3D%20new%20NgFor%3Ctypeof%20_peopleLetType%3E%28new%20DivInnerFactory%28%29%29%3B%0D%0A%09create%28%29%20%7B%0D%0A%09%09this.ngFor.of%20%3D%20this.context.people%3B%0D%0A%09%7D%0D%0A%7D%0D%0A%0D%0Aclass%20DivInnerFactory%20%7B%0D%0A%09context%3A%20NgForRow%3Ctypeof%20_peopleLetType%3E%3B%0D%0A%09text%3A%20string%3B%0D%0A%09create%28%29%20%7B%0D%0A%09%09this.context.%24implicit.first%3B%20%2F%2F%20expected%20type%20OK%20because%20%24implicit%20is%20Person%0D%0A%09%09this.context.%24implicit.name%3B%20%20%2F%2F%20expected%20type%20error%20because%20%24implicit%20is%20Person%0D%0A%09%7D%0D%0A%7D%0D%0A%0D%0Aclass%20NgForRow%3CT%3E%20%7B%0D%0A%09%24implicit%3A%20T%3B%0D%0A%7D%0D%0A%0D%0A%40Component%28%7B%0D%0A%09%2F%2F%20we%20need%20some%20way%20to%20hint%20to%20the%20template%20generated%20which%20property%20to%20use%20for%20type%20extraction%0D%0A%09%2F%2F%20and%20which%20static%20function%20to%20use%20with%20that%20property.%0D%0A%09typeTransformation%3A%20%5B'of'%2C%20NgFor.extractTypeFromOf%5D%0D%0A%7D%29%0D%0Aclass%20NgFor%3CT%3E%7B%0D%0A%09%40Input%28%7BtypeTransform%3A%20NgFor.extractTypeFromOf%7D%29%0D%0A%09of%3A%20T%5B%5D%3B%0D%0A%09constructor%28factory%3A%20Factory%29%20%7B%7D%0D%0A%09static%20extractTypeFromOf%3CT%3E%28expr%3A%20T%5B%5D%7CIterable%3CT%3E%29%3A%20T%20%7Breturn%20undefined%3B%7D%0D%0A%7D%0D%0A%0D%0Ainterface%20Factory%20%7B%0D%0A%09create%28%29%3B%0D%0A%7D%0D%0Ainterface%20Iterable%3CT%3E%20%7B%7D%0D%0Afunction%20Component%28a%3Aany%29%3A%20Function%20%7B%20return%20null%3B%20%7D%0D%0Afunction%20Input%28a%3Aany%29%3A%20Function%20%7B%20return%20null%3B%20%7D
chuckjazhttps://github.com/chuckjaz
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
on Oct 5, 2016https://github.com/angular/angular/issues/10510#event-812589637
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
freq3: highhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq3%3A%20high%22
on Oct 12, 2016https://github.com/angular/angular/issues/10510#event-820915896
https://github.com/chuckjaz
chuckjazhttps://github.com/chuckjaz
on Oct 19, 2016https://github.com/angular/angular/issues/10510#issuecomment-254972905
#12398https://github.com/angular/angular/issues/12398
chuckjazhttps://github.com/chuckjaz
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 19, 2016https://github.com/angular/angular/issues/10510#event-829878602
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 10, 2019https://github.com/angular/angular/issues/10510#issuecomment-529728101
automatic conversation locking policyhttps://github.com/angular/angular/blob/67d80f/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 10, 2019https://github.com/angular/angular/issues/10510#event-2620603722
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/10510
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/10510
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
freq3: highhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq3%3A%20high%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.