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

Automatic imports for react function not working in js but resolved correctly in ts #30549

Closed
lynxtaa opened this issue Mar 14, 2019 · 5 comments · Fixed by #37027
Closed

Automatic imports for react function not working in js but resolved correctly in ts #30549

lynxtaa opened this issue Mar 14, 2019 · 5 comments · Fixed by #37027
Labels
Bug A bug in TypeScript
Milestone

Comments

@lynxtaa
Copy link

lynxtaa commented Mar 14, 2019

VSCode doesn't show autoimport suggestions on my machine.

I've reproduced this issue on previous stable release and on insiders version (clean install, no user settings). code --verbose and console in dev. tools shows nothing suspicious.

On launch it creates operation_log.txt in temp folder:

[11884:10884:0314/222311.384:VERBOSE1:crash_service_main.cc(81)] Session start. cmdline is [--reporter-url=https://rink.hockeyapp.net/api/2/apps/9dca90f9ee8449a2b45bb36238fb0879/crashes/upload --application-name=VSCode "--crashes-directory=C:\Users\Александр\AppData\Local\Temp\VSCode Crashes" --v=1]
[11884:10884:0314/222311.391:VERBOSE1:crash_service.cc(150)] window handle is 002C059C
[11884:10884:0314/222311.391:VERBOSE1:crash_service.cc(291)] pipe name is \\.\pipe\VSCode Crash Service
dumps at C:\Users\Александр\AppData\Local\Temp\VSCode Crashes
[11884:10884:0314/222311.391:VERBOSE1:crash_service.cc(295)] checkpoint is C:\Users\Александр\AppData\Local\Temp\VSCode Crashes\crash_checkpoint.txt
server is https://rink.hockeyapp.net/api/2/apps/9dca90f9ee8449a2b45bb36238fb0879/crashes/upload
maximum 128 reports/day
reporter is electron-crash-service
[11884:10884:0314/222311.393:VERBOSE1:crash_service_main.cc(95)] Ready to process crash requests
[11884:12436:0314/222311.393:VERBOSE1:crash_service.cc(325)] client start. pid = 11636
[11884:12436:0314/222311.481:VERBOSE1:crash_service.cc(325)] client start. pid = 14128
[628:9556:0314/222311.519:VERBOSE1:crash_service_main.cc(81)] Session start. cmdline is [--reporter-url=https://rink.hockeyapp.net/api/2/apps/9dca90f9ee8449a2b45bb36238fb0879/crashes/upload --application-name=VSCode "--crashes-directory=C:\Users\Александр\AppData\Local\Temp\VSCode Crashes" --v=1]
[628:9556:0314/222311.529:VERBOSE1:crash_service.cc(150)] window handle is 001504C2
[628:9556:0314/222311.530:VERBOSE1:crash_service.cc(291)] pipe name is \\.\pipe\VSCode Crash Service
dumps at C:\Users\Александр\AppData\Local\Temp\VSCode Crashes
[628:9556:0314/222311.530:VERBOSE1:crash_service.cc(295)] checkpoint is C:\Users\Александр\AppData\Local\Temp\VSCode Crashes\crash_checkpoint.txt
server is https://rink.hockeyapp.net/api/2/apps/9dca90f9ee8449a2b45bb36238fb0879/crashes/upload
maximum 128 reports/day
reporter is electron-crash-service
[628:9556:0314/222311.530:ERROR:crash_service.cc(302)] could not start dumper
[11884:13552:0314/222606.151:VERBOSE1:crash_service.cc(334)] client end. pid = 11636
[11884:13552:0314/222606.194:VERBOSE1:crash_service.cc(334)] client end. pid = 14128
[11884:13552:0314/222607.195:VERBOSE1:crash_service.cc(355)] zero clients. exiting
[11884:10884:0314/222607.195:VERBOSE1:crash_service.cc(527)] session ending..
[11884:10884:0314/222607.195:VERBOSE1:crash_service.cc(532)] clients connected :2
clients terminated :2
dumps serviced :0
dumps reported :0
[11884:10884:0314/222607.195:VERBOSE1:crash_service_main.cc(100)] Session end. return code is 0

And it creates a folder vscode-typescript with an empty file tscancellation-6e5026c63e8646d8cd9f.tmp3

Auto imports does work as expected on a different machine. Is there anything i can try to solve this issue?

  • VSCode Version: 1.32.2
  • OS Version: Windows 10 Pro (1809) x64

Steps to Reproduce:

  1. For example, npm install react. Create index.js. Start typing useSta. No auto import suggestions

Does this issue occur when all extensions are disabled?: Yes

@mjbvz mjbvz self-assigned this Mar 14, 2019
@hqiwen
Copy link

hqiwen commented Mar 17, 2019

same thing,VSCode doesn't show autoimport suggestions on my machine.
Version: 1.32.3 (user setup)
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17134
here is the log(window).
renderer1.log
if you have a lot of modules,the import suggestions will lead the render process crashed,then you get Loading when you type something.No suggestions any more.
Snipaste_2019-03-17_22-30-10

@mjbvz
Copy link
Contributor

mjbvz commented Mar 22, 2019

@lynxtaa Can you please try collecting the TS Server log to see if there are any exceptions or errors:

  1. Set "typescript.tsserver.log": "verbose",
  2. Restart VS Code and reproduce the problem
  3. In VS Code, run the TypeScript: Open TS Server log command
  4. This should open a folder with a tsserver.log file in it

Look through that log file for errors or stack traces. If you can share the log, I can also take a look to see if anything stands out

⚠️Warning: The TypeScript log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on Github, just let me know and we can arrange something else. On our side, we only use these logs to investigate issues like this

@lynxtaa
Copy link
Author

lynxtaa commented Mar 22, 2019

Only error I found in logs was about TSLint:

Info 18   [21:44:36.659] For info: c:/Code/test-autoimports/index.js :: No config files found.
Info 19   [21:44:36.661] Loading global plugin typescript-tslint-plugin
Info 20   [21:44:36.661] Enabling plugin typescript-tslint-plugin from candidate paths: c:/PortableApps/VSCode/resources/app/extensions/node_modules/typescript/lib/tsserver.js/../../..,C:\PortableApps\VSCode\data\extensions\ms-vscode.vscode-typescript-tslint-plugin-1.0.0
Info 21   [21:44:36.661] Loading typescript-tslint-plugin from c:/PortableApps/VSCode/resources/app/extensions/node_modules/typescript/lib/tsserver.js/../../.. (resolved to c:/PortableApps/VSCode/resources/app/extensions/node_modules/node_modules)
Info 22   [21:44:36.675] Failed to load module 'typescript-tslint-plugin': Error: Could not resolve JS module 'typescript-tslint-plugin' starting at 'c:/PortableApps/VSCode/resources/app/extensions/node_modules/node_modules'. Looked in: c:/PortableApps/VSCode/resources/app/extensions/node_modules/typescript-tslint-plugin/package.json, c:/PortableApps/VSCode/resources/app/extensions/node_modules/typescript-tslint-plugin.js, c:/PortableApps/VSCode/resources/app/extensions/node_modules/typescript-tslint-plugin.jsx, c:/PortableApps/VSCode/resources/app/extensions/node_modules/typescript-tslint-plugin/index.js, c:/PortableApps/VSCode/resources/app/extensions/node_modules/typescript-tslint-plugin/index.jsx, c:/PortableApps/VSCode/resources/app/node_modules/typescript-tslint-plugin/package.json, c:/PortableApps/VSCode/resources/app/node_modules/typescript-tslint-plugin.js, c:/PortableApps/VSCode/resources/app/node_modules/typescript-tslint-plugin.jsx, c:/PortableApps/VSCode/resources/app/node_modules/typescript-tslint-plugin/index.js, c:/PortableApps/VSCode/resources/app/node_modules/typescript-tslint-plugin/index.jsx, c:/PortableApps/VSCode/resources/node_modules/typescript-tslint-plugin/package.json, c:/PortableApps/VSCode/resources/node_modules/typescript-tslint-plugin.js, c:/PortableApps/VSCode/resources/node_modules/typescript-tslint-plugin.jsx, c:/PortableApps/VSCode/resources/node_modules/typescript-tslint-plugin/index.js, c:/PortableApps/VSCode/resources/node_modules/typescript-tslint-plugin/index.jsx, c:/PortableApps/VSCode/node_modules/typescript-tslint-plugin/package.json, c:/PortableApps/VSCode/node_modules/typescript-tslint-plugin.js, c:/PortableApps/VSCode/node_modules/typescript-tslint-plugin.jsx, c:/PortableApps/VSCode/node_modules/typescript-tslint-plugin/index.js, c:/PortableApps/VSCode/node_modules/typescript-tslint-plugin/index.jsx, c:/PortableApps/node_modules/typescript-tslint-plugin/package.json, c:/PortableApps/node_modules/typescript-tslint-plugin.js, c:/PortableApps/node_modules/typescript-tslint-plugin.jsx, c:/PortableApps/node_modules/typescript-tslint-plugin/index.js, c:/PortableApps/node_modules/typescript-tslint-plugin/index.jsx, c:/node_modules/typescript-tslint-plugin/package.json, c:/node_modules/typescript-tslint-plugin.js, c:/node_modules/typescript-tslint-plugin.jsx, c:/node_modules/typescript-tslint-plugin/index.js, c:/node_modules/typescript-tslint-plugin/index.jsx
    at Object.resolveJSModule (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:26487:19)
    at Object.sys.require (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:128707:45)
    at Function.Project.resolveModule (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:122020:35)
    at c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:122695:36
    at Object.firstDefined (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:238:26)
    at InferredProject.Project.enablePlugin (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:122694:41)
    at _loop_1 (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:122679:32)
    at InferredProject.Project.enableGlobalPlugins (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:122684:25)
    at new InferredProject (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:122783:23)
    at ProjectService.createInferredProject (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:124234:31)
    at ProjectService.getOrCreateInferredProjectForProjectRootPathIfEnabled (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:124195:33)
    at ProjectService.assignOrphanScriptInfoToInferredProject (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:123642:36)
    at ProjectService.openClientFileWithNormalizedPath (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:124729:26)
    at IOSession.Session.openClientFile (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:126454:37)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:125587:31)
    at c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:127127:88
    at IOSession.Session.executeWithRequestId (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:127118:28)
    at IOSession.Session.executeCommand (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:127127:33)
    at IOSession.Session.onMessage (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:127149:35)
    at Interface.<anonymous> (c:\PortableApps\VSCode\resources\app\extensions\node_modules\typescript\lib\tsserver.js:128410:27)
    at Interface.emit (events.js:182:13)
    at Interface._onLine (readline.js:290:10)
    at Interface._normalWrite (readline.js:433:12)
    at Socket.ondata (readline.js:149:10)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:279:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onread (net.js:636:20)

@lynxtaa
Copy link
Author

lynxtaa commented Mar 22, 2019

After some digging I've created react application using create-react-app test-autoimports and see no suggestions:

Скриншот 2019-03-22 23 41 57

But if I use create-react-app test-autoimports --typescript for typescript version, suggestions do work as expected:

Скриншот 2019-03-22 23 41 33

Maybe it'll help. Thank you

@mjbvz mjbvz transferred this issue from microsoft/vscode Mar 22, 2019
@mjbvz mjbvz changed the title Automatic imports doesn't work in JS Automatic imports for react function not working in js but resolved correctly in ts Mar 22, 2019
@mjbvz
Copy link
Contributor

mjbvz commented Mar 22, 2019

Confirmed on TypeScript-3.4-rc

Installing @types/react locally sometimes seems to help. I confirmed that automatically downloaded types do have useCallback defined however

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants