Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typescript-treasure

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-treasure

Elegant and pragmatic collection of typescript tools

  • 0.0.9
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

typescript-treasure

Elegant and pragmatic collection of typescript tools

Installation

npm install typescript-treasure -S

Document

中文文档

ts type code specification

I call this code specification:MuGuaTS(Chinese interpretation:木瓜TS

All judgment tools are named using If_Xxx For example, If_Num<T> is a generic tool used to determine if it is a number.

Short generic tools can be written on one line

type SomeTool<T> =  T extends any ? true : false;

More complex generic tools need to wrap lines after the equal sign and follow the following wording

type ComplexTool<T1, T2> =
    If_NumStr<T1> extends true ?
    (
        If_Includes<T2, 2> extends true ?
        (
            SomeThing
        )
        :
        (
           SomeThing
        )
    )
    :
    (
        SomeThing
    )

The generic parameter part of a generic function should follow the equal sign

type SomeFn = <T1, T2>
    (arg1: T1, arg2: T2) =>
    (
        T1 extends any ?
        (
            SomeThing
        )
        :
        (
            SomeThing
        )
    )

Keywords

FAQs

Package last updated on 25 Oct 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc