TypeSharp is configured via a typesharp.config.json, .ts, or .js file in your frontend project root. Run npx typesharp init to generate one automatically.
Run the init command inside your frontend project to scaffold a config file:
$ npx typesharp init$ npx typesharp init --format json $ npx typesharp init --format js| Option | Type | Default | Description |
|---|---|---|---|
| source | string | string[] | — | Path(s) to .csproj, .sln, or .slnx file(s) |
| outputPath | string | — | Where to generate TypeScript files |
| singleOutputFile | boolean | false | Merge all types into a single types.ts file |
| namingConvention | string | { dir, file } | "camel" | File and directory naming: camel, kebab, pascal, snake |
| fileSuffix | string | "" | Suffix appended to generated file names |
projectFiles is deprecated. Rename it to source — it will be removed in a future major version.
import type { TypeSharpConfig } from '@siyavuyachagi/typesharp' const config: TypeSharpConfig = { source: ['C:/MyApp/MyApp.sln'], outputPath: './src/types', singleOutputFile: false, namingConvention: 'camel', } export default config
{
"source": ["C:/MyApp/MyApp.sln"],
"outputPath": "./src/types",
"singleOutputFile": false,
"namingConvention": "camel"
}export default { source: ['C:/MyApp/MyApp.sln'], outputPath: './src/types', }
source Accepts a single path or an array. Supports .csproj, .sln, and .slnx files. When pointing at a solution file, TypeSharp resolves all referenced .csproj files automatically.
// Single solution { "source": "C:/MyApp/MyApp.sln" } // Multiple projects { "source": ["C:/MyApp/Api/Api.csproj", "C:/MyApp/Domain/Domain.csproj"] }
singleOutputFile Controls whether TypeSharp emits one file per C# source file (preserving grouping) or merges everything into a single types.ts.
| C# structure | false (default) | true |
|---|---|---|
| One class per file | user.ts | types.ts |
| Multiple classes per file | userDtos.ts (all 3) | types.ts |
| Mixed structure | one file per .cs file | types.ts |
namingConvention Controls file and directory naming. Pass a string to apply the same convention to both, or an object to control them separately. Property names always use camelCase regardless of this setting.
// Simple — both dirs and files { "namingConvention": "kebab" } // Advanced — separate control { "namingConvention": { "dir": "kebab", "file": "camel" } }
| Convention | Directory | File |
|---|---|---|
| camel | myFeature/ | userProfile.ts |
| kebab | my-feature/ | user-profile.ts |
| pascal | MyFeature/ | UserProfile.ts |
| snake | my_feature/ | user_profile.ts |
Add TypeSharp to your package.json scripts so types are always up to date before the dev server or build starts:
{
"scripts": {
"predev": "typesharp",
"prebuild": "typesharp",
"dev": "nuxt dev",
"build": "nuxt build"
}
}