// docs / configuration

Configuration

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.

Generate a config file

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

Configuration options

OptionTypeDefaultDescription
sourcestring | string[]Path(s) to .csproj, .sln, or .slnx file(s)
outputPathstringWhere to generate TypeScript files
singleOutputFilebooleanfalseMerge all types into a single types.ts file
namingConventionstring | { dir, file }"camel"File and directory naming: camel, kebab, pascal, snake
fileSuffixstring""Suffix appended to generated file names

projectFiles is deprecated. Rename it to source — it will be removed in a future major version.

Config file formats

typesharp.config.tsrecommended
import type { TypeSharpConfig } from '@siyavuyachagi/typesharp'

const config: TypeSharpConfig = {
  source: ['C:/MyApp/MyApp.sln'],
  outputPath: './src/types',
  singleOutputFile: false,
  namingConvention: 'camel',
}

export default config
typesharp.config.json
{
  "source": ["C:/MyApp/MyApp.sln"],
  "outputPath": "./src/types",
  "singleOutputFile": false,
  "namingConvention": "camel"
}
typesharp.config.js
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# structurefalse (default)true
One class per fileuser.tstypes.ts
Multiple classes per fileuserDtos.ts (all 3)types.ts
Mixed structureone file per .cs filetypes.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" } }
ConventionDirectoryFile
camelmyFeature/userProfile.ts
kebabmy-feature/user-profile.ts
pascalMyFeature/UserProfile.ts
snakemy_feature/user_profile.ts

Run before dev & build

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"
  }
}