File tree Expand file tree Collapse file tree 2 files changed +3
-1
lines changed
packages/schema-typescript/src Expand file tree Collapse file tree 2 files changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export interface SchemaTSOptions {
1515 useSingleQuotes : boolean ;
1616 camelCase ?: boolean ; // defaults to false
1717 camelCaseFn ?: ( str : string ) => string ; // optional function to convert keys to camelCase
18+ stripLeadingNonAlphabetChars ?: boolean ; // defaults to true, strips leading non-alphabet chars when camelCasing
1819 strictTypeSafety : boolean ; // true uses { [k: string]: unknown; }, false uses any
1920 overrides ?: SchemaDefinitionOverrides ;
2021
@@ -72,6 +73,7 @@ export const defaultSchemaTSOptions: SchemaTSOptions = {
7273 useSingleQuotes : true ,
7374 camelCase : false ,
7475 camelCaseFn : null ,
76+ stripLeadingNonAlphabetChars : false ,
7577 strictTypeSafety : true ,
7678 exclude : [ ] ,
7779 include : [ ] ,
Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ function createPropertySignature(
233233 required : string [ ] ,
234234 schema : JSONSchema
235235) : t . TSPropertySignature {
236- let camelCaseFn : ( str : string ) => string = toCamelCase ;
236+ let camelCaseFn : ( str : string ) => string = ( str : string ) => toCamelCase ( str , ctx . options . stripLeadingNonAlphabetChars ) ;
237237 if ( ctx . options . camelCaseFn ) camelCaseFn = ctx . options . camelCaseFn ;
238238 const name = ctx . options . camelCase ? camelCaseFn ( key ) : key ;
239239 const propType = getTypeForProp ( ctx , prop , required , schema ) ;
You can’t perform that action at this time.
0 commit comments