TypeSharp supports all C# record forms. Records are emitted as TypeScript interfaces, identical to classes.
[TypeSharp] public record ProductSummary( int Id, string Name, decimal Price, bool IsActive );
export interface ProductSummary { id: number; name: string; price: number; isActive: boolean; }
record class and record structBoth explicit record keywords are supported and treated identically.
[TypeSharp] public record class AddressRecord(string Street, string City, string PostalCode); [TypeSharp] public record struct CoordRecord(double Lat, double Lng);
Records without a primary constructor are parsed from their { get; set; } properties, the same way as classes.
[TypeSharp] public record PersonRecord { public string FirstName { get; set; } public string LastName { get; set; } }
[TypeSharp] public record PagedResult<T>( IEnumerable<T> Items, int TotalCount, int PageSize );
export interface PagedResult<T> { items: T[]; totalCount: number; pageSize: number; }
[TypeIgnore], [TypeName], [TypeAs], and [Obsolete] work on primary constructor parameters. Use the property: target so the compiler applies the attribute to the generated property.
[TypeSharp] public record SecureRecord( string Name, [property: TypeIgnore] string Secret, [property: TypeAs("Date")] DateTime CreatedAt, [property: Obsolete("Use Name")] string Alias );
export interface SecureRecord { name: string; createdAt: Date; /** @deprecated Use Name */ alias: string; }