vscode: Task: Typescript errors disappear after document closed

  • VSCode Version: 1.22.1 (newest) (typescript 2.8.1)
  • OS Version: Windows 10 64bit

I expect typescript errors from all files to show until they have been fixed.

Instead, they disappear as soon as the document is closed again (e.g. by randomly clicking on the error list, which causes documents to open & close again)

Steps to Reproduce:

  1. Use this tasks.json (check if the project path fits you first)
{
    "version": "2.0.0",
    "command": "tsc",
    "isShellCommand": true,
    "args": [
        "-w",
        "-p",
        "."
    ],
    "showOutput": "silent",
    "isBackground": true,
    "problemMatcher": {
        "base": "$tsc-watch",
        // "owner": "typescript",
        //  "applyTo": "allDocuments"
    }
}
  1. Start the task
  2. Errors will show in error list (hopefully, if there are errors at all)
  3. Randomly click between errors of different files in error list. The files will open and close automatically (if they are not pinned). When a file closes, it’s errors disappear!

What I have tried:

  • $tsc-watch matcher without any other options
  • owner property “typescript” or something artificial
  • applyTo property all possibilities
  • in settings: typescript.validate.enable === false

The “best” in my trial and error endevour I have got was that the errors just persisted, even when fixed, lol 😃

My user settings (don’t have workspace settings)

{
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
    "editor.wordWrap": "on",
    "explorer.confirmDelete": false,
    "editor.quickSuggestions": {
        "other": false,
        "comments": false,
        "strings": false
    },
    "editor.autoClosingBrackets": false,
    "explorer.confirmDragAndDrop": false,
    "editor.acceptSuggestionOnCommitCharacter": false,
    "window.zoomLevel": 0,
    "explorer.autoReveal": true,
    "editor.suggestOnTriggerCharacters": true,
    "editor.acceptSuggestionOnEnter": "on",
    "editor.parameterHints": true,
    "typescript.referencesCodeLens.enabled": false,
    // "typescript.validate.enable": false
}

Does this issue occur when all extensions are disabled?: Yes

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 23
  • Comments: 21 (12 by maintainers)

Commits related to this issue

Most upvoted comments

We recently swapped from Flow to TypeScript.

In our previous workflow with Flow, the errors would remain when we opened/closed files.

However, with Typescript, none of the errors show by default (when all files are closed). For this reason, we use VSCode’s Tasks -> Run Build Task, to run the detected tsconfig.watch. This is great because it shows all errors across the project without having to open files.

However, when we open a file then close it, the error disappears from the problems tab (same issue as described above).

We would love for there to be a configuration option to disable removing errors from problems tab until they are fixed. This would be a simple fix. An even cooler one would be for this behaviour to be automatic when using a typescript watcher.

Yes but after you close a file, the errors disappear from the file browser bar and the IDE’s problems summary

@mjbvz Could you ping us the GitHub issue which will result in this behaviour being fixed? (i.e. if it’s in the TS repo or something). Just so we can have progress updates 😄

Seems this is still a problem nowadays.

Right now,

  • tsc --watch is reporting errors and on first run they appear in Problems pane.
  • If I open and close one of the files with errors, those errors are removed from Problems pane.
  • If I edit an unrelated file, which produces new output from tsc --watch, those errors never come back although they are re-outputted to stdout again.
  • The only way to get the errors back is to look at the terminal output to figure out which files have errors and then open those files.

This is fairly time consuming.

It would be great to show all (current and non-outdated) errors for the whole project in its current state, and have an option to disable that like some other people want (they want only errors for open files).

This is not fully correct:

Now open index.ts in vscode

  • since the errors from the problem matcher and the TS server have the same owner id the errors of the problem matchers are basically replaced by the one from the TS Server

Close index.ts

  • TS server takes errors away.
  • But since the compiler in watch mode is not triggered again (no file change usually on close) no new errors are generated and the errors are lost.

I looked into re-applying the errors on document close however this is not so easy due to that fact that everything runs async. If I re-add them too early the TS server will take them away if I re-add them too late then the whole problem view flickers. So we need to have some sort of coordination here which very likely requires new API.