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

[DAP] Example/Test case debugging TypeScript #1838

Open
mickaelistria opened this issue Oct 7, 2023 · 3 comments
Open

[DAP] Example/Test case debugging TypeScript #1838

mickaelistria opened this issue Oct 7, 2023 · 3 comments

Comments

@mickaelistria
Copy link

With #902 being resolved, I happily manage to use vscode-js-debug for JS files in Eclipse IDE using pwa-node. However, despite having attempted a bunch of things according to various docs or examples I've seen, I didn't manage yet to debug even the simplest typescript example:

let user:string = "Eclipse User";
console.log("Hello world,, " + user  + '!');

with a tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "lib": ["es6", "dom"],
    "allowJs": true,
    "sourceMap": true,
    "outDir": ".build/",
    "strict": true,
    "noImplicitAny": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}

and .js and .js.map files in the .build/ folder.

The issue I see is that the DAP seems to always interpret my file as a .js file and complains it cannot be parsed.

{  "jsonrpc": "2.0",
  "method": "output",
  "params": {
    "category": "stderr",
    "output": "Uncaught SyntaxError /home/mistria/git/wildwebdeveloper/org.eclipse.wildwebdeveloper.tests/testProjects/HelloWorldTS/index.ts:1\nlet user:string \u003d \"Eclipse User\";\n        ^\n\nSyntaxError: Unexpected token \u0027:\u0027\n    at internalCompileFunction (node:internal/vm:73:18)\n    at wrapSafe (node:internal/modules/cjs/loader:1178:20)\n    at Module._compile (node:internal/modules/cjs/loader:1220:27)\n    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)\n    at Module.load (node:internal/modules/cjs/loader:1119:32)\n    at Module._load (node:internal/modules/cjs/loader:960:12)\n    at executeUserEntryPoint (node:internal/modules/run_main:86:12)\n    at \u003canonymous\u003e (node:internal/main/run_main_module:23:47)\n",
    "variablesReference": 2
  }
}

and here is the launch request sent by the client to the Debug Adapter:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "launch",
  "params": {
    "outFiles": [
      "/home/mistria/git/wildwebdeveloper/org.eclipse.wildwebdeveloper.tests/testProjects/HelloWorldTS/.build/**/*.js"
    ],
    "request": "launch",
    "cwd": "/home/mistria/git/wildwebdeveloper/org.eclipse.wildwebdeveloper.tests/testProjects/HelloWorldTS",
    "noDebug": false,
    "runtimeExecutable": "/home/mistria/apps/eclipse-SDK/.node/node-v18.18.0-linux-x64/bin/node",
    "program": "/home/mistria/git/wildwebdeveloper/org.eclipse.wildwebdeveloper.tests/testProjects/HelloWorldTS/index.ts",
    "type": "pwa-node",
    "sourceMaps": true,
    "outDir": "/home/mistria/git/wildwebdeveloper/org.eclipse.wildwebdeveloper.tests/testProjects/HelloWorldTS/.build"
  }
}

I suspect there are some params I'm missing in the request, but I can't find a way to determine which one(s) are necessary for proper execution.
Does anyone have a clue? The best format would be an automated test case to show what's need for TS debugging.

@connor4312
Copy link
Member

The program should be the compiled JavaScript code, not Typescript. Things look alright otherwise.

@mickaelistria
Copy link
Author

OK, thanks. I could verify it works.
Do you think the debug adapter could take care of that resolution from .ts to .js? If not, I'll just close the issue, if yes, I will rephrase the title to make it read more like a feature request.

@connor4312
Copy link
Member

connor4312 commented Oct 9, 2023

Actually, that should work. I thought it was in a different layer that the DAP server didn't have.

private async tryGetCompiledFile(targetProgram: string) {

Not sure entirely what's going wrong without debugging it some more; I can see if I can reproduce it with a pure DAP server in next debt week. PR's also welcome if you're feeling intrepid.

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

No branches or pull requests

2 participants