diff --git a/src/index.test.ts b/src/index.test.ts index fb4e867..4e7c596 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -376,21 +376,21 @@ describe('generateJSONSchemaTypes()', () => { }; expect( - toSource( - await generateJSONSchemaTypes(schema, { - brandedTypes: [], - generateRealEnums: true, - tuplesFromFixedArraysLengthLimit: 5, - exportNamespaces: true, - }), - ), - ).toMatchInlineSnapshot(` + toSource( + await generateJSONSchemaTypes(schema, { + brandedTypes: [], + generateRealEnums: true, + tuplesFromFixedArraysLengthLimit: 5, + exportNamespaces: true + }) + ) +).toMatchInlineSnapshot(` "export type Main = Enums.Limit; export namespace Enums { export enum Limit { - _0M = "1m", - _0D = "1d", - _0W = "1w" + _1M = "1m", + _1D = "1d", + _1W = "1w" } }" `); diff --git a/src/index.ts b/src/index.ts index 5f4bd4e..b87cef4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -53,7 +53,7 @@ export function buildIdentifier(part: string): string { (_: unknown, $1: string, $2: string) => $1 + $2.toUpperCase(), ) .replace(/[^a-z0-9]/gi, '') - .replace(/^[0-9]/, (_: unknown, $1: string) => '_' + $1); + .replace(/^([0-9])/, (_: unknown, $1: string) => '_' + $1); return identifier || 'Unknown'; }