{"id":30325873,"url":"https://github.com/win7user10/laraue.codetranslation.typescript","last_synced_at":"2025-08-17T23:08:35.187Z","repository":{"id":53008395,"uuid":"332437817","full_name":"win7user10/Laraue.CodeTranslation.TypeScript","owner":"win7user10","description":"Library to generate Typescript contracts code from some C# DTO classes using reflection.","archived":false,"fork":false,"pushed_at":"2021-07-26T15:25:16.000Z","size":184,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-17T06:42:56.259Z","etag":null,"topics":["code-generator","typescript-contracts"],"latest_commit_sha":null,"homepage":"","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/win7user10.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":"2021-01-24T11:58:58.000Z","updated_at":"2021-07-26T15:25:20.000Z","dependencies_parsed_at":"2022-08-22T16:10:37.539Z","dependency_job_id":null,"html_url":"https://github.com/win7user10/Laraue.CodeTranslation.TypeScript","commit_stats":null,"previous_names":["win7user10/laraue.typescriptcontractsgenerator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/win7user10/Laraue.CodeTranslation.TypeScript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/win7user10%2FLaraue.CodeTranslation.TypeScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/win7user10%2FLaraue.CodeTranslation.TypeScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/win7user10%2FLaraue.CodeTranslation.TypeScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/win7user10%2FLaraue.CodeTranslation.TypeScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/win7user10","download_url":"https://codeload.github.com/win7user10/Laraue.CodeTranslation.TypeScript/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/win7user10%2FLaraue.CodeTranslation.TypeScript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270918404,"owners_count":24667679,"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-08-17T02:00:09.016Z","response_time":129,"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":["code-generator","typescript-contracts"],"created_at":"2025-08-17T23:08:34.224Z","updated_at":"2025-08-17T23:08:35.168Z","avatar_url":"https://github.com/win7user10.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Typescript code generator for DTO classes\n--------------------\n\n[![latest version](https://img.shields.io/nuget/v/Laraue.CodeTranslation.Typescript)](https://www.nuget.org/packages/Laraue.CodeTranslation.Typescript)\n\nThe problem: Frontend and backend have some contracts for communication, describing, what types exist in a system. Manually creating these contracts is slow and dangerous, because maybe occurred situation, when BE and FE contracts are not the same.\n\nThis library generates Typescript contracts from passed C# types using reflection. Each type is translating using specified logic.\n\nLibrary is setup as default to process most common types such as below:\n```cs\nSystem.String -\u003e string?\nSystem.Guid -\u003e string\nSystem.Int32 -\u003e number\nSystem.Int32? -\u003e number?\nIEnumerable\u003cSystem.String\u003e -\u003e string[]?\n```\n\nAnd also has options to extend default mapping.\n\n### Get started\n\nAs first necessary to create a collection of types should be translated.\n\n```cs\nvar types = new TypeCollection();\n```\n\nThe library contains some extensions in Laraue.CodeTranslation.Extensions namespace to fast creating this collection.\nFor example, code below will load all referenced assemblies which name contains \"Laraue.Contracts.\" and add to the collection all types\ncontains attribute \"DataContract\".\n\n```cs\nvar types.AddTypesFromAllReferencedAssemblies(x =\u003e x.Contains(\"Laraue.Contracts.\"), x =\u003e x.HasAttribute\u003cDataContractAttribute\u003e())\n```\n\nThen should be created instance of CodeTranslator, class which will translate code from C# to Typescript.\nIt consumes translator options that can control output code view.\n\n```cs\nvar codeTranslator = TypeScriptTranslatorBuilder.Create(new TypeScriptCodeTranslatorOptions());\nvar typesCode = codeTranslator.GenerateTypesCode(types);\n```\n\nCodeTranslator returns a sequence of files with generated code and path, where each of file should be situated.\nIt can be easily stored someplace on the disk using the special extension or used as you wish.\n\n```cs\ntypesCode.StoreTo(\"D:/tsTypes\", true);\n```\n\n### Code translator options\n\nOptions contains some properties to control code will be generated.\n\nExample of adding additional mapping: System.Net.HttpStatusCode -\u003e number:\n\n```cs\nvar options = new TypeScriptCodeTranslatorOptions()\n{\n    ConfigureTypeMap = (mapCollection) =\u003e mapCollection.AddMap\u003cHttpStatusCode, Number\u003e()\n}\n```\n\nExample of camel case type naming strategy for result code:\n\n```cs\nvar options = new TypeScriptCodeTranslatorOptions()\n{\n    TypeNamingStrategy = new CamelCaseNamingStrategy()    \n}\n```\n\nExample of custom indent size for generated code:\n\n```cs\nvar options = new TypeScriptCodeTranslatorOptions()\n{\n    IndentSize = 4    \n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwin7user10%2Flaraue.codetranslation.typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwin7user10%2Flaraue.codetranslation.typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwin7user10%2Flaraue.codetranslation.typescript/lists"}