Skip to content

Work In Progress. Structural types at runtime

Notifications You must be signed in to change notification settings

kube/structype_old

Repository files navigation

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
  }
}

About

Work In Progress. Structural types at runtime

Resources

Stars

Watchers

Forks

Packages

No packages published