OiO.lk Blog javascript Unable to set a breakpoint in typescript VS Extension
javascript

Unable to set a breakpoint in typescript VS Extension


I’ve cloned this repo…
https://github.com/semanticart/minimum-viable-vscode-language-server-extension

this is a Minimum Viable VS Code Language Server Extension with all the baseline code to develop an VS code entension.

When I try to set a breakpoint in one of the .ts or .js source code files, it does not seem to work. Once I try to debug the code with F5, another windiow will pop-up and the extesion runs fine. Initialization method get triggered but all breakpoint are greyed and VS show an error message saying "We couldn’t find a corresponding source location, and didn’t find any source with the name NameOfFile.js.

I’ve tryed look for solutions myself, firt on google and attempted meny suggestions, also tryied ask Chat GPT any everythin suggestes as the possible route cause is ok

My proyect is lacated in this folder: C:\dev\LSP\lsp-tal>

Below is the proyect struture: bind files are created and in the same .js files, main tsconfig.json and the tsconfig inside the server folder, lastly the VS configuration for run the debug session.

I someone can provide any idea or solution it will be great

Thanks is advance

these are the all posible causes according to chat gpt:

1 – Ensure Correct outFiles Paths: Your launch.json specifies paths for
the compiled files. Given that your output files are in
C:\dev\LSP\lsp-tal\server\out, update the outFiles pattern in your
launch.json to match:

json

"outFiles": [ "${workspaceRoot}/server/out//*.js",
"${workspaceRoot}/client/out/
/*.js" ]

This ensures that any subdirectories in out are included.

2 – Check Source Maps Generation: Verify that the TypeScript compiler is
generating source maps correctly. You mentioned that the output .js
files are generated in server/out. Ensure that .js.map files are
generated alongside them. If not, the debugger won’t be able to map
the TypeScript sources.

3 – Adjust sourceMap Settings in tsconfig.json: Ensure that the sourceMap
option in tsconfig.json is set to true (which it is, but just
double-check).

4 – Check File Paths in the Source Maps: Sometimes, the paths in the
generated source maps can be incorrect. Open one of the .js.map files
and verify that the sources entry points to the correct location
(e.g., ../src/parser.ts or similar). If it’s incorrect, you might need
to adjust your tsconfig.json settings like rootDir or outDir.

5 – Clean the Output Directory: Before recompiling, try deleting the out
directory to ensure no stale files are affecting the build:

bash

rm -rf server/out

6 – Verify preLaunchTask: Ensure that the npm script watch is correctly
set up in your package.json to build and watch changes. It should
ensure that files are being recompiled before starting the debugging
session.



You need to sign in to view this answers

Exit mobile version