Closed rschristian closed 2 years ago
In the example below, foo is shown to have a type of any
Can't reproduce, works as expected for me.
Well the instant-close feels a bit premature, any ideas what could lead to this? Definitely isn't working correctly for me.
Maybe you have turned off "typescript.suggest.jsdoc.generateReturns"
.
Or maybe you need wait for a while, tsserver needs some time to parse jsdoc
Hm, not sure if you just skimmed over the issue without reading or what, but I did say that there are a number of things I could do to have the type "magically" show up. Like the 4th item, swapping out String(context.params.foo)
with a static string ("foo"
).
There's no reason why that should have an effect, but for some reason it does. The type CAN resolve (and does so quickly enough, I'm using the same isolated test case provided here), but in that specific code block, it doesn't. It's really weird.
I don't think it's possible to be an issue in user code/config.
You have to wait for sometime, it's issue with tsserver. You should send report to typescript team.
The type doesn't change over time. I get any
even if I leave it for 3-4 minutes.
You should send report to typescript team.
I can't reproduce the issue outside of coc, so the issue doesn't seem to be with typescript. Works just fine in CodeSandbox, for example.
From log of your tsserver
Info 90 [06:25:06.286] response:
{"seq":0,"type":"response","command":"completionEntryDetails","request_seq":10,"success":true,"body":[{"name":"foo","kindModifiers":"","kind":"const","displayParts":[{"text":"const","kind":"keyword"},{"text":" ","kind":"space"},{"text":"foo","kind":"localName"},{"text":":","kind":"punctuation"},{"text":" ","kind":"space"},{"text":"any","kind":"keyword"}],"documentation":[],"tags":[]}]}
it's what it returned, I got same response first time and it gives me correct type after some seconds.
It happens on latest VSCode as well
Hmm, weird. I don't know if it's just my method of get syntax hints (I don't have hover hints, just when I go to use the value) but nothing ever changes, the hint is completely static.
Odd that you can reproduce in VSCode, I think I tried for a half hour to get CodeSandbox to reproduce but never once did. Fair enough then, sorry to bring it up here.
I've ran into a really odd issue in which a promise's resolved value gets replaced with
any
under a number of circumstances, but only withcoc-tsserver
. I cannot reproduce this behavior in any other editor.I tried to cut this down as much as I could, apologies if this is still a bit heavy. Removing anything else pretty much means it cannot be reproduced.
In the example below,
foo
is shown to have a type ofany
, however, doing any of the following steps corrects it:return console.log(foo);
return
, but remove theconsole.log()
return
and theconsole.log()
, but separate them (i.e., don't return the result ofconsole.log()
)String(context.params.foo)
with a static string ("foo"
)Foo()
without passsing any params at allawait
and noticefoo
's type is correctly marked asPromise<{ ... }>
Calling
Foo()
from a plain async function or top-level doesn't result in this issue. It seems limited to this library's method.TS Server Log pastebin
Project