
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
A workaround to get the return type of a function in TypeScript.
npm install returnof
At the moment TypeScript does not allow to get the return type of a function.
const hello = () => ({ hello: 'World' })
type helloReturnType = typeof hello() // ERROR
returnof
allows you to get it, at the cost of (a little) more verbosity.
import returnof from 'returnof'
const hello = () => ({ hello: 'World' })
const helloReturnValue = returnof(hello)
type helloReturnType = typeof helloReturnValue // { hello: string }
At runtime, helloReturnValue
will be null
.
If your function is overloaded and there is an ambiguity on which one you're trying to get the return type, you can pass additional arguments:
declare function hello(): void;
declare function hello(a: number): number;
const helloReturnValue = returnof(hello)
type helloReturnType = typeof helloReturnValue // void
const helloReturnValue = returnof(hello, 42)
type helloReturnType = typeof helloReturnValue // number
If there's no ambiguity, you do not need to pass additional arguments:
declare function hello(a: number): number;
const helloReturnValue = returnof(hello)
type helloReturnType = typeof helloReturnValue // number
FAQs
TypeScript typeof function return helper
The npm package returnof receives a total of 23 weekly downloads. As such, returnof popularity was classified as not popular.
We found that returnof demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.