Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
TypeScript utility types for function arguments
Should use typescript 2.8
and upper
npm i tsargs
import { Arg2 } from 'tsargs';
function foo(a: number, b: string) {}
const secondArg: Arg2<typeof foo> = 'hello world!';
Use ArgN
type to pick N
argument (max 10 arg)
import { Arg2 } from 'tsargs';
function foo(a: number, b: string) {}
const secondArg: Arg2<typeof foo> = 'hello world!';
Useful for typed callbacks, rpc or event
Use PreN
ArgJ
type to prepend N
arguments to function with J
arguments (max 10 arg)
or PreN
ArgN type to prepend N
arguments to function with unknown arguments number
import { Pre1Arg2, Pre1ArgN } from 'tsargs';
function foo(a: number, b: string) {}
function boo(x: string, a: number, b: string) {}
const booFromFoo: Pre1Arg2<string, typeof foo> = boo;
const booFromFoo2: Pre1ArgN<string, typeof foo> = boo;
PreN
ArgN type may cause low ts performance
Useful for typed callbacks, rpc or event
Use PostN
ArgJ
type to append N
arguments to function with J
arguments (max 10 arg)
or PostN
ArgN type to append N
arguments to function with unknown arguments number
import { Post1Arg2, Post1ArgN } from 'tsargs';
function foo(a: number, b: string) {}
function boo(a: number, b: string, x: string) {}
const booFromFoo: Post1Arg2<string, typeof foo> = boo;
const booFromFoo2: Post1ArgN<string, typeof foo> = boo;
PostN
ArgN type may cause low ts performance
Callbacks & arguments list
Use Args10
to pick 10 args of function
Use ArgsN
offOffset
to pick N
args with Offset
offset (max 10 arg)
import { Args2off1 } from 'tsargs';
function foo(a: boolean, b: number, c: string) {}
const argsBC: Args2off1<typeof foo> = [ 123, 'Hello' ];
Write issue on github if you have any trouble with arguments in typescript
FAQs
typescript function arguments utils
We found that tsargs 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
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.