René's URL Explorer Experiment


Title: Investigate opening more files in inferred JS projects based on package.json presence · Issue #45558 · microsoft/TypeScript · GitHub

Open Graph Title: Investigate opening more files in inferred JS projects based on package.json presence · Issue #45558 · microsoft/TypeScript

X Title: Investigate opening more files in inferred JS projects based on package.json presence · Issue #45558 · microsoft/TypeScript

Description: Separating out some of the discussion in #45109 since that issue encompasses both a bug and an effective feature request that needs to be explored. Background When you open a TS or JS file in an editor, TS Server tries to figure out what...

Open Graph Description: Separating out some of the discussion in #45109 since that issue encompasses both a bug and an effective feature request that needs to be explored. Background When you open a TS or JS file in an ed...

X Description: Separating out some of the discussion in #45109 since that issue encompasses both a bug and an effective feature request that needs to be explored. Background When you open a TS or JS file in an ed...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Investigate opening more files in inferred JS projects based on package.json presence","articleBody":"Separating out some of the discussion in #45109 since that issue encompasses both a bug and an effective feature request that needs to be explored.\r\n\r\n## Background\r\n\r\nWhen you open a TS or JS file in an editor, TS Server tries to figure out what project to put that file in. It searches up the directory tree for tsconfig/jsconfig files (up until the folder opened by the editor, I believe), and if there is a project config file that includes the file in question, a “configured project” is created (or an already-open one is used). The TS Program created for these configured projects contains all the files that would normally be part of the compilation with `tsc -p path/to/tsconfig.json`. Since the Program contains everything, auto-imports and other language features will be aware of other files that are not yet open in the editor, as expected.\r\n\r\nOn the other hand, if no containing tsconfig/jsconfig is found, the open file goes into an “inferred project” that contains _just_  the files that are currently open in the editor (that aren’t part of another project), along with all their recursive imports/references. This can create a confusing experience, since open editor tabs feel like UI state, but actually affect program state: e.g., globals defined in other files will only be found when those files are open, and auto imports will only be available from files that are open or already imported from open files. This is the default experience for JS users who have no idea what a jsconfig.json is or why they would want one, but often the solution to their flaky IntelliSense issues is just to add a jsconfig.json file containing nothing but `{}` to their project root.\r\n\r\n## Investigation\r\n\r\nI hypothesized that we could give a better default experience basically by pretending that every package.json file had an empty jsconfig.json file alongside it, causing other TS/JS files recursively down the directory to be added to the project. Unsurprisingly, this is a huge oversimplification of how this could work, and after half a day or so of poking around in the code, I see a number of questions/problems deciding when to trigger this behavior and what files to include.\r\n\r\n- Obvious invariant: a file should not be part of an inferred project if it should be included by a configured project (findable within the opened folder). An inferred project should be the last resort for every file it contains.\r\n  - Scenario: open folder `/project` and file `/project/index.js`, no config file found, but `/project/package.json` is present, so we want to include additional files in the folder. When we see `/project/a/b/c/d/e/f/g/h/foo.js`, we have to check each of those subfolders for tsconfig/jsconfig files. Could this be expensive? (We may already have `readdir` results cached in the process of finding the file?)\r\n- What if there is a configured project already open with many files included, but an additional, unincluded file is open that creates an inferred project. Is it still worthwhile to search the directory tree for additional files to go into the inferred project?\r\n  - Default assumption is no—if a workspace mostly uses configured projects, the behavior of inferred projects for random additional files isn't what we're trying to target here.\r\n  - But if we don’t include additional files in the presence of configured projects, it might become complicated to maintain the state of the inferred project if a configured project gets opened or closed—if a configured project closes, does the inferred project suddenly gain files? If a configured project is opened, does the inferred project suddenly lose files? This sounds undesirable.\r\n  - Maybe we shouldn’t include additional files if a tsconfig/jsconfig is found (while searching for files to include) _anywhere_ in the opened folder (recursive)?\r\n- Should this behavior be enabled for inferred projects containing TS, or only JS? What about a mix? What about JS and .d.ts?\r\n- What files should be excluded from wildcard inclusion?\r\n\t- `.min.js`\r\n\t- `{dist,build,out}/`?\r\n\t- Should/can we take a cue from other kinds of config files? .gitignore, .vscode, package.json fields?\r\n\t- If you have a ton of compiled/vendor code we included because our heuristics didn't filter it out, you end up with a worse perf experience, and the solution is manual config. We might be trading one non-obvious problem solved by a jsconfig for another.\r\n- Still, the happy path scenario for pure unconfigured JS projects is compelling. Most tempting approach is to try it only when we're pretty sure the workspace will never open a configured project.\r\n  - Should the JS/TS VS Code extension just detect this and prompt to add a jsconfig file instead?\r\n- Not yet explored: how to detect and what to do for monorepo-like projects","author":{"url":"https://github.com/andrewbranch","@type":"Person","name":"andrewbranch"},"datePublished":"2021-08-23T23:55:40Z","url":"https://github.com/microsoft/TypeScript/issues/45558"}

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:ab6a68e8-96ea-19db-7bc1-6628e70b2851
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB670:6365:7FF4A9:ACA3C5:6B00E0E9
html-safe-nonce4bed433151f62d1972a5d836718b79f64da13253216b17f42540a1b45ff1f31c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjcwOjYzNjU6N0ZGNEE5OkFDQTNDNTo2QjAwRTBFOSIsInZpc2l0b3JfaWQiOiI4MzEzNTIyODY4MTMwNDcyMTY5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac05856e725544c13e890068de68df7815ed3149602fed0cfd76d27b7e36509c40
hovercard-subject-tagissue:977572306
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/45558/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5d405263378e671be76da3f334bd8be05c2e09126995881e541f1e1680ca16ba/microsoft/TypeScript/issues/45558
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5d405263378e671be76da3f334bd8be05c2e09126995881e541f1e1680ca16ba/microsoft/TypeScript/issues/45558
og:image:altSeparating out some of the discussion in #45109 since that issue encompasses both a bug and an effective feature request that needs to be explored. Background When you open a TS or JS file in an ed...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameandrewbranch
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/45558#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F45558
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%2F45558
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/45558
Reloadhttps://github.com/microsoft/TypeScript/issues/45558
Reloadhttps://github.com/microsoft/TypeScript/issues/45558
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/45558
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/45558
Investigate opening more files in inferred JS projects based on package.json presencehttps://github.com/microsoft/TypeScript/issues/45558#top
https://github.com/andrewbranch
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
Backloghttps://github.com/microsoft/TypeScript/milestone/29
https://github.com/andrewbranch
Andrew Branch (andrewbranch)https://github.com/andrewbranch
on Aug 23, 2021https://github.com/microsoft/TypeScript/issues/45558#issue-977572306
#45109https://github.com/microsoft/TypeScript/issues/45109
Andrew Branch (andrewbranch)https://github.com/andrewbranch
on Aug 23, 2021https://github.com/microsoft/TypeScript/issues/45558#event-5197491166
Andrew Branch (andrewbranch)https://github.com/andrewbranch
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 Aug 23, 2021https://github.com/microsoft/TypeScript/issues/45558#event-5197493867
Andrew Branch (andrewbranch)https://github.com/andrewbranch
TypeScript 4.5.0https://github.com/microsoft/TypeScript/milestone/147
on Aug 23, 2021https://github.com/microsoft/TypeScript/issues/45558#event-5197494079
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Aug 24, 2021https://github.com/microsoft/TypeScript/issues/45558#issuecomment-905005277
Andrew Branch (andrewbranch)https://github.com/andrewbranch
TypeScript 4.5.0https://github.com/microsoft/TypeScript/milestone/147
TypeScript 4.5.1https://github.com/microsoft/TypeScript/milestone/150
on Oct 8, 2021https://github.com/microsoft/TypeScript/issues/45558#event-5435955772
Andrew Branch (andrewbranch)https://github.com/andrewbranch
RescheduledThis issue was previously scheduled to an earlier milestonehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Rescheduled%22
on Dec 7, 2021https://github.com/microsoft/TypeScript/issues/45558#event-5729224763
Andrew Branch (andrewbranch)https://github.com/andrewbranch
TypeScript 4.5.1https://github.com/microsoft/TypeScript/milestone/150
TypeScript 4.6.0https://github.com/microsoft/TypeScript/milestone/151
on Dec 7, 2021https://github.com/microsoft/TypeScript/issues/45558#event-5729226792
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/45558#event-6005674412
Andrew Branch (andrewbranch)https://github.com/andrewbranch
TypeScript 4.6.1https://github.com/microsoft/TypeScript/milestone/158
TypeScript 4.7.0https://github.com/microsoft/TypeScript/milestone/156
on Feb 11, 2022https://github.com/microsoft/TypeScript/issues/45558#event-6053036487
Andrew Branch (andrewbranch)https://github.com/andrewbranch
RescheduledThis issue was previously scheduled to an earlier milestonehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Rescheduled%22
on Mar 22, 2022https://github.com/microsoft/TypeScript/issues/45558#event-6287348680
Andrew Branch (andrewbranch)https://github.com/andrewbranch
TypeScript 4.7.0https://github.com/microsoft/TypeScript/milestone/156
Backloghttps://github.com/microsoft/TypeScript/milestone/29
on Mar 22, 2022https://github.com/microsoft/TypeScript/issues/45558#event-6287348975
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/45558
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/45558
Andrew Branch (andrewbranch)https://github.com/andrewbranch
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
BacklogNo due datehttps://github.com/microsoft/TypeScript/milestone/29
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.