git404hub

what is elm-ts-types fr?

lydell/elm-ts-types — explained in plain English

Analysis updated 2026-05-18

16JavaScriptAudience · developerComplexity · 2/5Setup · easy

tl;dr

A small library that generates TypeScript type definitions from compiled Elm JavaScript, covering flags, ports, and init functions.

vibe map

mindmap
  root((elm-ts-types))
    What it does
      Generates TS types
      Types flags and ports
      Works with elm-watch
    Tech stack
      JavaScript
      TypeScript
      Elm
    Use cases
      Type safe Elm JS interface
      Catch port mistakes
      Automated d.ts generation
    Audience
      Elm developers
      TypeScript developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

what do people make with this?

VIBE 1

Generate accurate .d.ts files for an Elm app's JavaScript interface automatically.

VIBE 2

Catch mistakes like wrong flags or unsubscribed ports at compile time in a TypeScript project embedding Elm.

VIBE 3

Wire elm-ts-types into an elm-watch build so type definitions regenerate on every build.

what's the stack?

JavaScriptTypeScriptElmNode.js

how it stacks up fr

lydell/elm-ts-typesadnpolymerase/ha-appliance-cardakaakshat246/ecoscore-browser-extension
Stars161616
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasyeasyhard
Complexity2/52/53/5
Audiencedevelopergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

how do i run it?

Difficulty · easy time til it works · 30min

in plain english

elm-ts-types is a small JavaScript library that solves a specific gap in the Elm programming language's tooling. Elm compiles to JavaScript, but once your Elm program becomes plain JavaScript, TypeScript has no way of knowing what functions it exposes, what flags it expects, or what data flows through its ports. This library fixes that by generating TypeScript type definitions directly from your compiled Elm code. You install it as an npm package and call its one function, generateTypeScript, passing it the compiled JavaScript string that the Elm compiler produced. It hands back a string of TypeScript definitions describing the app's init function, the flags it requires, and every port, including which ports send data and which ones subscribe to it, along with the exact shape of the data moving through each one. If you use the elm-watch build tool, this can run automatically as part of its build process so your type definitions stay up to date without extra effort. Once you save that output into a d.ts file, TypeScript recognizes the global Elm object in your project and understands exactly how to call into your Elm app safely, including catching mistakes like passing the wrong flags or forgetting to subscribe to a port. One detail worth knowing: subscribing to a port is typed to expect an async function rather than a plain one. This is intentional. Async functions in JavaScript never throw errors directly, they always return a promise and turn thrown errors into a rejected promise instead, which keeps an error in one port callback from silently breaking unrelated Elm commands running at the same time. Under the hood, the library works by injecting extra code into your compiled Elm output so that instead of actually starting the app, it returns information about its own structure, then evaluates that modified code to recover the true shape of your ports and flags. This keeps it automatically in sync with whatever the Elm compiler actually produces, rather than trying to parse Elm source code by hand.

prompts (copy fr)

prompt 1
Show me how to call generateTypeScript from elm-ts-types on my compiled Elm JavaScript output.
prompt 2
Help me wire elm-ts-types into my elm-watch postprocess step so .d.ts files regenerate automatically.
prompt 3
Explain why elm-ts-types types port subscriptions as async functions instead of plain functions.
prompt 4
Write the TypeScript code to subscribe to all the ports elm-ts-types generated for my Elm app.

Frequently asked questions

what is elm-ts-types fr?

A small library that generates TypeScript type definitions from compiled Elm JavaScript, covering flags, ports, and init functions.

What language is elm-ts-types written in?

Mainly JavaScript. The stack also includes JavaScript, TypeScript, Elm.

How hard is elm-ts-types to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is elm-ts-types for?

Mainly developer.

peek the repo → explain another one

This repo across BitVibe Labs

double-check against the repo, no cap.