René's URL Explorer Experiment


Title: `inject` function does not correctly infer the return type when used with generic classes/abstract classes · Issue #48126 · angular/angular · GitHub

Open Graph Title: `inject` function does not correctly infer the return type when used with generic classes/abstract classes · Issue #48126 · angular/angular

X Title: `inject` function does not correctly infer the return type when used with generic classes/abstract classes · Issue #48126 · angular/angular

Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description If we use the inject function with a generic class (or abstract class), the return type won't be properly inferred: import { inject } from '...

Open Graph Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description If we use the inject function with a generic class (or abstract class), the return type won't be pro...

X Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description If we use the inject function with a generic class (or abstract class), the return type won't be...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`inject` function does not correctly infer the return type when used with generic classes/abstract classes","articleBody":"### Which @angular/* package(s) are the source of the bug?\r\n\r\ncore\r\n\r\n### Is this a regression?\r\n\r\nNo\r\n\r\n### Description\r\n\r\nIf we use the `inject` function with a generic class (or abstract class), the return type won't be properly inferred:\r\n\r\n```ts\r\nimport { inject } from '@angular/core';\r\n\r\nclass C\u003cT extends number> {}\r\n\r\nconst c1 = inject(C); // type: C\u003cany>\r\nconst c2 = inject(C\u003c1>) // type: C\u003cany>\r\n\r\nabstract class AC\u003cT extends string> {}\r\n\r\nconst ac1 = inject(AC); // type: AC\u003cany>\r\nconst ac2 = inject(AC\u003c'ng'>); // type: AC\u003cany>\r\n```\r\n\r\nTyping issue is due to the AbstractType interface. It's currently defined as follows:\r\n\r\n```ts\r\ninterface AbstractType\u003cT> extends Function {\r\n  prototype: T;\r\n}\r\n```\r\n\r\nTo solve this typing bug, `AbstractType` can be defined as follows:\r\n\r\n```ts\r\ntype AbstractType\u003cT> = abstract new (...args: unknown[]) => T;\r\n```\r\n\r\nHere is the [Stackblitz playground](https://stackblitz.com/edit/angular-qldklj-4f7htw?file=src%2Fapp%2Finject-typing-demo.ts) containing the `typedInject` function that solves this issue.\r\n\r\n---\r\n\r\n**This fix would introduce a breaking change.**\r\n\r\n---\r\n\r\n**If accepted, I'll create a PR for this bug.**\r\n\r\n### Please provide a link to a minimal reproduction of the bug\r\n\r\nhttps://stackblitz.com/edit/angular-qldklj?file=src%2Fapp%2Finject-typing-demo.ts\r\n\r\n### Please provide the exception or error you saw\r\n\r\n_No response_\r\n\r\n### Please provide the environment you discovered this bug in (run `ng version`)\r\n\r\n```true\r\nAngular CLI: 15.0.0\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\nAs a workaround, we can explicitly set the return type:\r\n\r\n```ts\r\nclass C\u003cT extends number> {}\r\n\r\nconst c = inject\u003cC\u003cnumber>>(C);\r\n```","author":{"url":"https://github.com/markostanimirovic","@type":"Person","name":"markostanimirovic"},"datePublished":"2022-11-19T02:19:29Z","url":"https://github.com/angular/angular/issues/48126"}

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:384ff597-313d-5c10-6d4f-84c80f5b8ed6
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD0FC:3DA8B4:7AA947:A4BDD9:6B06329F
html-safe-nonce4f2b8868ca47ded7438cdd088eb6293597e4763113d264b9629d963d4a03ac70
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEZDOjNEQThCNDo3QUE5NDc6QTRCREQ5OjZCMDYzMjlGIiwidmlzaXRvcl9pZCI6IjMyMzgzMTk0NTIyMjM1ODI4NzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf1593e7ed5448073418a280e2ffc97a7a5a0d3cd9f52f689a1c072dc062a0a9e
hovercard-subject-tagissue:1456125745
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/48126/issue_layout
twitter:imagehttps://opengraph.githubassets.com/984a0b49f179248a4e9476028cf4263b315ccb0b239c764fab2fea6903406be4/angular/angular/issues/48126
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/984a0b49f179248a4e9476028cf4263b315ccb0b239c764fab2fea6903406be4/angular/angular/issues/48126
og:image:altWhich @angular/* package(s) are the source of the bug? core Is this a regression? No Description If we use the inject function with a generic class (or abstract class), the return type won't be pro...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemarkostanimirovic
hostnamegithub.com
expected-hostnamegithub.com
Nonec3584c853cd39700ecff6e2cf8364295ffdb5313e571046c41cd2479270f7df0
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
release9eb3bb1597d09170a5f282cd38ae376dee1a5ec1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/48126#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F48126
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%2F48126
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/48126
Reloadhttps://github.com/angular/angular/issues/48126
Reloadhttps://github.com/angular/angular/issues/48126
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues831 (831)https://github.com/angular/angular/issues
Pull requests122 (122)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/48126
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/48126
inject function does not correctly infer the return type when used with generic classes/abstract classeshttps://github.com/angular/angular/issues/48126#top
P4https://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P4%22
area: corehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
bughttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22bug%22
core: dihttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22core%3A%20di%22
cross-cutting: typeshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22cross-cutting%3A%20types%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/markostanimirovic
markostanimirovichttps://github.com/markostanimirovic
on Nov 19, 2022https://github.com/angular/angular/issues/48126#issue-1456125745
Stackblitz playgroundhttps://stackblitz.com/edit/angular-qldklj-4f7htw?file=src%2Fapp%2Finject-typing-demo.ts
https://stackblitz.com/edit/angular-qldklj?file=src%2Fapp%2Finject-typing-demo.tshttps://stackblitz.com/edit/angular-qldklj?file=src%2Fapp%2Finject-typing-demo.ts
Nexthttps://github.com/angular/angular/issues/48126?timeline_page=1
markostanimirovichttps://github.com/markostanimirovic
on Nov 19, 2022https://github.com/angular/angular/issues/48126#event-7848700397
dylhunnhttps://github.com/dylhunn
area: corehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
on Nov 21, 2022https://github.com/angular/angular/issues/48126#event-7859821687
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
on Nov 21, 2022https://github.com/angular/angular/issues/48126#event-7859821955
dylhunnhttps://github.com/dylhunn
core: dihttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22core%3A%20di%22
bughttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22bug%22
on Nov 21, 2022https://github.com/angular/angular/issues/48126#event-7859822082
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
cross-cutting: typeshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22cross-cutting%3A%20types%22
on Dec 6, 2022https://github.com/angular/angular/issues/48126#event-7961959969
https://github.com/pkozlowski-opensource
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
on Dec 7, 2022https://github.com/angular/angular/issues/48126#issuecomment-1341097638
@markostanimirovichttps://github.com/markostanimirovic
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
P4https://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P4%22
on Dec 7, 2022https://github.com/angular/angular/issues/48126#event-7978780661
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
Backloghttps://github.com/angular/angular/milestone/82
on Dec 7, 2022https://github.com/angular/angular/issues/48126#event-7978781217
JeanMechehttps://github.com/JeanMeche
on May 21, 2025https://github.com/angular/angular/issues/48126#event-17756194860
fix(core): infer correct return type when `inject` is used with gener…https://github.com/markostanimirovic/angular/commit/2400b8448b3082b8213cdbe55e144814223debc5
https://docs.github.com/articles/closing-issues-via-commit-messages
2400b84https://github.com/markostanimirovic/angular/commit/2400b8448b3082b8213cdbe55e144814223debc5
JeanMechehttps://github.com/JeanMeche
on Nov 2, 2026https://github.com/angular/angular/issues/48126#event-34864455896
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/3c510f5db6637e5f1ea00c29e2ef11c9e3435414
https://docs.github.com/articles/closing-issues-via-commit-messages
3c510f5https://github.com/JeanMeche/angular/commit/3c510f5db6637e5f1ea00c29e2ef11c9e3435414
JeanMechehttps://github.com/JeanMeche
on Nov 3, 2026https://github.com/angular/angular/issues/48126#event-35063146146
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/c7beaf58f969c67b538e1eefadb071ea845005cd
https://docs.github.com/articles/closing-issues-via-commit-messages
c7beaf5https://github.com/JeanMeche/angular/commit/c7beaf58f969c67b538e1eefadb071ea845005cd
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/454585c893e9a8c3055edf901354962f504b21dc
https://docs.github.com/articles/closing-issues-via-commit-messages
454585chttps://github.com/JeanMeche/angular/commit/454585c893e9a8c3055edf901354962f504b21dc
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/704d1bd2d54d42aae2f02b00b59388eb2e097508
https://docs.github.com/articles/closing-issues-via-commit-messages
704d1bdhttps://github.com/JeanMeche/angular/commit/704d1bd2d54d42aae2f02b00b59388eb2e097508
JeanMechehttps://github.com/JeanMeche
on Nov 11, 2026https://github.com/angular/angular/issues/48126#event-35747909718
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/91969de5748029986454ddf4847a364d2e4451c5
https://docs.github.com/articles/closing-issues-via-commit-messages
91969dehttps://github.com/JeanMeche/angular/commit/91969de5748029986454ddf4847a364d2e4451c5
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/a1b5e97c6b4a2fa81fe937060c6c13b51ba83a73
https://docs.github.com/articles/closing-issues-via-commit-messages
a1b5e97https://github.com/JeanMeche/angular/commit/a1b5e97c6b4a2fa81fe937060c6c13b51ba83a73
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/952853b31ee4de00f42ac4bb6fcdd66c26bb1390
https://docs.github.com/articles/closing-issues-via-commit-messages
952853bhttps://github.com/JeanMeche/angular/commit/952853b31ee4de00f42ac4bb6fcdd66c26bb1390
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/7f67dc7f3d64a00543e4343a04e76caabe3786fb
https://docs.github.com/articles/closing-issues-via-commit-messages
7f67dc7https://github.com/JeanMeche/angular/commit/7f67dc7f3d64a00543e4343a04e76caabe3786fb
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/4911874500924e57f7db72937dc8b2e80b439598
https://docs.github.com/articles/closing-issues-via-commit-messages
4911874https://github.com/JeanMeche/angular/commit/4911874500924e57f7db72937dc8b2e80b439598
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/d20037f8c482352c6f373463e74af3038becd7ec
https://docs.github.com/articles/closing-issues-via-commit-messages
d20037fhttps://github.com/JeanMeche/angular/commit/d20037f8c482352c6f373463e74af3038becd7ec
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/01cca4e73793be03c475565a275687ca95f720dd
https://docs.github.com/articles/closing-issues-via-commit-messages
01cca4ehttps://github.com/JeanMeche/angular/commit/01cca4e73793be03c475565a275687ca95f720dd
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/72b3fb5fbf866ef5239a360568a87d0a2daa72a1
https://docs.github.com/articles/closing-issues-via-commit-messages
72b3fb5https://github.com/JeanMeche/angular/commit/72b3fb5fbf866ef5239a360568a87d0a2daa72a1
fix(core): preserve generic type parameters when injecting or queryin…https://github.com/JeanMeche/angular/commit/ada8b0d3a495bf53bf1da4810137c27a252b813a
https://docs.github.com/articles/closing-issues-via-commit-messages
ada8b0dhttps://github.com/JeanMeche/angular/commit/ada8b0d3a495bf53bf1da4810137c27a252b813a
JeanMechehttps://github.com/JeanMeche
on Nov 24, 2026https://github.com/angular/angular/issues/48126#event-37155393532
refactor(core): preserve generic type parameters when injecting or qu…https://github.com/JeanMeche/angular/commit/81d2de193a4c3a5d66bcc9be74831b05628ec3d9
81d2de1https://github.com/JeanMeche/angular/commit/81d2de193a4c3a5d66bcc9be74831b05628ec3d9
refactor(core): add g3-only overloads to preserve generic token typeshttps://github.com/JeanMeche/angular/commit/11ef300b945574141950d5a5ea22eec115efd90f
11ef300https://github.com/JeanMeche/angular/commit/11ef300b945574141950d5a5ea22eec115efd90f
refactor(core): add g3-only overloads to preserve generic token typeshttps://github.com/JeanMeche/angular/commit/9628aad6bf3c589be3a8d2c8a8b57a4590d6c230
9628aadhttps://github.com/JeanMeche/angular/commit/9628aad6bf3c589be3a8d2c8a8b57a4590d6c230
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/48126
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/48126
P4https://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P4%22
area: corehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
bughttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22bug%22
core: dihttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22core%3A%20di%22
cross-cutting: typeshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22cross-cutting%3A%20types%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.