frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: minfern – Type inference for JavaScript without transpilation

https://github.com/sinelaw/minfern
2•_sinelaw_•4h ago
I wrote a type checker (minfern - https://github.com/sinelaw/minfern) for a subset of javascript with no transpilation. It accepts valid JS as input and allows a subset of JS code to pass the checking. There’s no transpilation or compilation needed. The input code can be run directly.

Try it online at: https://sinelaw.github.io/minfern/

It could be used for checking code targeting normal JS runtimes, or runtimes like mquickjs (though minfern is more strict but also allows things like ‘const’ which mquickjs doesn’t). minfern is based on the type system for Infernu, which I wrote back in 2015, but is less hacky and has a cleaner implementation.

Very simple example:

  function calculateTotal(product, quantity) {
    return product.price * quantity;
  }
  var item = {
    name: "Wireless Mouse",
    cost: 25 // Note the property name is 'cost', not 'price'
  };
  console.log(calculateTotal(item, 2));
Output:

  Error: Property 'price' not found in type {cost: Number, name: String}
      ╭─[ tests/example_error.js:11:13 ]
      │
   11 │ console.log(calculateTotal(item, 2));
      │             ───────────┬───────────  
      │                        ╰───────────── Property 'price' not found in type {cost: Number, name: String}
  ────╯
Type system features:

- Full type inference with principle typing, support for type annotations

- Parameteric polymorphism (aka “generic functions”)

- Structural typing with row-type polymorphism

- Object method typing with equi-recursive types (for self/“this”)

- Polymorphic object methods (still considered rank-1)

- Basic constraints “Plus a” and “Indexable a” to allow + and [] to apply to different types like numbers, strings, arrays.

This allows a subset of JS expressions to be checked.

Some JS idioms are not allowed by this system:

- No union types (design choice) - return values, variables, arrays, etc must have a single type. Currently it doesn’t support returning null/undefined either, this can be fixed in the future by adding Optional as a type, but makes principle typing harder.

- No sum types (yet) - this explains why I haven’t added Optional<T>, I think sum types will fit in the type system and are doable. Once added also enums could be expressed.

- Value restriction forbids reassigning to polymorphic variables after declaration (ML-style).

- As a result of the above - can’t use && / || operators like some people do in JS. The operators are required to have the same type on both sides (no allowing “undefined” on one side)

- No type coercion, converting a number to a string (for example) requires using String() constructor.

- And probably other limitations that people might see as a limitation rather than a feature of the type system.

Disclaimer: this type checker comes with NO WARRANTY. I am not a language expert. I didn’t prove soundness, and would love someone who’s an expert to look at it. That being said - it looks correct on all the tests I’ve tried. It’s based on HMF and other published type systems but combines things in a different way.

GitHub: https://github.com/sinelaw/minfern

Show HN: I built a replit game where you need to kill debuggers[Glitch Survival]

https://glitch-survival.replit.app
2•altras•9m ago•1 comments

Show HN: Ez FFmpeg – Video editing in plain English

http://npmjs.com/package/ezff
386•josharsh•1d ago•190 comments

Show HN: Mysti – Claude, Codex, and Gemini debate your code, then synthesize

https://github.com/DeepMyst/Mysti
204•bahaAbunojaim•5d ago•165 comments

Show HN: Future Hacker News

https://future-hacker-news.succinct.link
2•johnhenry•3h ago•0 comments

Show HN: I built an open-source wallpaper gallery for GitHub repos

https://walle.theblank.club/
4•nyxuis•3h ago•2 comments

Show HN: Word-GPT-Plus – Integrate AI and Agent Directly into Word

https://github.com/Kuingsmile/word-GPT-Plus
2•kuingsmile•4h ago•0 comments

Show HN: minfern – Type inference for JavaScript without transpilation

https://github.com/sinelaw/minfern
2•_sinelaw_•4h ago•0 comments

Show HN: Databasus – open-source backup tool for PostgreSQL, MySQL and MongoDB

https://databasus.com
7•rostislav_dugin•5h ago•2 comments

Show HN: Xcc700: Self-hosting mini C compiler for ESP32 (Xtensa) in 700 lines

https://github.com/valdanylchuk/xcc700
148•isitcontent•2d ago•36 comments

Show HN: Witr – Explain why a process is running on your Linux system

https://github.com/pranshuparmar/witr
487•pranshuparmar•2d ago•96 comments

Show HN: AutoLISP interpreter in Rust/WASM – a CAD workflow invented 33 yrs ago

https://acadlisp.de/noscript.html
134•holg•2d ago•43 comments

Show HN: Lamp Carousel – DIY kinetic sculpture powered by lamp heat (2024)

https://evan.widloski.com/posts/spinners/
99•Evidlo•3d ago•21 comments

Show HN: attainable – The fastest and easiest way to design and deploy APIs

https://attainable.dev
5•clintjhill•17h ago•2 comments

Show HN: Gaming Couch – a local multiplayer party game platform for 8 players

https://gamingcouch.com
433•ChaosOp•1w ago•120 comments

Show HN: PatchMyGear – a living map for your studio gear (cables and checklist)

https://patchmygear.com
7•sumamedi•1d ago•1 comments

Show HN: GeneGuessr – a daily biology web puzzle

https://geneguessr.brinedew.bio/
86•brinedew•5d ago•20 comments

Show HN: An immutable ostree-based Arch Linux image

https://github.com/myyc/vyy
9•mxxc•1d ago•6 comments

Show HN: Minimalist editor that lives in browser, stores everything in the URL

https://github.com/antonmedv/textarea
466•medv•3d ago•165 comments

Show HN: Jsonic – Python JSON serialization that works

https://medium.com/dev-genius/jsonic-python-serialization-that-just-works-3b38d07c426d
10•orrbenyamini•1d ago•5 comments

Show HN: Vibium – Browser automation for AI and humans, by Selenium's creator

https://github.com/VibiumDev/vibium
438•hugs•3d ago•122 comments

Show HN: I built opencode –> telegram notification plugin

https://github.com/Davasny/opencode-telegram-notification-plugin
4•davasny•18h ago•2 comments

Show HN: Jmail – Google Suite for Epstein files

https://www.jmail.world
1554•lukeigel•1w ago•360 comments

Show HN: Waycore – an open-source, offline-first modular field computer

43•DGrechko•18h ago•21 comments

Show HN: CineCLI – Browse and torrent movies directly from your terminal

https://github.com/eyeblech/cinecli
345•samsep10l•5d ago•107 comments

Show HN: I Made a Tiny Stranger Things Game While Waiting for the Finale

https://www.strangerclicks.com
2•jeanmayer•18h ago•2 comments

Show HN: Turn Your Git Commits into Tweets

https://landkit.pro/git-to-tweet
2•nikhonit•18h ago•1 comments

Show HN: HookVerify – Webhook delivery visibility for production systems

https://hookverify.com
2•phntmdz•20h ago•1 comments

Show HN: Follow independent journalists across platforms in one app

https://www.sourcedup.news/
3•smiiith•21h ago•0 comments

Show HN: The bedtime, another little bedside clock

https://www.stavros.io/posts/i-made-another-little-bedside-clock/
4•stavros•1d ago•0 comments

Show HN: InsideStack – Find curated tech articles with semantic search

https://insidestack.it
5•kivarada•21h ago•0 comments