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

3

4

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.

Viticulture answered 8/4, 2018 at 22:18 Comment(2)
I think you need to use $workSpaceRootSilt
@Emilio have you finally managed to resolve the problem? Do you remember what was the fix?Stumer
S
9

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).

Stumer answered 11/3, 2019 at 17:59 Comment(1)
thanks. The same, I've just relaunch VSCode.Lucubrate
L
6

I'm probably a bit late here, but this might help someone else.

I had the exact same issue, and after some tinkering, I solved the problem by replacing forward slash / by double backward slashes \\ in the paths.

For instance, replacing

"tsconfig": "src/server/tsconfig.json",

by

"tsconfig": "src\\server\\tsconfig.json",

disclaimer: I only tested that on Windows. Considering that forward slash is the standard for every other platform, this may not work on other platforms :/.

Lissalissak answered 26/4, 2018 at 13:9 Comment(1)
Strange: after updating to VSC version 1.35 I had to change \\ to / to avoid this error (Windows).Melitta
J
0

I just had the reverse problem that @Benjamin Blois reported above, all backward double slashes in paths for typescript tasks within tasks.json had to be replaced now with a forward slash. Fine with me, that's way more readable, doesn't need escaped, etc.

Had:

{ ... "tsconfig": "src\\project-foo\\tsconfig.json" ... }

Changed to:

{ ... "tsconfig": "src/project-foo/tsconfig.json" ... }
Jacquelinjacqueline answered 24/6, 2019 at 18:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.