{"id":25873288,"url":"https://github.com/annulusgames/typescriptimporter","last_synced_at":"2025-10-13T23:38:12.664Z","repository":{"id":271986139,"uuid":"915190886","full_name":"annulusgames/TypeScriptImporter","owner":"annulusgames","description":"TypeScript Importer for Unity","archived":false,"fork":false,"pushed_at":"2025-01-11T15:06:06.000Z","size":1776,"stargazers_count":22,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-13T23:38:11.099Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/annulusgames.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-11T07:43:45.000Z","updated_at":"2025-08-08T08:40:41.000Z","dependencies_parsed_at":"2025-01-11T08:28:56.317Z","dependency_job_id":"bf0f6fc8-8c7f-4265-bbff-5c16cfc3deea","html_url":"https://github.com/annulusgames/TypeScriptImporter","commit_stats":null,"previous_names":["annulusgames/typescriptimporter","yn01dev/typescriptimporter","yn01-dev/typescriptimporter","nuskey8/typescriptimporter"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/annulusgames/TypeScriptImporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/annulusgames%2FTypeScriptImporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/annulusgames%2FTypeScriptImporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/annulusgames%2FTypeScriptImporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/annulusgames%2FTypeScriptImporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/annulusgames","download_url":"https://codeload.github.com/annulusgames/TypeScriptImporter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/annulusgames%2FTypeScriptImporter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017233,"owners_count":26086016,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-03-02T08:34:47.998Z","updated_at":"2025-10-13T23:38:12.636Z","avatar_url":"https://github.com/annulusgames.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript Importer  \nTypeScript Importer for Unity  \n\n[![Releases](https://img.shields.io/github/release/AnnulusGames/TypeScriptImporter.svg)](https://github.com/AnnulusGames/TypeScriptImporter/releases)\n[![GitHub license](https://img.shields.io/github/license/AnnulusGames/TypeScriptImporter.svg)](./LICENSE)\n\nEnglish | [日本語](./README_JA.md)\n\n![hero-image](./docs/images/hero-image.png)  \n\n## Overview  \n\nTypeScript Importer is a library for integrating TypeScript into Unity. By adding TypeScript Importer to your project, `.ts` files are automatically transpiled into JavaScript and treated as `TypeScriptAsset`.  \n\nAdditionally, it provides support for [TypeScriptToLua](https://typescripttolua.github.io/), enabling `.ts` files to be transpiled into Lua instead of JavaScript. For details, refer to the [TypeScriptImporter.Lua](#typescriptimporterlua) section.  \n\n## Setup  \n\n### Requirements  \n\n- Unity 2021.3 or later  \n\n### TypeScript  \n\nIf TypeScript is not installed, use the following command to install it:  \n\n\u003e [!WARNING]  \n\u003e TypeScript Importer requires TypeScript to be installed globally.  \n\n```plaintext  \nnpm install -g typescript  \n```  \n\n### Unity  \n\n1. Open the Package Manager from `Window \u003e Package Manager`.  \n2. Click the \"+\" button and select \"Add package from git URL\".  \n3. Enter the following URL:  \n\n```\nhttps://github.com/AnnulusGames/TypeScriptImporter.git?path=src/TypeScriptImporter/Assets/TypeScriptImporter\n```  \n\nAlternatively, open `Packages/manifest.json` and add the following entry to the `dependencies` block:  \n\n```json  \n{\n    \"dependencies\": {\n        \"com.annulusgames.typescript-importer\": \"https://github.com/AnnulusGames/TypeScriptImporter.git?path=src/TypeScriptImporter/Assets/TypeScriptImporter\"\n    }\n}\n```  \n\n## Usage  \n\nAdding a `.ts` file to the `Assets` folder will trigger automatic compilation by TypeScript Importer, converting it into a `TypeScriptAsset`.  \n\nThis asset retains both the original TypeScript source code and the transpiled JavaScript source code as a `ScriptableObject`.  \n\n\u003cimg src=\"https://github.com/AnnulusGames/TypeScriptImporter/blob/main/docs/images/img-typescript-asset.png\" width=\"500\"\u003e\n\nThe generated `TypeScriptAsset` can be passed to any JavaScript execution environment. Below is an example using [Jint](https://github.com/sebastienros/jint):  \n\n```ts  \n// example.ts\n// Place this in the Resources folder\n\ndeclare function log(message: any): void;\n\nlog(\"hello!\");\n```  \n\n```cs  \nusing System;\nusing UnityEngine;\nusing TypeScriptImporter;\nusing Jint;\n\npublic class Example : MonoBehaviour\n{\n    void Start()\n    {\n        var engine = new Engine()\n            .SetValue(\"log\", new Action\u003cobject\u003e(Debug.Log));\n        \n        var asset = Resources.Load\u003cTypeScriptAsset\u003e(\"example\");\n\n        engine.Execute(asset.JavaScriptSource);\n    }\n}\n```  \n\n## Type Definition Files  \n\nTypeScript Importer recognizes `.d.ts` files and converts them into `TypeScriptDeclarationAsset`. This can be used like a `TextAsset` and can also be referenced by other `.ts` files.  \n\n## tsconfig.json  \n\nYou can modify the `tsconfig.json` file used by TypeScript Importer from `Project Settings \u003e TypeScript Importer`.  \n\n![img](./docs/images/img-typescript-settings.png)  \n\nFor details on `tsconfig.json`, refer to the [official documentation](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).  \n\nIf no configuration is specified, TypeScript Importer generates a temporary `tsconfig.json` for use.  \n\n## TypeScriptImporter.Lua  \n\nBy using TypeScriptImporter.Lua, `.ts` files can be transpiled into Lua instead of JavaScript. TypeScriptImporter.Lua is provided as a separate package and requires additional installation.  \n\n### TypeScriptToLua  \n\nTypeScriptImporter.Lua uses [TypeScriptToLua](https://typescripttolua.github.io/) internally. If TypeScriptToLua is not installed, use the following command to install it:  \n\n\u003e [!WARNING]  \n\u003e TypeScriptImporter.Lua requires TypeScriptToLua to be installed globally.  \n\n```plaintext  \nnpm install -g typescript-to-lua  \n```  \n\n### Unity  \n\n1. Open the Package Manager from `Window \u003e Package Manager`.  \n2. Click the \"+\" button and select \"Add package from git URL\".  \n3. Enter the following URL:  \n\n```\nhttps://github.com/AnnulusGames/TypeScriptImporter.git?path=src/TypeScriptImporter/Assets/TypeScriptImporter.Lua\n```  \n\nAlternatively, open `Packages/manifest.json` and add the following entry to the `dependencies` block:  \n\n```json  \n{\n    \"dependencies\": {\n        \"com.annulusgames.typescript-importer.lua\": \"https://github.com/AnnulusGames/TypeScriptImporter.git?path=src/TypeScriptImporter/Assets/TypeScriptImporter.Lua\"\n    }\n}\n```  \n\n## TypeScriptToLuaAsset  \n\nTo transpile `.ts` files into Lua, switch the active Importer. From the Importer dropdown, select `TypeScriptImporter.Editor.TS2LuaImporter`.  \n\n\u003cimg src=\"https://github.com/AnnulusGames/TypeScriptImporter/blob/main/docs/images/img-select-importer.png\" width=\"500\"\u003e\n\nThe generated `TypeScriptToLuaAsset` can be passed to any Lua execution environment. Below is an example using [Lua-CSharp](https://github.com/AnnulusGames/Lua-CSharp):  \n\n```ts  \n// example.ts\n// Place this in the Resources folder\n\nconsole.log(\"hello!\");\n```  \n\n```cs  \nusing System;\nusing UnityEngine;\nusing TypeScriptImporter;\nusing Lua;\n\npublic class Example : MonoBehaviour\n{\n    async void Start()\n    {\n        var state = LuaState.Create();\n\n        state.Environment[\"print\"] = new LuaFunction(\"print\", (context, buffer, ct) =\u003e\n        {\n            Debug.Log(context.GetArgument(0));\n            return new(0);\n        });\n\n        var asset = Resources.Load\u003cTypeScriptToLuaAsset\u003e(\"example\");\n\n        await state.DoStringAsync(asset.LuaSource, cancellationToken: destroyCancellationToken);\n    }\n}\n```  \n\nTo adjust the behavior of TypeScriptToLua, you need to edit `tsconfig.json`. For details, refer to the [TypeScriptToLua documentation](https://typescripttolua.github.io/docs/configuration).  \n\n## License  \n\n[MIT License](LICENSE)  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fannulusgames%2Ftypescriptimporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fannulusgames%2Ftypescriptimporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fannulusgames%2Ftypescriptimporter/lists"}