Playground
Write untyped TypeScript, call it at the end of the file, and run. ts-capture watches the calls and writes the types it saw back into the code.
Everything happens in this tab: the code runs in your browser and is sent nowhere. The calls play the part your test suite plays in a real project.
Paste a JSON value and run. ts-capture types it the way apply would type a parameter called with it.
Everything happens in this tab: the JSON is parsed in your browser and is sent nowhere. In code, typesFromValues does the same for any value.
Options 1 changed from the defaults
After ts-capture applyThe type ts-capture apply would write
- One file, no imports, and only the JavaScript standard library: no DOM and no Node.
- An annotation that would not compile is not written. The report under the result says which, and why.
- A type is only as good as the calls behind it. See what it cannot infer.
- This runs the same applier and type-check as the
ts-capture CLI. A real project also gets its test runner, several files and its own tsconfig.json.
- One value. A list of objects that differ becomes one shape, with the fields only some have optional.
- Nothing is written when part of the value is unknown: an empty list seen alone, or an object nested deeper than Depth levels.
- A type is only as good as the values behind it. See what it cannot infer.