TsWorks Tools
All tools (39)

YAML to TypeScript

Generate TypeScript types for a YAML config file.

Declare as

Several documents come out as an array.

Paste YAML. Anchors, multi-line scalars and multi-document streams all work.

YAML to TypeScript

Paste a YAML config and get TypeScript interfaces for it. The point is the file your application reads at startup: once it has a type, every place downstream that touches a setting is checked against the same shape, and a renamed key becomes a compile error rather than anundefined at three in the morning.

YAML's own types are respected

Parsing uses the default YAML schema rather than the JSON subset, which is what your CI reads the file with. So on andyes are booleans, an ISO date is a date, and1.0 is a number - all of which change the generated types, and all of which are the behaviour you actually want to be typing against.

A sample is not a schema

These types describe the document you pasted. A key that only appears in your production config will not be in them, and an optional setting that happens to be present looks required. Generate from the fullest example you have, then widen by hand.

Related tools