{"id":45473086,"url":"https://github.com/nickna/SharpTS","last_synced_at":"2026-03-07T15:00:52.063Z","repository":{"id":331985652,"uuid":"1126940580","full_name":"nickna/SharpTS","owner":"nickna","description":"Compile TypeScript to .NET IL; Use .NET classes in Typescript","archived":false,"fork":false,"pushed_at":"2026-02-26T19:33:40.000Z","size":8050,"stargazers_count":115,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-27T01:32:08.285Z","etag":null,"topics":["aot","csharp","dotnet","language-implementation","typescript","typescript-compiler","typescript-interpreter"],"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/nickna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-02T21:24:49.000Z","updated_at":"2026-02-26T19:33:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/nickna/SharpTS","commit_stats":null,"previous_names":["nickna/sharpts"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/nickna/SharpTS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickna%2FSharpTS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickna%2FSharpTS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickna%2FSharpTS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickna%2FSharpTS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nickna","download_url":"https://codeload.github.com/nickna/SharpTS/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickna%2FSharpTS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30118934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T09:35:22.236Z","status":"ssl_error","status_checked_at":"2026-03-05T09:35:20.028Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["aot","csharp","dotnet","language-implementation","typescript","typescript-compiler","typescript-interpreter"],"created_at":"2026-02-22T13:00:39.106Z","updated_at":"2026-03-07T15:00:52.042Z","avatar_url":"https://github.com/nickna.png","language":"C#","readme":"# SharpTS\n\nA TypeScript interpreter and ahead-of-time compiler written in C#.\n\n[![NuGet](https://img.shields.io/nuget/v/SharpTS.svg)](https://www.nuget.org/packages/SharpTS)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![.NET](https://img.shields.io/badge/.NET-10.0-purple.svg)](https://dotnet.microsoft.com/)\n\n## Overview\n\n\u003cimg width=\"2816\" height=\"1536\" alt=\"Gemini_Generated_Image_go1ahqgo1ahqgo1a\" src=\"https://github.com/user-attachments/assets/565d98dc-8268-4cd6-8b34-7cc24a0f7a4a\" /\u003e\n\nSharpTS is an implementation of a TypeScript interpreter and compiler. It implements the complete pipeline from source code to execution:\n\n1. **Lexical Analysis** - Tokenizing source code\n2. **Parsing** - Building an Abstract Syntax Tree\n3. **Type Checking** - Static type validation\n4. **Execution** - Either interpretation or compilation to .NET IL\n\nSharpTS supports two execution modes:\n\n- **Interpretation** - Tree-walking execution for rapid development\n- **AOT Compilation** - Compile TypeScript to native .NET assemblies\n\n## Features\n\n### Language Support\n\n- **Types**: `string`, `number`, `boolean`, `null`, `any`, `void`, `unknown`, `never`\n- **Generics**: Generic functions, classes, and interfaces with type constraints\n- **Advanced Types**: Union (`|`), intersection (`\u0026`), tuples, literal types\n- **Arrays**: Typed arrays with `push`, `pop`, `map`, `filter`, `reduce`, `forEach`, etc.\n- **Objects**: Object literals with structural typing\n- **Classes**: Constructors, methods, fields, inheritance, `super`, static members\n- **Abstract Classes**: Abstract classes and abstract methods\n- **Interfaces**: Structural type checking (duck typing)\n- **Functions**: First-class functions, arrow functions, closures, default parameters\n- **Async/Await**: Full `async`/`await` with `Promise\u003cT\u003e` and combinators (`all`, `race`, `any`)\n- **Modules**: ES6 `import`/`export` with default, named, and namespace imports\n- **Decorators**: Legacy and TC39 Stage 3 decorators with Reflect metadata API\n- **Control Flow**: `if/else`, `while`, `do-while`, `for`, `for...of`, `for...in`, `switch`\n- **Error Handling**: `try/catch/finally`, `throw`\n- **Operators**: `??`, `?.`, `?:`, `instanceof`, `typeof`, bitwise operators\n- **Destructuring**: Array/object destructuring with rest patterns\n- **Built-ins**: `console.log`, `Math`, `Date`, `Map`, `Set`, `RegExp`, `bigint`, `Symbol`, string methods\n\n### Compiler Features\n\n- Static type checking with helpful error messages\n- Nominal typing for classes, structural typing for interfaces\n- Compile to standalone executables or .NET assemblies\n- Reference assembly output for C# interop (`--ref-asm`)\n- IL verification (`--verify`)\n\n### .NET Interop\n\n- **Use .NET types from TypeScript** via `@DotNetType` decorator\n- Access BCL classes like `StringBuilder`, `Guid`, `DateTime`, `TimeSpan`\n- Automatic type conversion and overload resolution\n- **Compile TypeScript for C# consumption** with reflection or direct reference\n\n## Quick Start\n\n### Prerequisites\n\n- **[.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0)** or later (required)\n- **Visual Studio 2026 18.0+** or **Visual Studio Code** (optional, for IDE support)\n\n**Note for MSBuild SDK users:** SharpTS.Sdk requires .NET 10 SDK and uses modern C# features for optimal performance.\n\n### Installation\n\n**Install CLI tool from NuGet (recommended):**\n\n```bash\ndotnet tool install -g SharpTS\n```\n\n**Or use TypeScript in a .NET project:**\n\n```xml\n\u003cProject Sdk=\"SharpTS.Sdk/1.0.0\"\u003e\n  \u003cPropertyGroup\u003e\n    \u003cTargetFramework\u003enet10.0\u003c/TargetFramework\u003e\n    \u003cSharpTSEntryPoint\u003esrc/main.ts\u003c/SharpTSEntryPoint\u003e\n  \u003c/PropertyGroup\u003e\n\u003c/Project\u003e\n```\n\n### Usage\n\n**REPL Mode:**\n\n```bash\nsharpts\n```\n\n**Run a TypeScript file (interpreted):**\n\n```bash\nsharpts script.ts\n```\n\n**Compile to .NET assembly:**\n\n```bash\nsharpts --compile script.ts\ndotnet script.dll\n```\n\n**Compile to self-contained executable:**\n\n```bash\nsharpts --compile script.ts -t exe\nscript.exe\n```\n\n**Additional compiler options:**\n\n```bash\nsharpts --compile script.ts --ref-asm       # Reference assembly for C# interop\nsharpts --compile script.ts --verify        # Verify emitted IL\nsharpts --compile script.ts --preserveConstEnums  # Keep const enums\n```\n\n**Generate NuGet package:**\n\n```bash\nsharpts --compile Library.ts --pack         # Creates Library.1.0.0.nupkg\nsharpts --compile Library.ts --pack --version 2.0.0-beta  # Custom version\nsharpts --compile Library.ts --pack --push https://api.nuget.org/v3/index.json --api-key $KEY\n```\n\nPackage metadata is read from `package.json` in the source directory.\n\n**Decorator support:**\n\nDecorators are enabled by default (TC39 Stage 3).\n\n```bash\nsharpts script.ts                           # Stage 3 decorators (default)\nsharpts --experimentalDecorators script.ts  # Legacy (Stage 2) decorators\nsharpts --noDecorators script.ts            # Disable decorators\n```\n\n## Examples\n\n### Hello World\n\n```typescript\n// hello.ts\nconsole.log(\"Hello, World!\");\n```\n\n```bash\n$ sharpts hello.ts\nHello, World!\n```\n\n### Classes and Inheritance\n\n```typescript\n// animals.ts\nclass Animal {\n    name: string;\n    constructor(name: string) {\n        this.name = name;\n    }\n    speak(): string {\n        return this.name + \" makes a sound\";\n    }\n}\n\nclass Dog extends Animal {\n    speak(): string {\n        return this.name + \" barks!\";\n    }\n}\n\nlet dog = new Dog(\"Rex\");\nconsole.log(dog.speak());\n```\n\n```bash\n$ sharpts animals.ts\nRex barks!\n```\n\n### Functional Programming\n\n```typescript\n// functional.ts\nlet numbers: number[] = [1, 2, 3, 4, 5];\n\nlet doubled = numbers.map((n: number): number =\u003e n * 2);\nlet evens = numbers.filter((n: number): boolean =\u003e n % 2 == 0);\nlet sum = numbers.reduce((acc: number, n: number): number =\u003e acc + n, 0);\n\nconsole.log(doubled);  // [2, 4, 6, 8, 10]\nconsole.log(evens);    // [2, 4]\nconsole.log(sum);      // 15\n```\n\n### Compiled Execution\n\n```bash\n# Compile to .NET assembly\n$ sharpts --compile functional.ts\n\n# Run the compiled assembly\n$ dotnet functional.dll\n[2, 4, 6, 8, 10]\n[2, 4]\n15\n```\n\n### Use .NET Types from TypeScript\n\n```typescript\n// Use BCL types directly in TypeScript\n@DotNetType(\"System.Text.StringBuilder\")\ndeclare class StringBuilder {\n    constructor();\n    append(value: string): StringBuilder;\n    toString(): string;\n}\n\nlet sb = new StringBuilder();\nsb.append(\"Hello from .NET!\");\nconsole.log(sb.toString());\n```\n\n```bash\n$ sharpts --compile dotnet-example.ts\n$ dotnet dotnet-example.dll\nHello from .NET!\n```\n\n### Access TypeScript classes from .NET (C#)\n\n```C#\n// Compile your TypeScript with --ref-asm:\n\nvar person = new Person(\"Alice\", 30.0);  // Direct instantiation\nConsole.WriteLine(person.name);          // Direct property access\nstring greeting = person.greet();        // Typed return values\n```\n\n[More code examples](Examples/README.md)\n\n## Documentation\n\n- [**Using .NET Types**](docs/dotnet-types.md) - Use .NET BCL and libraries from TypeScript\n- [**.NET Integration**](docs/dotnet-integration.md) - Consume compiled TypeScript from C#\n- [**MSBuild SDK Guide**](docs/msbuild-sdk.md) - Integrate SharpTS into your .NET build process\n- [**Architecture Guide**](ARCHITECTURE.md) - Deep dive into the compiler/interpreter internals\n- [**Contributing Guide**](CONTRIBUTING.md) - How to contribute to the project\n\n## Project Status\n\nSharpTS is under active development. See [STATUS.md](STATUS.md) for current feature support and roadmap.\n\n## Contributing\n\nContributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on:\n\n- Code style guidelines\n- How to add new language features\n- Submitting pull requests\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickna%2FSharpTS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnickna%2FSharpTS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickna%2FSharpTS/lists"}