🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

@arthurka/ts-utils

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arthurka/ts-utils

Some convenient TS utilities.

Source
npmnpm
Version
2.10.0
Version published
Weekly downloads
9.6K
-5.52%
Maintainers
1
Weekly downloads
 
Created
Source

Usage

import { checkExactShape, ExactShape } from '@arthurka/ts-utils';

const tooFew = { first: 'Stefan' };
const exact = { first: 'Stefan', last: 'asd' };
const tooMany = { first: 'Stefan', last: 'asd', age: '37' };

const record: Record<string, string> = {};
type R = typeof record;
type Exact = typeof exact;
interface ExtendedRecord extends Exact, R {}
const extendedRecord: ExtendedRecord = {
  first: 'Stefan',
  last: 'asd',
  // asd: 'asd',
};

type Person = {
  first: string;
  last: string;
};


function savePerson<T>(person: ExactShape<T, Person>) {

}
savePerson(exact);
// @ts-expect-error
savePerson(tooFew);
// @ts-expect-error
savePerson(tooMany);
// @ts-expect-error
savePerson(record);
// @ts-expect-error
savePerson(extendedRecord);

function getPerson(): Person {
  const a = exact;
  // const a = tooFew;
  // const a = tooMany;
  // const a = record;
  // const a = extendedRecord;

  checkExactShape<Person>()(a);
  return a;
}

const person = getPerson();
console.info(person);

FAQs

Package last updated on 20 Jul 2022

Did you know?

Socket

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.

Install

Related posts