0.0.0 • Published 7 years ago
type-analyze v0.0.0
type-analyze
Statically analyze types through comments
// foo : Number -> Number
function foo (x) {
return x + 1
}
foo('Hello')
// TypeError: foo('Hello') doesnt match Number -> Number
This module is a work in progress:
- x: Loads function type signature
- x: Checks literal types on function calls
- : Wildcards in type signature using
*
- : Infers types of expressions (in functions and identifiers)
- : Loads identifier type signature
- : Checks identifier types
- : Proper support for scopes
Installation
$ npm install --save type-analyze
Usage
analyze(source, options)
-> errors
Analyze source
with options
.
var errors = analyze(`
// foo : Number -> Number
function foo (x) { return x + 1 }
foo('Hello')
`)
console.error(errors)
// [ TypeError { ... } ]
'errors'
An array of TypeError
objects.
License
MIT © Jamen Marz
0.0.0
7 years ago