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.

Don't use the TypeScript `any` type for return types

See original GitHub issue

Functions in the JS API use the TypeScript any type for return types. Please instead use real types so we can use these APIs with type safety.

For example:

https://github.com/BitGo/BitGoJS/blob/7862547b3e40f6836d25c77fdb1a0ffbebbfc9c7/modules/sdk-core/src/bitgo/wallet/wallet.ts#L469

Screen Shot 2022-06-18 at 5 32 08 pm Screen Shot 2022-06-18 at 5 48 02 pm

In the mean time, it’s not clear the right way to manually type this.

Feature Description

Don’t use the TypeScript any type for return types; instead use detailed types that describe the possible variations of the real data that could be returned.

Motivation

So we can use the BitGo JS SDK with type safety.

Context

N/A

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
byhowcommented, Aug 31, 2022

Hi @jaydenseric, refactoring this particular function, would require us to also refactor all the modules for our SDK. We created an internal ticket to track this, and we’ll assess and scope the effort soon. In the meantime, we’ll keep this issue open. Thank you!

0reactions
jaydensericcommented, Aug 19, 2022

Not stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Do's and Don'ts - TypeScript
Don't ever use the types Number , String , Boolean , Symbol , or Object These ... Don't use the return type any...
Read more >
TypeScript: Stop Using 'any', There's a Type For That
Chances are you've worked with the `any` type in TypeScript. It's widely overused, and subtly dangerous. Let's explore why you should avoid ...
Read more >
Why you should not use the type any in TypeScript
In JavaScript, you reassign any type to any variable, or even access attributes that do not exist. Not with TypeScript since TypeScript checks ......
Read more >
How to type to prevent a return value in Typescript
Typescript can help you restrict what type you can return. The specific things you can return are: void: nothing (no return statement) ...
Read more >
typescript-eslint/explicit-function-return-type.md at main - GitHub
Functions in TypeScript often don't need to be given an explicit return type ... types do make it visually more clear what type...
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