Get TypeSharp running in your project in under 2 minutes.
Navigate to your C# backend project i.e. /CSharp/Project/MyApp.csproj, open in terminal and install TypeSharp controll attributes.
dotnet add package TypeSharp.Attributes Or use GUI nuget package manager Installation using GUI
Use [TypeSharp] attribute on your C# classes, records, or enums to mark them for TypeScript generation.
using TypeSharp.Attributes; [TypeSharp] public class UserDto { public int Id { get; set; } public string Name { get; set; } public string? Email { get; set; } public UserRole Role { get; set; } public List<string> Tags { get; set; } }
Or use GUI nuget package manager Installation using GUI
Navigate to your frontend project and install TypeSharp as a dev dependency.
npm install -D @siyavuyachagi/typesharp In your frontend project run the following script to scaffold a typesharp.config.ts file, which you can edit to point at your C# solution or project file.
npx typesharp init import type { TypeSharpConfig } from '@siyavuyachagi/typesharp' const config: TypeSharpConfig = { source: ['C:/Users/User/Desktop/MyApp/MyApp.slnx'], outputPath: './app/types', singleOutputFile: false, namingConvention: 'camel', fileSuffix: '' } export default config
Run the following command to generate types
npx typesharp generate /** * Auto-generated by TypeSharp * Do not edit this file manually */ export interface UserDto { id: number; name: string; email: string | null; role: UserRole; tags: string[]; }
Import generated types directly in your project components:
import type { UserDto } from '~/app/types/userDto.ts' // Fully typed — no manual interface needed const user = ref<UserDto | null>(null); console.log(user.value?.name);