When using GitHub Copilot Chat within Visual Studio Code, I've encountered an issue where TypeScript attempts to type check "temporary files" generated by Copilot. These files, identifiable by their hash-based filenames (e.g., c4507d29-b816-4a1c-9f29-c06addfc1204), are not part of my repository. Yet, TypeScript checks produce a plethora of errors, disrupting my workflow. The error messages suggest TypeScript treats these temporary outputs as part of my project, even though they're out of context and irrelevant to my actual codebase.

My questions are twofold: am I overlooking a straightforward setting or configuration related to GitHub Copilot and TypeScript, or has anyone else encountered this issue, and if so, how was it resolved?
I have tried excluding these files in my tsconfig.json, however I feel like this should not even be happening in the first place. I would expect TypeScript to ignore any generated code unless it is in one of the actual files of the project I am currently working on.
This was a bug. It's supposed to be fixed in the latest VS Code Insiders. The fix should be in 1.88.0 when that releases (you can try that in VS Code Insiders). See issue ticket Problems in chat codeblocks show as workspace problems #206644.
In the meantime, you can edit your search.exclude setting (if that doesn't work, try files.exclude) to exclude files matching the following pattern (based on the pattern given by TonyH in their answer post, but I think this will be more accurate): [a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9] (yes, it's verbose. I don't know if it works since I don't use GitHub Copilot, but if the idea works, then it's accurate and is less prone to exclude other things you might care about).
There's a related bug with chat stuff being included in references: Functions in Cached Chat files are being discovered as a reference in Visual Studio Code #1055. That issue is fixed by Pull Request Don't include internal schemes in references/implementation results #211149, which will be released in the May 2024 release of VS Code.
My fix for this is simple:
Most checkers (ShellCheck was my issue) have a way to exclude files.
The Copilot temporary or virtual files all seem to have hex names like e481a39b-6037-4f11-8dd4-9d813bf1de08
Excluding this glob: [a-f0-9]* will unmatch, and all the errors will be gone!
That said, personally this failed to fix my issue with Pylance, but did work with the ShellCheck extension. Perhaps they are peculiarities with the glob library each uses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With