Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript incorrectly auto-importing string from fp-ts. #48075

Closed
kkirby opened this issue Mar 1, 2022 · 7 comments · Fixed by #48939
Closed

TypeScript incorrectly auto-importing string from fp-ts. #48075

kkirby opened this issue Mar 1, 2022 · 7 comments · Fixed by #48939
Assignees
Labels
Domain: Auto-import Fix Available A PR has been opened for this issue Needs More Info The issue still hasn't been fully clarified

Comments

@kkirby
Copy link

kkirby commented Mar 1, 2022

Bug Report

I originally commented on this issue: #35395 but was directed to make a new issue.

If I have fp-ts installed to my project, and then type something like:

type A = {
  value: string;
}

The TypeScript language server auto-imports string from fp-ts.

A minimum reproduction can be done on CodeSandbox. Simply create an empty TypeScript project. Add fp-ts to the dependencies. Then type the code above in the editor and you'll see that it wants to auto-import string from fp-ts:

CleanShot 2022-03-01 at 14 43 13@2x

If it doesn't pop up right away you might need to trigger the auto-complete by hitting ctrl-space on your keyboard.

Here's a pre-created CodeSandbox to test with: https://codesandbox.io/s/bitter-shape-3rnzh9?file=/src/index.ts

🔎 Search Terms

N/A

🕗 Version & Regression Information

Tested 4.4.5, 4.6.2

  • This is the behavior in every version I tried

🙁 Actual behavior

TypeScript auto-imports string from fp-ts.

🙂 Expected behavior

TypeScript does not auto-imports string from fp-ts.

@tjjfvi
Copy link
Contributor

tjjfvi commented Mar 1, 2022

Bug reports should follow the issue template for bug reports to help the TypeScript team triage and address the issue.

@willmanduffy
Copy link

Just to note, not only does this happen with string but it also happens with boolean and perhaps others.

@andrewbranch
Copy link
Member

I 👍 this earlier so I assume I could repro it at the time, or maybe I just repro’d it in the Code Sanbdbox which is using TypeScript 4.5, but I can’t repro on nightly:

image

string from fp-ts is there in a value position:

image

@kkirby or @willmanduffy, can you confirm that this is fixed when you use typescript@next as your VS Code TS version?

@andrewbranch andrewbranch added Needs More Info The issue still hasn't been fully clarified and removed Bug A bug in TypeScript labels Apr 21, 2022
@kkirby
Copy link
Author

kkirby commented Apr 22, 2022

@andrewbranch Still broken for me when using typescript@next:

CleanShot 2022-04-22 at 10 59 47@2x

From the ts server log file:

Info 0    [10:57:25.632] Starting TS Server
Info 1    [10:57:25.633] Version: 4.7.0-dev.20220422
Info 2    [10:57:25.633] Arguments: /Applications/Visual Studio Code.app/Contents/MacOS/Electron /Users/kkirbatski/Projects/test/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/vf/bdglby3n3r72_zfhj_b4zkw80000gn/T/vscode-typescript501/e779ed38cfeaa09de81a/tscancellation-9f6e3c1c4a583dfac398.tmp* --logVerbosity normal --logFile /Users/kkirbatski/Library/Application Support/Code/logs/20220422T105425/exthost1/vscode.typescript-language-features/tsserver-log-MdTheW/tsserver.log --globalPlugins typescript-svelte-plugin,@vsintellicode/typescript-intellicode-plugin --pluginProbeLocations /Users/kkirbatski/.vscode/extensions/svelte.svelte-vscode-105.16.0,/Users/kkirbatski/.vscode/extensions/visualstudioexptteam.vscodeintellicode-1.2.20 --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc
Info 3    [10:57:25.633] Platform: darwin NodeVersion: 16 CaseSensitive: false
Info 4    [10:57:25.633] ServerMode: undefined syntaxOnly: false hasUnknownServerMode: undefined
Info 5    [10:57:25.642] Host information vscode
Info 6    [10:57:25.643] Host watch options changed to undefined, it will be take effect for next watches.
Info 7    [10:57:25.644] Search path: /Users/kkirbatski/Projects/test/src
Info 8    [10:57:25.645] For info: /Users/kkirbatski/Projects/test/src/Interface.ts :: Config file name: /Users/kkirbatski/Projects/test/tsconfig.json
Info 9    [10:57:25.645] Creating configuration project /Users/kkirbatski/Projects/test/tsconfig.json

@andrewbranch
Copy link
Member

What the heck. @kkirby would you mind throwing that test project in a gist/repo/zip and sending it to me?

@kkirby
Copy link
Author

kkirby commented Apr 22, 2022

@andrewbranch Sure, here: https://github.com/kkirby/typescript-issue-48075

I will point out that upon opening the project, I didn't initially get the issue to occur. I had to give it awhile. Maybe the TypeScript server was still caching stuff or whatever. Let me know how it goes. There's a file in the repo called "repo_steps.mp4" that shows the problem occurring in that project.

@andrewbranch
Copy link
Member

Ah, ok—the thing I was doing to make it more likely to happen—importing from fp-ts elsewhere in the file or project—actually makes it not happen. This only occurs when you haven’t used fp-ts anywhere in your project yet 😱. Anyway, thanks for the repro, this should be easy to figure out now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Auto-import Fix Available A PR has been opened for this issue Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants