{"id":17979145,"url":"https://github.com/thelicato/ts2py","last_synced_at":"2025-03-25T17:31:59.607Z","repository":{"id":65337959,"uuid":"590149925","full_name":"thelicato/ts2py","owner":"thelicato","description":"Convert TypeScript Interfaces to Python TypedDict","archived":false,"fork":false,"pushed_at":"2023-01-17T21:28:39.000Z","size":307,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T06:12:53.814Z","etag":null,"topics":["interface","python","typeddict","typescript"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thelicato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-17T19:05:41.000Z","updated_at":"2024-08-28T15:18:41.000Z","dependencies_parsed_at":"2023-02-10T12:16:44.401Z","dependency_job_id":null,"html_url":"https://github.com/thelicato/ts2py","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thelicato%2Fts2py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thelicato%2Fts2py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thelicato%2Fts2py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thelicato%2Fts2py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thelicato","download_url":"https://codeload.github.com/thelicato/ts2py/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245510793,"owners_count":20627263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interface","python","typeddict","typescript"],"created_at":"2024-10-29T17:36:36.444Z","updated_at":"2025-03-25T17:31:59.363Z","avatar_url":"https://github.com/thelicato.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts2py\n\n![](https://img.shields.io/pypi/v/ts2py)\n![](https://img.shields.io/pypi/status/ts2py)\n![](https://img.shields.io/pypi/pyversions/ts2py)\n![](https://img.shields.io/pypi/l/ts2py)\n\nPython-interoperability for Typescript-Interfaces.\nTranspiles TypeScript-Interface-definitions to Python TypedDicts\n\n## What is this\nThis repo is born as a fork of [ts2python](https://github.com/jecki/ts2python) written by Eckhart Arnold \u003carnold@badw.de\u003e, Bavarian Academy of Sciences and Humanities. The reason behind this fork was that I needed a **simpler** way to quickly convert *TypeScript* interfaces to Python *TypedDict*. Once I started looking into the initial code I decided to change (and remove) a lot of stuff.\nI also managed to split the code in multiple files and added [Typer](https://typer.tiangolo.com/) to create a beautiful CLI. The initial project should be much more powerful and should also have **support for run-time type-checking of JSON-data**.\n\n## Purpose\nNowadays **a lot** of applications are created with TypeScript. To enable a much better way of developing when dealing with Python backend it could be useful to quickly convert [Typescript-Interfaces](https://www.typescriptlang.org/docs/handbook/2/objects.html) into Python [TypedDicts](https://www.python.org/dev/peps/pep-0589/). In order to enable structural validation on the Python-side, ts2py transpiles the typescript-interface definitions to Python-data structure definitions.\n\n## Installation\n\n``ts2py`` can be installed from the command line with the command:\n```\npip install ts2py\n```\n\nts2py requires the parsing-expression-grammar-framework [DHParser](https://gitlab.lrz.de/badw-it/DHParser) which will automatically be installed as a dependency by the `pip`-command. ts2py requires at least Python Version 3.10 to run. However, the Python-code it produces is backwards compatible down to Python 3.6 thanks to the [typing extensions](https://pypi.org/project/typing-extensions/).\n\n## Usage\n\nIn order to generate TypedDict-classes from Typescript-Interfaces, run `ts2py` on the Typescript-Interface definitions:\n```\nts2py interfaces.ts\n```\nThis generates a ``.py`` file in same directory as the source file that contains the TypedDict-classes and can simpy be imported in Python-Code:\n```python\nfrom interfaces import *\n```\n\n## License and Source Code\n\n``ts2py`` is open source software under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0)\n\nThe complete source-code of ts2py can be downloaded from the [its git-repository](https://github.com/thelicato/ts2py).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthelicato%2Fts2py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthelicato%2Fts2py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthelicato%2Fts2py/lists"}