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 nugget 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 nugget 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.sln'], outputPath: './app/types', singleOutputFile: false, namingConvention: 'camel', fileSuffix: '' } export default config
Run the following command to generate types
$ npx typesharp Import generated types directly in your project components:
import type { UserDto } from '~/app/types/userDto.ts' const user = ref<UserDto | null>(null);