fredemmott / hakana

Another typechecker for Hack, built by Slack

Home Page:https://hakana.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hakana

Hakana is a typechecker for Hack, built by Slack.

It complements the existing Hack typechecker that comes bundled with HHVM by providing additional insights beyond the scope of the official typechecker.

Hakana’s primary goal is to infer accurate types in the codebase, and to do so quickly.

Good type inference allows Hakana to do several other valuable things:

  • Security Analysis
  • Custom type-aware migrations
  • Detection of potential logic bugs
  • Discovery and removal of dead code

Non-goals

This is not intended to replace Hack's default typechecker, which supports extra features (e.g. contexts and capabilities) that aren't immediately relevant to type inference.

This tool is not designed to be run on every keypress — LSP integration is not on the roadmap.

Building from source

Clone this repo, install Rust and Cargo if you haven't already.

Run git submodule init && git submodule update to ensure HHVM is present (Hakana borrows HHVM's parser).

Then run cd third-party/hhvm && git apply ../../hhvm-patch.diff && cd ../../ to apply a few patches that enable WASM compilation.

Then run cargo build --release

That will create a binary at ./target/release/hakana-default

Running tests

You can run all tests with: cargo run --release test tests

You can run an individual test with cargo run test <path-to-test-dir>

Known issues

  • Generic parameters are not correctly inferred for new HH\Lib\Ref<_>(false) — currently Hakana infers the overly-narrow type HH\Lib\Ref<false>. As a workaround, the generic parameter type can be provided explicitly: new HH\Lib\Ref<bool>(false).

About

Another typechecker for Hack, built by Slack

https://hakana.dev

License:MIT License


Languages

Language:Rust 84.4%Language:Hack 9.8%Language:JavaScript 4.6%Language:CSS 0.7%Language:TypeScript 0.3%Language:HTML 0.3%Language:Shell 0.0%