craigtaub / our-own-type-system

Basic JavaScript type checker, in 100 lines.

Home Page:https://craigtaub.dev/under-the-hood-of-type-systems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Our own type system

A compiler which checks types for 3 scenarios:

  1. Issue with un-compatible types on declaration and expression
fn("craig-string"); // throw with string vs number
function fn(a: number) {}
  1. Issue with unknown type on declaration and expression
fn("craig-string"); // throw with string vs ?
function fn(a: made_up_type) {} // throw with bad type
  1. Issue with property name
interface Person {
  name: string;
}
fn({ nam: "craig" }); // throw with "nam" vs "name"
function fn(a: Person) {}

About

Basic JavaScript type checker, in 100 lines.

https://craigtaub.dev/under-the-hood-of-type-systems


Languages

Language:JavaScript 100.0%