On the bottom of the page where the error count appears, when I click on the error count, it shows me the list of errors.
When I click on them, it used to take me to the error but instead, now it's asking me to create a new file. The new file name has [0] and the original file in error.
Am I doing something wrong or this is actually a bug?
This indicates that the file extracted from the error does not exist. Are you using a particular problem matcher from in a task.json?
Can you provide steps for how to reproduce this in a simple setup?
This is a copy of my task json:
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
// A task runner that calls the Typescript compiler (tsc) and
// Compiles a HelloWorld.ts program
{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "npm",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// args is the HelloWorld program to compile.
"args": ["start"],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
// A task runner that calls the Typescript compiler (tsc) and
// compiles based on a tsconfig.json file that is present in
// the root of the folder open in VSCode
/*
{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "tsc",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Tell the tsc compiler to use the tsconfig.json from the open folder.
"args": ["-p", "."],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
*/
// A task runner configuration for gulp. Gulp provides a less task
// which compiles less to css.
/*
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"tasks": [
{
"taskName": "less",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the standard less compilation problem matcher.
"problemMatcher": "$lessCompile"
}
]
}
*/
// Uncomment the following section to use jake to build a workspace
// cloned from https://github.com/Microsoft/TypeScript.git
/*
{
"version": "0.1.0",
// Task runner is jake
"command": "jake",
// Need to be executed in shell / cmd
"isShellCommand": true,
"showOutput": "silent",
"tasks": [
{
// TS build command is local.
"taskName": "local",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the redefined Typescript output problem matcher.
"problemMatcher": [
"$tsc"
]
}
]
}
*/
// Uncomment the section below to use msbuild and generate problems
// for csc, cpp, tsc and vb. The configuration assumes that msbuild
// is available on the path and a solution file exists in the
// workspace folder root.
/*
{
"version": "0.1.0",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true"
],
"taskSelector": "/t:",
"showOutput": "silent",
"tasks": [
{
"taskName": "build",
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the standard MS compiler pattern to detect errors, warnings
// and infos in the output.
"problemMatcher": "$msCompile"
}
]
}
*/
// Uncomment the following section to use msbuild which compiles Typescript
// and less files.
/*
{
"version": "0.1.0",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true"
],
"taskSelector": "/t:",
"showOutput": "silent",
"tasks": [
{
"taskName": "build",
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the standard MS compiler pattern to detect errors, warnings
// and infos in the output.
"problemMatcher": [
"$msCompile",
"$lessCompile"
]
}
]
}
_/
// A task runner example that defines a problemMatcher inline instead of using
// a predefined one.
/_
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["HelloWorld.ts"],
"showOutput": "silent",
"problemMatcher": {
// The problem is owned by the typescript language service. Ensure that the problems
// are merged with problems produced by Visual Studio's language service.
"owner": "typescript",
// The file name for reported problems is relative to the current working directory.
"fileLocation": ["relative", "${cwd}"],
// The actual pattern to match problems in the output.
"pattern": {
// The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'.
"regexp": "^([^\s]._)((\d+|\d+,\d+|\d+,\d+,\d+,\d+)):\s+(error|warning|info)\s+(TS\d+)\s_:\s_(._)$",
// The match group that denotes the file containing the problem.
"file": 1,
// The match group that denotes the problem location.
"location": 2,
// The match group that denotes the problem's severity. Can be omitted.
"severity": 3,
// The match group that denotes the problem code. Can be omitted.
"code": 4,
// The match group that denotes the problem's message.
"message": 5
}
}
}
*/
and here is the tsconfig:
{
"compilerOptions": {
"rootDir": "app",
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/browser/",
"typings/browser.d.ts"
]
}
These errors do exist but the file names do not have [0] in the beginning.
here is a screenshot:

@geelus would it be possible to share the project that shows the problem. I tried to reproduce but wasn't able to do so.
Sorry I don't have it anymore. To give you a clue, I was using typescript to generate the .js files. I now change it to do compile on the fly.
I guess the .js files was at fault but I was hiding them using the configuration in typescript and only worked on the ts files. This could be why VS Code could not show me the error.
I hope you can find it.
On Windows, at least, the attached minimal project reproduces this issue. Ctrl+Shift+B runs the tsc task. Ctrl+Shift+U shows the task output. Ctrl+Click to navigate to the error location does not work on any of the three errors...
main.ts(1,1): error TS2304: Cannot find name 'does'.
main.ts(1,6): error TS2304: Cannot find name 'not'.
main.ts(1,10): error TS2304: Cannot find name 'compute'.
The project's build task is the default Typescript - tsconfig task that uses the $tsc problemMatcher.
VSCode version 1.6.1
@rminster the output currently doesn't do any link detection. So there is no support to click there. However all the errors should show up in the problems view from where you can navigate them.
Oh, I see. Thanks for clarifying.
can you please add support for clicking matched errors in the output window?
sometimes it's useful to see the errors along with other output that the build tools generates, and the error list doesn't support this. without the ability to click errors in the output window (like in VS proper) you need to switch between the two views in order to see all the info.
I am picking up this issue with some more information.
Running vscode 1.10.1 and typescript 2.2.1
I have a root that contains multiple subprojects, each with their own package.json. I have set up a task to compile one of the subprojects like:
{
"taskName": "build",
"isBuildCommand": true,
"command": "tsc",
"isShellCommand": true,
"options": {
"cwd": "${workspaceRoot}/subproject1"
},
"problemMatcher": "$tsc",
"showOutput": "always"
}
I get a list of errors from the problem matcher, but all of the links are relative to the ${workspaceRoot}instead of ${workspaceRoot}/subproject1
Typescript did a change where they stopped reporting absolute paths to files, instead showing the more "human friendly" relative locations. See https://github.com/Microsoft/TypeScript/issues/7238
The same error is present when calling gulp tasks in the subprojects also. Any problem reported should take the cwd option into account when outputting the path i guess?
@maskmaster there is a setting in the tsconfig.json to control the root of a compiled source tree.
You can alternatively start the build in the workspace root and point tsc to the right tsconfig.json using the -p option.
Agreed. There is a workaround for this instance.
Maybe I picked a bad example. I originally encountered the issue when doing a gulp ts-compile where gulp is executing from the subproject directory (task options cwd = workspaceRoot/subproject1)
Since gulp has no way of knowing where the ${workspaceRoot} is located, all output is done relative to the subproject1 directory.
I would still argue that a problem reporter should take the cwd option into account when creating the absolute links for the error navigation.
This is possible today. You can do the following:
"problemMatcher": {
"base": "$tsc",
"fileLocation": ["relative", "${workspaceRoot}/subproject1"]
}
Doing this by default it too big of a breakage for existing tasks.json files.
Super! This was great information.
For reference the code in question is in the repos in folder src/vs/platform/markers/common/problemMatcher.ts
I realize that this limitation also is stated in the documentation for tasks.
TypeScript: $tsc assumes that file names in the output are relative to the opened folder.
A second realization is that my issue maybe was not the perfect match for this original issue. It sounds more like the regex matching was not matching the typescript output.
For my part my issue was resolved. Thank you @dbaeumer.
Closing due to last comment.
Most helpful comment
This is possible today. You can do the following:
Doing this by default it too big of a breakage for existing tasks.json files.