question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Instantiation expressions inconsistently trigger incorrect error messages in editor contexts

See original GitHub issue

Type: Bug

  1. Attempt to use the Instantiation Expressions in VSCode typescript language
function makeBox<T>(value: T){
  return {value};
}

const makeStringBox = makeBox<string>;
const stringBox = makeStringBox('abc');
  1. Observe Red squiggly lines that shouldn’t be there.

image

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
Item Value
CPUs Intel® Core™ i9-9900K CPU @ 3.60GHz (16 x 3600)
GPU Status 2d_canvas: enabled
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
Load (avg) undefined
Memory (System) 31.92GB (17.88GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30422396
pythontb:30258533
pythonptprofiler:30281269
vsdfh931:30280409
vshan820:30294714
pythondataviewer:30285072
vscod805:30301674
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30404738
wslgetstarted:30449409
vscscmwlcmt:30465136
cppdebug:30492333
vscaac:30438845
pylanb8912:30522163
vsclangdf:30492506
c4g48928:30535728

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.

  1. Running npx tsc builds the package just fine without any issues from type errors.
  2. As seen in this comment, the typescript playground doesn’t show any errors with this. https://github.com/microsoft/TypeScript/pull/47607#issuecomment-1191409426 TS Playground

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:5
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

7reactions
xiaoxiangmoecommented, Sep 16, 2022

Temporary solution:

function makeBox<T>(value: T){
  return {value};
}

const makeStringBox = (makeBox)<string>;
const stringBox = makeStringBox('abc');
0reactions
DanielRosenwassercommented, Dec 16, 2022

Okay, here’s what I believe happens - you can notice in in two ways:

  1. You have semantic highlighting enabled (the default in VS Code) or you have inlay hints enabled. These (sometimes) get requested before diagnostics. However, the way semantic classifier queries entities asks for its meaning as a type instead of a value. That triggers an error, and that error gets cached for the subsequent getErr request.
  2. The first thing you do after the language server has loaded or after an edit is you try to get quick info on the usage of bar. That triggers the same bad lookup behavior, which reports an error which gets reported in any following diagnostics request.
Read more comments on GitHub >

github_iconTop Results From Across the Web

IBM Informix Messages and Corrections
This RSAM error message indicates an incorrect serial number. ... 19823 Cannot use EXECUTE PROCEDURE INTO with the INSTEAD OF trigger.
Read more >
Visual C++ 2015 Update 2 Bug Fixes
Connect User Connect ID Title Aaron J Ballman 2394957 Signed vs unsigned mismatch warning false positive aemwaqas60 1970608 unexpected loop vlaues Alex Katranov 2090221 excessive warning...
Read more >
Dafny "no terms found to trigger on" error message
My logic for the loop is that while they are in the loop the index wasn't found. And the ensures is when it...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Note: Shared Tab Groups and syncing for Tab Groups, Website Settings, and Web Extensions are not enabled in this release. WebAssembly. Fixed error...
Read more >
Lightning Aura Components Developer Guide
More Readable Styling Markup with the join Expression . ... Use your favorite code editor with Salesforce CLI. We recommend using Visual ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found