#TYPESCRIPT ERROR IN VSC

20 messages · Page 1 of 1 (latest)

rose drift
#

Hi as you can see here this code works perfect. But in VSC it turns me an error when I am calling the 63 line as in vsc it says that I have to pass to all the args params a SubscriptionMessage and not in the first param a SubscriptionMessage and in the second a Subscription. In the playground all is correct but in vsc shows me an error. I am running the last version of typescript.

#

It's something weird as I said because in the playground works correctly. An additional information is that if I remove the generic type of EventSubEvents in the emit function of the class it works correctly

#

I need this code to works to continue with the development of this project.

rose drift
#

!helper

mint lintel
#

what about with running tsc from the command line?

#

copying your code to the playground may introduce some inaccuracies by differing configs

rose drift
mint lintel
#

it's not an issue with vsc then, your code is just seemingly incorrect

#

i tried modifying your playground to align with the code shown in the screenshot, but it's yielding a different error.

fast flax
#

General points with VSC issues - try compiling it from the command line to see if you get the same error

#

If you don't get the same error from the command line, check that VSCode is using the same version of TS as you are on the command line.

#

(Also "Restart TS Server" is a good thing to try just in case)

rose drift
#

I made those steps before but anything has changed

#

I named this forum as VSC error as it in the playground it wasn't any error shown.

mint lintel
#

well if it's reproducable with the command line tool then it's not related to vscode
it's more of a discrepancy between your local setup and the playground

rose drift
fast flax
#

Right so if it happens on the command line it's not a VSC issue.

#

If it's not happening in the playground that means either there's a TS version difference between the playground version, there's a typings versoin difference (in this case could only be @types/node since that's the only dependency), or there's a config difference between your config and the playground's config.

rose drift
#

its something weird becasue as you can see I have those functions well typed and implemented in the EventEmitter but when I emit the args params in the emit function are typed as SubscriptionMessage and not as SubscriptionMessage and then Subscription<K, T>

#

but all is ok if in the emit function at the args parameter I remove the generic type to EventSubEvents