-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Instantiation expressions inconsistently trigger incorrect error messages in editor contexts #50161
Comments
What TS version is reported if you hover over TS language details in status bar? Built-in TS version in VS Code insiders is 4.7.3 which doesn't report error in this case. |
I've tested it with the built in 4.7.3, local 4.7.4, 4.7.3, 4.7.2, and 4.8-beta. I also tested it on a fresh insiders install. Literally minutes before I made the issue. |
To show what I mean by the inconsistency with this bug. Randomly, it won't complain about the error until you modify the code, in which case it'll realize that it forgot to complain. The really weird thing about it is that the typescript language server both knows its fine and reports that error. For example, you can see that the type of In addition to that, it appears that running the "Typescript: Reload Project" command fixes it until you change the code. |
Here's the TS Server log for this case (using TS 4.8.0-dev.20220801):
Notice how |
Temporary solution: function makeBox<T>(value: T){
return {value};
}
const makeStringBox = (makeBox)<string>;
const stringBox = makeStringBox('abc'); |
I was able to reproduce this on the TS compiler itself, but only within the editor. In fact, building the project sometimes fixed the issue. Restarting TS does too. export function instantiateIsNodeArray<T extends Node>() {
return isNodeArray<T>;
} |
I've had no success in making a test that reproduces it, though. I did a little debugging, and I feel like the problem is in |
I was having this problem until I ran |
The repro we had today was export function foo<U>() {
/*$*/return bar<U>;
}
export function bar<T>(x: T) {
return x;
}
let x = foo()(42);
Expected: No errors. |
As @jakebailey has mentioned, I do feel like this is not a parsing bug. If you hover over function foo<U>(): <U>(x: U) => U |
SEMANTIC HIGHLIGHTING!!!!! |
That's one thing I suspect, but I tested with it disabled and also hit it, so I think there may be more (but maybe I'm wrong). |
Okay, here's what I believe happens - you can notice in in two ways:
|
Type: Bug
VS Code version: Code - Insiders 1.70.0-insider (e9bda7aa4ff76648cfccc1a7bde465443803da71, 2022-08-02T16:56:25.649Z)
OS version: Windows_NT x64 10.0.19044
Modes:
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
A/B Experiments
I've had this issue with both no npm packages installed. With typescript installed only. And with typescript and a tsconfig.json file.
Note: It is incredibly inconsistent. Sometimes it doesn't happen. Other times changing from the built-in version of typescript to the local version fixes it, sometimes just waiting fixes it. Until you change the code at all (adding/removing whitespace for example) and then it comes back. Installing a different version of typescript removes the error until you change the code as well.
I believe that this is a VSCode centric issue and not a Typescript issue for 2 reasons.
npx tsc
builds the package just fine without any issues from type errors.The text was updated successfully, but these errors were encountered: