Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 894 Bytes

README.md

File metadata and controls

45 lines (34 loc) · 894 Bytes

CircleCI

Structype

Structural Type validation. Statically-typed.

Install

yarn add structype

Usage

import { Type, String, Number } from 'structype'

export const Person = Type({
  firstName: String,
  lastName: String,
  age: Number
})

export type Person = typeof Person.type

Static Type Inference

function handleInput(obj: any) {
  if (Person.test(obj)) {
    obj // x is a Person
  } else {
    obj // x is still any
  }
}