How can I view original javscript library source code in VS Code and not the typescript version?

前端 未结 1 521
无人及你
无人及你 2020-12-03 19:26

I just started to learn Express JS and I am someone who learns the library by clicking \"Go to definition\" of IDE\'s and tracing each method/function.

But when I c

相关标签:
1条回答
  • 2020-12-03 20:12

    If your tsconfig.json has "allowJs": true and "maxNodeModuleJsDepth" set to a sufficiently large number, and you uninstall the type declarations, then clicking "Go to definition" will take you to TypeScript's best guess of the definition in the JavaScript, which may be no good for JavaScript code that was never designed to be statically analyzable (e.g., I didn't get very far with Express). For a JavaScript package that includes type declarations directly in the package instead of having a separate @types package that you can uninstall, you'll have to manually copy the JavaScript source code (and not the type declarations) into a subdirectory of your project and set up the baseUrl and paths options so that TypeScript finds it.

    This issue is for "Go to definition" to take you to the JavaScript even when the type declarations are installed.

    0 讨论(0)
提交回复
热议问题