-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent errors reported between tsc
and VSCode
#52813
Comments
Hi @frank-weindel, I have been trying to reproduce this using the instructions you left, but so far I wasn't able to. If you're still able to repro this, could you repro it with logging enabled on tsserver, and post the tsserver logs here? That would help me investigate this issue. Thank you. In case you don't already know how to do get a tsserver log: (2) Once you have logging enabled, and you manage to reproduce the issue, you can then open the log by running the "TypeScript: Open TS Server log" command on vscode: |
As requested! Specifically what I did to reproduce was:
|
I think the following program captures the essence of this issue: interface Some {}
class Foo<T=Some> {
num: number = 0;
Field: number = (this as Foo).num;
Value = (this as Foo).num; // Ok
} You don't get the circularity error reported on the above program, but you do get the error if you swap the interface Some {}
class Foo<T=Some> {
num: number = 0;
Value = (this as Foo).num; // Error
Field: number = (this as Foo).num;
} Essentially, what is happening is that, if we type check property Translating that to the original reported issue, what happens is that, when we run the checker via |
Does adding variance annotation(s) to |
Yes, computing variance for |
Here's a variant repro I was trying out function f() {
const b = new Bar();
// Uncomment to create error
// console.log(b.Value);
}
class Bar<T> {
num!: number;
// Or swap these two lines
Field: number = (this as Bar<any>).num;
Value = (this as Bar<any>).num;
} |
Bug Report
The basic problem looks like this:
tsc
directly from the command line and get Set A of errors.Set B errors seem completely wrong since the
tsc
doesn't produce them. HOWEVER, a specfically unique error in Set B seems to be causing this weird behavior:If I solve this error with an explicit type assertion, the inconsistency goes away and I resume seeing Set A errors.
My project does rely on a deep set of types involving conditionals and generics. This seems to have something to do with causing this problem. I've provided a repository below with steps on how to reproduce. I would try to narrow the behavior down to a simpler project+repo but do not have the time at the moment.
Original Discord discussion
🔎 Search Terms
inconsistency, inconsistent, errors, ts language server,
🕗 Version & Regression Information
This issue was tested and occurs in TypeScript 4.9 and the latest nightly build as of this writing (5.0.0-dev.20230216).
⏯ Playground Link
Unfortunately I'm unable to reproduce this with the TS Playground
Repo+Branch that reproduces the issue
Stepper.ts
line 77. See the TSDoc comment there for reproducibility steps. It can some times take a few file modifications to trigger the behavior.💻 Code
See Repo above.
🙁 Actual behavior
tsc
via the command line.🙂 Expected behavior
tsc
via the command line.The text was updated successfully, but these errors were encountered: