py2tsd

Converts Python codebases into TypeScript definitions

Usage no npm install needed!

<script type="module">
  import py2tsd from 'https://cdn.skypack.dev/py2tsd';
</script>

README

py2tsd

NPM version Build Status Gitpod ready-to-code

Python to TypeScript definition generator. Intended for use with JsPyBridge.

Uses the Python astexporter lib written by fpoli to run Python AST to JSON.

Install

npm install -g py2tsd
or
npx py2tsd

Usage

py2tsd v0.0.1
        Each time you run this CLI tool, we'll append to the last exported TSD. To avoid this, you can use the --clear flag.
usage: py2tsd 
        <[--input | -i] python directory OR installed package name>
        <[--ts-out | -t] output tsd location> 
        [[--exclude | -x] optional regex to use to skip python files]
        [[--match | -m] require match of regex string]
        [--clear | -c] -- clear the workspace cache
npx py2tsd -i ./myPythonDir/ -o types.d.ts
npx py2tsd -i tensorflow -o tf.d.ts
npx py2tsd -i torch -o tf.d.ts -c