TypeSharp.Attributes 1.0.2

dotnet add package TypeSharp.Attributes --version 1.0.2
                    
NuGet\Install-Package TypeSharp.Attributes -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TypeSharp.Attributes" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TypeSharp.Attributes" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="TypeSharp.Attributes" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TypeSharp.Attributes --version 1.0.2
                    
#r "nuget: TypeSharp.Attributes, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TypeSharp.Attributes@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TypeSharp.Attributes&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=TypeSharp.Attributes&version=1.0.2
                    
Install as a Cake Tool

TypeSharp.Attributes

NuGet version NuGet downloads License: MIT GitHub stars Sponsor

C# attributes for controlling TypeSharp TypeScript generation.

TypeSharp is a direct C# → TypeScript type generator. This package provides the attributes that let you fine-tune what gets generated and how — without touching the CLI config.


Installation

dotnet add package TypeSharp.Attributes

Attributes

Attribute Target Description
[TypeSharp] (Class/Enum) Marks a class or enum to be included in TypeScript generation
[TypeIgnore] Property Excludes the property from TypeScript output
[TypeName("...")] Property Overrides the property name in the generated TypeScript
[TypeAs("...")] Property Overrides the inferred TypeScript type
[Obsolete("...")] Property Marks a property as obsolete and optionally affects TypeScript type output

Usage

[TypeIgnore]

Exclude a property entirely from the generated output.

using TypeSharp.Attributes;

[TypeSharp]
public class UserDto
{
    public string Email { get; set; }

    [TypeIgnore]
    public string PasswordHash { get; set; }
}

Generated TypeScript:

export interface UserDto {
  email: string;
}

[TypeName("...")]

Override the property name in the generated TypeScript output.

[TypeSharp]
public class UserDto
{
    [TypeName("created_at")]
    public DateTime CreatedAt { get; set; }

    [TypeName("updated_at")]
    public DateTime UpdatedAt { get; set; }
}

Generated TypeScript:

export interface UserDto {
  created_at: string;
  updated_at: string;
}

[TypeAs("...")]

Override the inferred TypeScript type for a property.

[TypeSharp]
public class UserDto
{
    [TypeAs("Date")]
    public DateTime CreatedAt { get; set; }

    [TypeAs("'admin' | 'user' | 'guest'")]
    public string Role { get; set; }
}

Generated TypeScript:

export interface UserDto {
  createdAt: Date;
  role: "admin" | "user" | "guest";
}

Combining attributes

All three attributes can be stacked together or alongside [Obsolete].

[TypeSharp]
public class ProductDto
{
    public Guid Id { get; set; }

    [TypeName("display_name")]
    public string Name { get; set; }

    [TypeAs("'active' | 'inactive'")]
    public string Status { get; set; }

    [TypeIgnore]
    public string InternalCode { get; set; }

    [Obsolete("Use Status instead.")]
    public bool IsActive { get; set; }
}

Generated TypeScript:

export interface ProductDto {
  id: string;
  display_name: string;
  status: "active" | "inactive";
  /** @deprecated Use Status instead. */
  isActive: boolean;
}

Requirements



License

MIT © Siyavuya Chagi


Built with ❤️ in South Africa 🇿🇦

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 33 3/21/2026
1.0.1 29 3/20/2026
1.0.0 29 3/20/2026