René's URL Explorer Experiment


Title: Auto-import in TypeScript suggests one outlandish choice, doesn't list reasonable ones · Issue #43352 · microsoft/TypeScript · GitHub

Open Graph Title: Auto-import in TypeScript suggests one outlandish choice, doesn't list reasonable ones · Issue #43352 · microsoft/TypeScript

X Title: Auto-import in TypeScript suggests one outlandish choice, doesn't list reasonable ones · Issue #43352 · microsoft/TypeScript

Description: VS Code Version: 1.54.3 OS Version: macOS 10.14.6 Does this issue occur when all extensions are disabled?: Yes I have a monorepo with a directory structure like so: @myscope/ foo/ package.json node_modules/ ... MyClass.ts index.ts <- exp...

Open Graph Description: VS Code Version: 1.54.3 OS Version: macOS 10.14.6 Does this issue occur when all extensions are disabled?: Yes I have a monorepo with a directory structure like so: @myscope/ foo/ package.json node...

X Description: VS Code Version: 1.54.3 OS Version: macOS 10.14.6 Does this issue occur when all extensions are disabled?: Yes I have a monorepo with a directory structure like so: @myscope/ foo/ package.json node...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Auto-import in TypeScript suggests one outlandish choice, doesn't list reasonable ones","articleBody":"\u003c!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->\r\n\u003c!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->\r\n\u003c!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->\r\n\u003c!-- 🔎 Search existing issues to avoid creating duplicates. -->\r\n\u003c!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->\r\n\u003c!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->\r\n- VS Code Version: 1.54.3\r\n- OS Version: macOS 10.14.6\r\n\r\n\r\n\u003c!-- 🔧 Launch with `code --disable-extensions` to check. -->\r\nDoes this issue occur when all extensions are disabled?: Yes\r\n\r\nI have a monorepo with a directory structure like so:\r\n\r\n```\r\n@myscope/\r\n  foo/\r\n    package.json\r\n    node_modules/\r\n      ...\r\n    MyClass.ts\r\n    index.ts   \u003c- exports MyClass\r\n  bar/\r\n    package.json   \u003c- depends on @myscope/foo\r\n    node_modules/\r\n      ...\r\n    index.ts   \u003c- re-exports MyClass\r\n  bar-demo/\r\n    package.json   \u003c- depends on @myscope/bar\r\n    node_modules/\r\n      ...\r\n  baz/\r\n    package.json   \u003c- depends on @myscope/foo\r\n    node_modules/\r\n      ...\r\n    currentFile.ts\r\n```\r\n\r\nNow, in a sane world, the sort of tough problem faced by VS Code would be how to prioritize the different reasonable ways to import `MyClass`.  Suppose a package (not shown) depended on *both* `@myscope/foo` and `@myscope/bar`, then there would be *three* possible ways to import it:\r\n\r\n```\r\nimport { MyClass } from \"@myscope/foo\";\r\nimport { MyClass } from \"@myscope/foo/MyClass\";\r\nimport { MyClass } from \"@myscope/bar\";\r\n```\r\n\r\nI would be coming here asking, for example, how to de-prioritize the second one, because I'm using `index.ts` files with barrel exports.\r\n\r\nHowever, that is not the world we live in, because when I am in `currentFile.ts` (above), and I type `MyClass`, I might be offered *one* choice like:\r\n\r\n```\r\nMyClass (@myscope/foo/MyClass)  >  Auto import from '../foo-demo/node_modules/@myscope/bar'\r\n```\r\n\r\n...with no other choices, when the correct and only reasonable place to auto-import from is (simply) `'@myscope/foo'`.\r\n\r\nThis is just the most bizarre thing.\r\n\r\n* Why would a convoluted path involving `..` and descending into `node_modules` ever be given priority over a simple one?\r\n* Why isn't the \"correct\" module path (or any others) at least listed alongside the weird one as an option?\r\n* Why does the gray text next to MyClass (rendered in parentheses in the snippet above) disagree with the part that says \"Auto import from...\", with one referring to `@myscope/foo` and the other referring to `@myscope/bar` inside the `foo-demo` package?\r\n\r\nBefore VS Code, I used Emacs, for over a decade, and the auto-import features I encountered there were similarly terrible.  I've never had a good auto-import experience, at least in JS/TS.  But, VS Code's feature does save me some typing, even if I have to constantly correct it, and I have hope it could one day serve me well.\r\n\r\nCan extensions improve this experience?  I have looked through the extension API a bit, but I can't find anything about influencing auto-import suggestions, even though there are apparently extensions that do this, including a popular one called Auto Import (which doesn't explain how it differs from or interacts with VS Code's built-in feature that does the same thing).\r\n\r\nI would like to know what auto-import is expected to be able to do, or take into account, and what it simply doesn't.  I feel like there is some design limitation here, like maybe the different ways of importing MyClass are considered \"the same\" because they ultimately come from the same original declaration?  That doesn't explain why the single path chosen among many is such a bad one, though.\r\n\r\nIf I were sitting down to write an auto-import feature from scratch that needed to come up with good suggestions for how to import a symbol, I would take factors into account like:\r\n\r\n* Is the symbol exported by a module that is already being imported from in this file?\r\n* How is this symbol usually imported in this workspace?\r\n* What is available in the nearest node_modules?\r\n\r\nThe first one seems like a no-brainer.  The second one might require architectural changes or something, but an auto-import feature that *only* looked at existing import statements as source material might actually be more useful and accurate a lot of the time than what the current system is doing.\r\n\r\nWhen this problem isn't occurring, I actually do encounter the \"in a sane world\" problem mentioned above, where VS Code will not see and choose `@myscope/foo` over `@myscope/foo/MyClass` even though the former is shorter, even with 'Import Module Specifier' set to 'shortest.'","author":{"url":"https://github.com/dgreensp","@type":"Person","name":"dgreensp"},"datePublished":"2021-03-23T15:38:08Z","url":"https://github.com/microsoft/TypeScript/issues/43352"}

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:0b393b4c-49bd-d252-ce48-15eb7e4d2ba4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8E18:296654:991A0B:CEDD04:6B00E99E
html-safe-nonce5c6888980791efdc0067b0792790b8fa573fac266926e4b6c989753cf7dd853c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTE4OjI5NjY1NDo5OTFBMEI6Q0VERDA0OjZCMDBFOTlFIiwidmlzaXRvcl9pZCI6Ijg0MzEzOTMzNzUwNzYyODA3MzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac8b8b586f48acbf6d269e3c47e606ac8be5320c60a5457f05d295cbce8864144c
hovercard-subject-tagissue:839120571
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/43352/issue_layout
twitter:imagehttps://opengraph.githubassets.com/606830d9a1ba009da96b3e838a28c1e236d0cf56dcc23b21d82ed08512ebafbe/microsoft/TypeScript/issues/43352
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/606830d9a1ba009da96b3e838a28c1e236d0cf56dcc23b21d82ed08512ebafbe/microsoft/TypeScript/issues/43352
og:image:altVS Code Version: 1.54.3 OS Version: macOS 10.14.6 Does this issue occur when all extensions are disabled?: Yes I have a monorepo with a directory structure like so: @myscope/ foo/ package.json node...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedgreensp
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
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
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/43352#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F43352
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%2F43352
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/43352
Reloadhttps://github.com/microsoft/TypeScript/issues/43352
Reloadhttps://github.com/microsoft/TypeScript/issues/43352
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests308 (308)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/43352
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/43352
Auto-import in TypeScript suggests one outlandish choice, doesn't list reasonable oneshttps://github.com/microsoft/TypeScript/issues/43352#top
Needs More InfoThe issue still hasn't been fully clarifiedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20More%20Info%22
https://github.com/dgreensp
David Greenspan (dgreensp)https://github.com/dgreensp
on Mar 23, 2021https://github.com/microsoft/TypeScript/issues/43352#issue-839120571
VS Code Issue Triage Bot (vscode-triage-bot)https://github.com/vscode-triage-bot
Matt Bierner (mjbvz)https://github.com/mjbvz
on Mar 23, 2021https://github.com/microsoft/TypeScript/issues/43352#event-4497279493
Matt Bierner (mjbvz)https://github.com/mjbvz
microsoft/vscodehttps://github.com/microsoft/vscode
on Mar 23, 2021https://github.com/microsoft/TypeScript/issues/43352#event-4498544277
Matt Bierner (mjbvz)https://github.com/mjbvz
on Mar 23, 2021https://github.com/microsoft/TypeScript/issues/43352#event-4498544530
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Mar 23, 2021https://github.com/microsoft/TypeScript/issues/43352#issuecomment-805277245
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs More InfoThe issue still hasn't been fully clarifiedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20More%20Info%22
on Mar 23, 2021https://github.com/microsoft/TypeScript/issues/43352#event-4498657276
https://github.com/dgreensp
David Greenspan (dgreensp)https://github.com/dgreensp
on Mar 26, 2021https://github.com/microsoft/TypeScript/issues/43352#issuecomment-808490520
https://github.com/aminpaks
Amin Pakseresht (aminpaks)https://github.com/aminpaks
on May 7, 2021https://github.com/microsoft/TypeScript/issues/43352#issuecomment-834675362
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on May 11, 2021https://github.com/microsoft/TypeScript/issues/43352#issuecomment-838827574
https://github.com/aminpaks
Amin Pakseresht (aminpaks)https://github.com/aminpaks
on May 12, 2021https://github.com/microsoft/TypeScript/issues/43352#issuecomment-839815630
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/microsoft/vscode/issues/123683https://github.com/microsoft/vscode/issues/123683
https://github.com/andrewbranch
Andrew Branch (andrewbranch)https://github.com/andrewbranch
on Jun 28, 2023https://github.com/microsoft/TypeScript/issues/43352#issuecomment-1612236786
Andrew Branch (andrewbranch)https://github.com/andrewbranch
not plannedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Anot-planned
on Jun 28, 2023https://github.com/microsoft/TypeScript/issues/43352#event-9670995792
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/43352
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/43352
Needs More InfoThe issue still hasn't been fully clarifiedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20More%20Info%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.