René's URL Explorer Experiment


Title: Only look up package.json type if module is node16/nodenext or file is in node_modules by andrewbranch · Pull Request #58825 · microsoft/TypeScript · GitHub

Open Graph Title: Only look up package.json type if module is node16/nodenext or file is in node_modules by andrewbranch · Pull Request #58825 · microsoft/TypeScript

X Title: Only look up package.json type if module is node16/nodenext or file is in node_modules by andrewbranch · Pull Request #58825 · microsoft/TypeScript

Description: This walks back the heuristics added to non-Node.js module modes in #57896 a bit, based mostly on feedback in #58663. In 5.5-beta, an explicit package.json "type" or module-format-specific file extension started overriding "module": "commonjs" or "module": "esnext" in tsconfig.json. This impacted both type checking (relevant primarily for imports of node_modules dependencies, but with some effects on local files, e.g. with verbatimModuleSyntax) and emit (relevant for local project source files, if emit was enabled). The feedback in #58663 was that the effects on local files were unwelcome because the emitted files (whether from tsc or another tool) were going to be placed in some other context tsc didn’t know about, so the package.json tsc was finding during compilation shouldn’t be considered during the build. With this PR, we only look up package.json "type" if --module is node16/nodenext (as we’ve always done) or if the file is inside node_modules. Some testing and experimentation is still needed to ensure this doesn’t create inconsistencies with symlinked monorepos. This doesn’t seem to cause inconsistencies with workspaces-style monorepos, because module resolution takes the realpath of files in node_modules before we see if we need to look up a package.json "type". So in a project references example like . └── packages/ ├── app/ │ ├── node_modules/shared ↪︎ │ ├── tsconfig.json │ ├── package.json │ └── index.ts └── shared/ ├── dist/index.d.ts ├── src/index.ts ├── tsconfig.json └── package.json When we build shared/tsconfig.json, we decide that shared/src/index.ts is not inside node_modules. Then, when we build app/tsconfig.json, even though we resolve app/node_modules/shared/dist/index.d.ts, we realpath it to shared/dist/index.d.ts and count it as not inside node_modules. Having this consistency between input and output files regardless of how they’re resolved is what matters most. The caveat is that the realpath and project references logic can cause the type checking of app/tsconfig.json during development to behave differently than it would after publishing/deploying into a situation where app/node_modules/shared is no longer a symlink, but a real node_modules package. Fixes #54752 Fixes #50647

Open Graph Description: This walks back the heuristics added to non-Node.js module modes in #57896 a bit, based mostly on feedback in #58663. In 5.5-beta, an explicit package.json "type" or module-format-specifi...

X Description: This walks back the heuristics added to non-Node.js module modes in #57896 a bit, based mostly on feedback in #58663. In 5.5-beta, an explicit package.json "type" or module-format...

Opengraph URL: https://github.com/microsoft/TypeScript/pull/58825

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:3eff40e5-d92a-7bee-4031-289c7ebb8ad4
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA9A4:20176B:1FCFA20:2B1E3DC:6A6557B9
html-safe-nonce705fb57a680ab0d8cc3ba1cbf1ac43df43ac57bd8fa16a319a2cc15506ca408c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOUE0OjIwMTc2QjoxRkNGQTIwOjJCMUUzREM6NkE2NTU3QjkiLCJ2aXNpdG9yX2lkIjoiOTgzMzI1NzI5MDQ3Nzk1NjQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacad1351f47b9d18d8c5f513d9f0bcfeb7cb078cc77563f4a88d64be220325a8e4
hovercard-subject-tagpull_request:1913239815
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
twitter:imagehttps://avatars.githubusercontent.com/u/3277153?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/3277153?s=400&v=4
og:image:altThis walks back the heuristics added to non-Node.js module modes in #57896 a bit, based mostly on feedback in #58663. In 5.5-beta, an explicit package.json "type" or module-format-specifi...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b
turbo-cache-controlno-preview
diff-viewunified
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
release309153364422b3c499922d1a2a6404910a58ed8e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fpull%2F58825%2Fcommits%2F9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fpull%2F58825%2Fcommits%2F9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fcommits&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
Reloadhttps://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
Reloadhttps://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
Please reload this pagehttps://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
microsoft https://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Notifications https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Fork 13.6k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Star 110k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Code https://github.com/microsoft/TypeScript
Issues 5k+ https://github.com/microsoft/TypeScript/issues
Pull requests 20 https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality 0 https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Code https://github.com/microsoft/TypeScript
Issues https://github.com/microsoft/TypeScript/issues
Pull requests https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fmicrosoft%2FTypeScript%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmicrosoft%2FTypeScript%2Fissues%2Fnew%2Fchoose
andrewbranchhttps://github.com/andrewbranch
microsoft:mainhttps://github.com/microsoft/TypeScript/tree/main
andrewbranch:package-json-type-only-in-node_moduleshttps://github.com/andrewbranch/TypeScript/tree/package-json-type-only-in-node_modules
Conversation 21 https://github.com/microsoft/TypeScript/pull/58825
Commits 7 https://github.com/microsoft/TypeScript/pull/58825/commits
Checks 0 https://github.com/microsoft/TypeScript/pull/58825/checks
Files changed https://github.com/microsoft/TypeScript/pull/58825/files
Please reload this pagehttps://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
Only look up package.json type if module is node16/nodenext or file is in node_modules https://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a#top
Show all changes 7 commits https://github.com/microsoft/TypeScript/pull/58825/files
c4069c5 Revert "Revert "Respect package.json `"type"` and module-format-speci… andrewbranch Jun 17, 2024 https://github.com/microsoft/TypeScript/pull/58825/commits/c4069c58b0aaa0eaa738f4419c03b7d6bba9797a
6208d2f Revert "Revert "[DO NOT MERGE UNTIL 5.6] Fix re-exported defaults in … andrewbranch Jun 17, 2024 https://github.com/microsoft/TypeScript/pull/58825/commits/6208d2f6890a37a72e46b71b0a1e3eecf4794f37
1df4982 Merge branch 'main' into package-json-type-only-in-node_modules andrewbranch Jun 24, 2024 https://github.com/microsoft/TypeScript/pull/58825/commits/1df498290dad5c1661180a364973cfae3707457f
953711b Merge branch 'main' into package-json-type-only-in-node_modules andrewbranch Jul 1, 2024 https://github.com/microsoft/TypeScript/pull/58825/commits/953711b03924d7e7d0d04cf0ad6929af0f7a3f7e
5445d35 Remove unnecessary `type` import modifier andrewbranch Jul 1, 2024 https://github.com/microsoft/TypeScript/pull/58825/commits/5445d351b961ff8928044ee26d3178145524676c
8e6ae69 Update comments andrewbranch Jul 1, 2024 https://github.com/microsoft/TypeScript/pull/58825/commits/8e6ae696e19686c8a370b93446bd7d5abf2d9682
9d9a7a8 Silence knip bug andrewbranch Jul 1, 2024 https://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
Clear filters https://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
Please reload this pagehttps://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
Please reload this pagehttps://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
Prev https://github.com/microsoft/TypeScript/pull/58825/commits/8e6ae696e19686c8a370b93446bd7d5abf2d9682
Please reload this pagehttps://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a
https://github.com/andrewbranch
andrewbranchhttps://github.com/microsoft/TypeScript/commits?author=andrewbranch
src/compiler/program.tshttps://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a#diff-dbfa0e7f632eca196a5ee0e08e00743c46c03799e2704206cfccc065bb6f9e3a
View file https://github.com/andrewbranch/TypeScript/blob/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a/src/compiler/program.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/TypeScript/pull/58825/commits/{{ revealButtonHref }}
https://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a#diff-dbfa0e7f632eca196a5ee0e08e00743c46c03799e2704206cfccc065bb6f9e3a
https://github.com/microsoft/TypeScript/pull/58825/commits/9d9a7a8c3f1d48bcaa646834126dc55ae4c59f3a#diff-dbfa0e7f632eca196a5ee0e08e00743c46c03799e2704206cfccc065bb6f9e3a
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.