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

@naturalcycles/common-type

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@naturalcycles/common-type

Common Type interface and generator

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
3
Weekly downloads
 
Created
Source

@naturalcycles/common-type

Common Type interface and generator

npm min.gz size code style: prettier

Allows to generate "Common Type" and JSON Schema from a set of Typescript files with Interfaces (also Types and Enums).

Status: experimental! Everything is subject to change!

Example

Install common-type as your devDependency:

yarn add -D @naturacycles/common-type

Define a commonType.cfg.js in the root of you project:

module.exports = {
  paths: ['src/types/*.ts'],
  outputDir: 'src/schemas',
}

Config says to scan all *.ts files in src/types, parse them, generate JSON schemas, write them into src/schemas folder.

Develop

Typescript AST debugging: https://ts-ast-viewer.com/

todo

  • parse multiple files, "cross-link" them

  • Link to schemas instead of inlining them (let ajv compile/combine them for us)

  • null type

  • union types support

  • nullable union types support

  • array of union types

  • tuple type

  • StringMap support

  • fix dataFlags bug

  • includeTypes/excludeTypes in cfg

Non-structural validation:

  • unixTimestamp type
  • isoDate type
  • email type (regex)
  • id type
  • regex validation support

Currently NOT supported

Partial, Required, Omit, Pick

Generic interfaces e.g:

interface MyType<T> {
  current: T
  future: T
}

FAQs

Package last updated on 07 Aug 2021

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