René's URL Explorer Experiment


Title: Moving an unrelated `new Schema(…, options)` above a mongoose model turns `typeof Model extends Model` into `never` · Issue #65607 · microsoft/TypeScript · GitHub

Open Graph Title: Moving an unrelated `new Schema(…, options)` above a mongoose model turns `typeof Model extends Model` into `never` · Issue #65607 · microsoft/TypeScript

X Title: Moving an unrelated `new Schema(…, options)` above a mongoose model turns `typeof Model extends Model` into `never` · Issue #65607 · microsoft/TypeScript

Description: 🔎 Search Terms check order, declaration order, statement order, conditional type infer never, mongoose Model, history dependent diagnostics, checkers 🕗 Version & Regression Information Reproduces identically with 5.9.3, 6.0.2, 7.0.2 and ...

Open Graph Description: 🔎 Search Terms check order, declaration order, statement order, conditional type infer never, mongoose Model, history dependent diagnostics, checkers 🕗 Version & Regression Information Reproduces i...

X Description: 🔎 Search Terms check order, declaration order, statement order, conditional type infer never, mongoose Model, history dependent diagnostics, checkers 🕗 Version & Regression Information Reproduc...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Moving an unrelated `new Schema\u003cT>(…, options)` above a mongoose model turns `typeof Model extends Model\u003cinfer R>` into `never`","articleBody":"### 🔎 Search Terms\n\ncheck order, declaration order, statement order, conditional type infer never, mongoose Model, history dependent diagnostics, checkers\n\n### 🕗 Version & Regression Information\n\nReproduces identically with 5.9.3, 6.0.2, 7.0.2 and 7.1.0-dev.20261118.1, so it is not a regression of the native port.\n\n### ⏯ Playground Link\n\nNeeds `mongoose@9.11.2` and `@types/node`, so no playground link. Each of the two files below is a complete program on its own.\n\n### 💻 Code\n\n`first.ts`: the unrelated `historySchema` declared before the model.\n\n```ts\nimport mongoose, { type Model, Schema } from \"mongoose\";\n\nexport const historySchema = new Schema\u003c{ updatedAt: Date }>({ updatedAt: Date }, { _id: false });\n\nconst sentFileSchema = new Schema({\n  agency: { type: Schema.Types.ObjectId, required: true },\n});\n\nexport const SentFileModel = mongoose.model(\"SentFile\", sentFileSchema);\n\ntype SentFile = typeof SentFileModel extends Model\u003cinfer Raw> ? Raw : never;\n\nexport const readAgency = (file: SentFile) => file.agency;\n```\n\n`last.ts`: the same statements, with `historySchema` moved to the end.\n\n```ts\nimport mongoose, { type Model, Schema } from \"mongoose\";\n\nconst sentFileSchema = new Schema({\n  agency: { type: Schema.Types.ObjectId, required: true },\n});\n\nexport const SentFileModel = mongoose.model(\"SentFile\", sentFileSchema);\n\ntype SentFile = typeof SentFileModel extends Model\u003cinfer Raw> ? Raw : never;\n\nexport const readAgency = (file: SentFile) => file.agency;\n\nexport const historySchema = new Schema\u003c{ updatedAt: Date }>({ updatedAt: Date }, { _id: false });\n```\n\n```sh\nnpm i mongoose@9.11.2 @types/node typescript\nnpx tsc --noEmit --strict --module nodenext --target es2022 --skipLibCheck --types node first.ts\nnpx tsc --noEmit --strict --module nodenext --target es2022 --skipLibCheck --types node last.ts\n```\n\n### 🙁 Actual behavior\n\n```\nfirst.ts(13,52): error TS2339: Property 'agency' does not exist on type 'never'.\n```\n\n`last.ts` reports no error. Removing the `{ _id: false }` argument of `historySchema` in `first.ts` also makes the error go away.\n\n### 🙂 Expected behavior\n\nThe same diagnostics whatever the order of the two independent declarations. Either answer could be the intended one; the point is that it changes with check order.\n\n### Additional information about the issue\n\n- Assigning a similar model (same schema plus `timestamps` and a subdocument) to `Model\u003cany>` fails on 7.0.2: `Model\u003c{ agency: ObjectId; … }, {}, {}, { id: string }, …>` is not assignable to `Model\u003cany, {}, {}, {}, any, any, any>`, the elaboration ending in `The 'this' types of each signature are incompatible` / `Property 'id' is missing in type '{}' but required in type '{ id: string; }'` on `schema.virtuals`. So whether `Model` is related through its type arguments or structurally seems to depend on what an earlier statement left in the checker's caches.\n- Related: #56099 has the same shape without mongoose (an unused interface changes the result of `X extends C\u003cinfer V>`), still open. On the mongoose side, Automattic/mongoose#16503 reports that since 9.10.0 a model with typed virtuals is not assignable to `Model\u003cany>`; the maintainer observed it only on TypeScript 7 with `skipLibCheck`, never on 5.9, which fits a result that depends on check order. Their fix (Automattic/mongoose#16505) relaxed the populate typings only, so the relation itself still fails on 9.11.2.\n- In a real multi-file project the effect is order of files, not statements: the error appears or disappears depending on which file a checker visits first. With TypeScript 7's parallel checkers, that turns into diagnostics that change with `--checkers` and with how files are split across checkers. On a ~9,500-file project we see a few dozen such errors (this TS2339, TS2344 \"`Model\u003c…>` does not satisfy the constraint `Model\u003cany, {}, {}, {}, any, any, any>`\", and values typed `never`) appear only under some file orders, and none in the default order.\n\n","author":{"url":"https://github.com/jltrv","@type":"Person","name":"jltrv"},"datePublished":"2026-11-20T17:02:58Z","url":"https://github.com/microsoft/TypeScript/issues/65607"}

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:57725467-60b1-4bdf-e0df-e7f091bde094
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id95E2:31E99C:8295C9:B08743:6B00E10D
html-safe-noncea7b42fd068a79322daffa36db911f8cdf248e5ec918b00059a37baa7e5cab0cd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUUyOjMxRTk5Qzo4Mjk1Qzk6QjA4NzQzOjZCMDBFMTBEIiwidmlzaXRvcl9pZCI6Ijg4MTA3NDczOTY1ODI1OTY4NzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac9602766146d6955500bdc848534abe2d3fee92922523e923ad190c004cd4f8a2
hovercard-subject-tagissue:6516019756
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/65607/issue_layout
twitter:imagehttps://opengraph.githubassets.com/90ba6ccbc41a05c8532f65772d958d4a6033844226e96cbcc7ef78cf7ec4dc37/microsoft/TypeScript/issues/65607
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/90ba6ccbc41a05c8532f65772d958d4a6033844226e96cbcc7ef78cf7ec4dc37/microsoft/TypeScript/issues/65607
og:image:alt🔎 Search Terms check order, declaration order, statement order, conditional type infer never, mongoose Model, history dependent diagnostics, checkers 🕗 Version & Regression Information Reproduces i...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejltrv
hostnamegithub.com
expected-hostnamegithub.com
None043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf
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
release5425dc24e8bd8d6fca9641a12afc984825a43875
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/65607#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F65607
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%2F65607
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/65607
Reloadhttps://github.com/microsoft/TypeScript/issues/65607
Reloadhttps://github.com/microsoft/TypeScript/issues/65607
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/65607
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/65607
Moving an unrelated new Schema(…, options) above a mongoose model turns typeof Model extends Model into neverhttps://github.com/microsoft/TypeScript/issues/65607#top
https://github.com/jltrv
Jacques Latrive (jltrv)https://github.com/jltrv
on Nov 20, 2026https://github.com/microsoft/TypeScript/issues/65607#issue-6516019756
Unrelated interface causes assignability to change  #56099https://github.com/microsoft/TypeScript/issues/56099
9.10.0: Model with typed virtuals is no longer assignable to Model Automattic/mongoose#16503https://github.com/Automattic/mongoose/issues/16503
types: relax populate Model generics to allow typed virtuals to be passed to populate in TypeScript 7 with skipLibCheck Automattic/mongoose#16505https://github.com/Automattic/mongoose/pull/16505
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/65607
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/65607
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.