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:
{
"version": "2.0.0",
"command": "tsc",
"isShellCommand": true,
"args": [
"-w",
"-p",
"."
],
"showOutput": "silent",
"isBackground": true,
"problemMatcher": {
"base": "$tsc-watch",
// "owner": "typescript",
// "applyTo": "allDocuments"
}
}
What I have tried:
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
@mjbvz the reason for this is that the errors from the TS language server and the tsc -w task have the same owner (which they need, otherwise you see errors twice). Now when the file closes the TS extensions removes the errors from the file. I somehow remember that I had special code in that I fetched errors from files that have been through an open / close cycle until the file disappears.
The same problem happens for example without the tsc watch task. Have two ts files open where one depends on the other, have an error and close the one with the error. Observer the error list is empty.
At the end the TS language server should have a project wide compile.
For the tsc -w case I can look into restoring errors when files are closing.
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.
@mjbvz in the past the typescript extension did keep all files that were open and reported errors in a list and rechecked them even if they were closed. This feature seems to got removed. Any reason for this?
Our team moved from Flow to TypeScript recently and this is one thing they keep bringing up as a downside... @mjbvz any comments on this?
this looks like a regression to me, it didn't use to be like that
You can always run the tsc: watchtaks contributed by the TypeScript extension. This will compile the whole project and watch for file changes.
Yes but after you close a file, the errors disappear from the file browser bar and the IDE's problems summary
Agree. (see my command https://github.com/Microsoft/vscode/issues/47386#issuecomment-380002223)
I鈥檓 checking in a change to keep the diagnostics around on close, but the problem de-duplication seems incorrect here. Here are the states:
Open workspace with no open files and start watch task
index.ts from problem matcherNow open index.ts in vscode
Close index.ts
This is not fully correct:
Now open index.ts in vscode
Close index.ts
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.
That makes sense for how the feature is implemented, but as an extension author I expected that VS Code would maintain both errors behind the scenes and then presents the de-duplicated error list to users. Is that possible? Would it break existing scenarios?
No, the problem with this is that de-duping would only work if both error sets are computed on the same state. However usually the compiler works on the save state on disk whereas the typescript server works on the in buffer state. Consider the case where there is one error from the compiler and then the user opens the file and adds two new lines at the top. Will be very hard to de-dupe these reliable. So the model for TS is more:
The problem is to make transitions without flickering and showing errors twice. Am not sure if we can handle this generically in the core or whether we best involve the extension into this since that one might have more knowledge.
Thanks for the explanation. I'm closing this issue since we have a workaround on the ts side then
@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 馃槃
Reopened with 553e6e4f797448a05cf01e74bbd0ad4f4cce5456 which reverts this fix in favor of fixing #58088 and #59363
Could anyone explain me please: why the job in VSCode is done twice?
Why TS language server and tsc do the same work -- they both parse code to show errors? And VSCode has to deduplicate messages somehow...
Is it not better to have just one service?
And moreover, why VSCode has its own syntax coloring engine based on Regex while TS language service already do parsing and AST building and has all the information about coloring? Why this information is not reused?
Once the TS language server has provided problems, perhaps the matched problems could be temporarily suppressed, but not deduped (lost)?
Seems this is still a problem nowadays.
Right now,
tsc --watch is reporting errors and on first run they appear in Problems pane.tsc --watch, those errors never come back although they are re-outputted to stdout again.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).
Most helpful comment
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.