Search code examples
typescriptvisual-studio-codevscode-extensions

VS code extension "HelloWorld" sample in typescript is not working


I'm trying to create VS code extension and followed the steps provided in documentation here

I setup "helloworld" project in typescript but when i press "F5", nothing happening. I saw, typescript files complied to JS but project is not opening new instance of VS code and enable debug mode not enabled on "F5".

Any suggestions ?.

launch.json file

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Extension",
        "type": "extensionHost",
        "request": "launch",
        "runtimeExecutable": "${execPath}",
        "args": [
            "--extensionDevelopmentPath=${workspaceFolder}"
        ],
        "outFiles": [
            "${workspaceFolder}/out/**/*.js"
        ],
        "preLaunchTask": "npm: watch"
    },
    {
        "name": "Extension Tests",
        "type": "extensionHost",
        "request": "launch",
        "runtimeExecutable": "${execPath}",
        "args": [
            "--extensionDevelopmentPath=${workspaceFolder}",
            "--extensionTestsPath=${workspaceFolder}/out/test"
        ],
        "outFiles": [
            "${workspaceFolder}/out/test/**/*.js"
        ],
        "preLaunchTask": "npm: watch"
    },

]

}

Steps i followed is same as mentioned in VS code doc

  1. npm install -g yo generator-code
  2. yo code
  3. Launch VS Code,
  4. choose File > Open Folder and pick the folder that you generated.
  5. Press F5 or click on the Debug icon and click Start.

    For me step #5 is not working and not doing anything


Solution

  • Your launch file doesn't look like the one generated by yo 2.0.2. That one generates a launch file version 0.1.0 rather than 0.2.0 like yours.

    Currently you should have yo 2.0.2 and vscode 1.24.0. Please verify.

    I created a typescript extension for vscode from the ground up and get this:

    {
      "version": "0.1.0",
      "configurations": [
        {
            "name": "Launch Extension",
            "type": "extensionHost",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
            "stopOnEntry": false,
            "sourceMaps": true,
            "outDir": "${workspaceRoot}/out/src",
            "preLaunchTask": "npm"
        },
        {
            "name": "Launch Tests",
            "type": "extensionHost",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
            "stopOnEntry": false,
            "sourceMaps": true,
            "outDir": "${workspaceRoot}/out/test",
            "preLaunchTask": "npm"
        }
      ]
    }