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.

Typescript types not accurate

See original GitHub issue

Hi, I’m trying to use stream in a Typescript application and have found several issues with the types.

First, when creating a client (server-side) with this call:

const client = connect(apiKey, secret, appId);

The client is created as an “any” object. If I remove “stream.” from the returned object type on the connect function in the stream-js index.d.ts file (making it just “StreamClient” instead of “stream.StreamClient”), the client is correctly typed.

I’m currently working around this by explicitly declaring the type of the object, but it’s obviously preferable to just have the types working:

const client = connect(apiKey, secret, appId) as StreamClient;

Second, I’m creating a client-side connection to a particular feed with a server-generated read only token, as below:

const client = connect( apiKey, null, appId, ) as StreamClient; const readOnlyFeed = client.feed( feedGroupName, feedName, readOnlyToken, );

This is working as expected, but I’m receiving a typescript error on the feed function, which only has 2 arguments in the stream-js index.d.ts file: feedSlug and userId. An optional token argument should be added to the feed function definition.

Thanks!

gz#4555

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
shodgettscommented, Jul 21, 2020

We’re working on it 😉

1reaction
baileywallcommented, Aug 27, 2020

hi all! sorry I wasn’t able to try out the beta, I got pulled onto another feature that we just wrapped up this week. I’m coming back to this now and am THRILLED at the new release!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does TypeScript not show accurate return type?
Therefore, it is quite natural that typescript compiler, which is executed before runtime, cannot decide what the type of a is going to...
Read more >
typeRoots and types not working · Issue #37708 - GitHub
In my project root, I got package.json, package-lock.json, main.ts(empty one), tsconfig.json . tsconfig.json contains the above code.
Read more >
Documentation - Advanced Types - TypeScript
By default, the type checker considers null and undefined assignable to anything. Effectively, null and undefined are valid values of every type. That...
Read more >
Handbook - Basic Types - TypeScript
Variables also acquire the type never when narrowed by any type guards that can never be true. The never type is a subtype...
Read more >
Documentation - Narrowing - TypeScript
While it might not look like much, there's actually a lot going under the covers here. Much like how TypeScript analyzes runtime values...
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