microsoft / TypeScript-Sublime-Plugin

IO wrapper around TypeScript language services, allowing for easy consumption by editor plugins
Apache License 2.0
1.72k stars 235 forks source link

Incorrectly detecting additional characters #781

Open IPWright83 opened 3 years ago

IPWright83 commented 3 years ago

I'm encountering an issue whereby the TypeScript validation is detecting additional characters that don't exist in the file. I've encountered this a few times within a couple of different files:

Cannot find name 'Stringg'. Did you mean 'String'?

image

If I attempt to re-save the file this doesn't update as there haven't actually been any changes. If I load in a different editor and save then Sublime re-loads the file and correct the incorrect error. Additionally if I make a superfluous change and re-save the error goes away. But it's very annoying :(

Running Sublime Text 4 - Build 4121
on Ubuntu 20.04.1
DanielRosenwasser commented 2 years ago

I could imagine that this is caused by some character that creates a mismatch between what the server is seeing and what the language server is seeing. Possibly a paragraph separator (\u2029)? Can you check if you have any unusual characters outside of the extended ASCII range? A regex search for [^\u0000-\u00fff] should do it.

IPWright83 commented 2 years ago

@DanielRosenwasser oddly SublimeText doesn't appear to respect the ^ in that regex as it's matching spaces, brackets etc.

I checked it in VSCode and there are few characters outside the standard range across a number of files, but not in the particular file(s) I've been working in.

bs85 commented 2 years ago

I've had issues like this, it seems the deltas generated whenever the file is modified are not always reliable, resulting in the ts compiler seeing incorrect content for the file. My work-around is to cut-paste the problematic section (or the whole file).

IPWright83 commented 2 years ago

@bs85 that does fix the issue, thanks. I am seeing this a lot though unfortunately :(

IPWright83 commented 2 years ago

Hey @DanielRosenwasser, I'm just wondering if there's any additional info I can help to diagnose this one. I appreciate I seem to be the only one encountering it at the moment but it's an incredibly annoying issue that's happening > 10x a day. So if there's anything I can to to help try and get this fixed!

Cobertos commented 2 years ago

I have the same issue, normally I just press add a character at the end of a line and delete it fast. Sometimes it takes a few tries, but it usually gets the right thing send to the typescript compiler

IPWright83 commented 2 years ago

@Cobertos it's maybe exasperated by the fact that the TypeScript linting is taking 25s to lint a single file. So this slight annoyance introduced almost a 60s delay into my workflow 😢