Search code examples
typescriptvisual-studio-codetscvscode-tasks

Error: The typescript task detection didn't contribute a task for the following configuration


I try to put a path in tasks.json for typescript type task:

{
    "version": "2.0.0",
    "tasks": [
        {   
            "identifier": "tsc-client", 
            "label": "tsc-client", 
            "type": "typescript",
            "tsconfig": "src/client/tsconfig.json",
            "problemMatcher": [
                "$tsc"
            ]
        },
        {   
            "identifier": "tsc-server", 
            "label": "tsc-server", 
            "type": "typescript",
            "tsconfig": "src/server/tsconfig.json",
            "problemMatcher": [
                "$tsc"
            ]
        },
        {
            "identifier": "build-all",
            "label": "build-all",
            "dependsOn": ["tsc-client", "tsc-server"]
        }
    ]
}

then in my launch.json I have:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "preLaunchTask": "tsc-client",
            "name": "Launch Program",
            "program": "${workspaceFolder}/server/server-repsic.js"
        }
    ]
}

I lounch it and I obtain:

Error: The typescript task detection didn't contribute a task for the following configuration:
{
    "identifier": "tsc-server",
    "label": "tsc-server",
    "type": "typescript",
    "tsconfig": "src/server/tsconfig.json",
    "problemMatcher": [
        "$tsc"
    ]
}
The task will be ignored.

I check that in the root path I have the src/server/tsconfig.json and src/client/tsconfig.json. Also I type it in the console:

tsc -p src/client/tsconfig.json

and the command works fine.


Solution

  • In my case the problem was caused by the fact that VSCode did not read tasks.json on the fly. I.e. I have to restart VSCode when I change tasks.json. After the restart everything works fine. Here is a similar discussion, they say:

    There was a problem that the tasks.json didn't get reparsed after a change if not task has been started before. This is fixed for the next releases. However looks like that people get this even without editing the tasks.json.

    The comment was added back in 2017, but it looks like the problem with restart is not fixed yet (I have VSCode 1.32.1).