change-case#pascalCaseTransformMerge TypeScript Examples

The following examples show how to use change-case#pascalCaseTransformMerge. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GoGenerator.ts    From modelina with Apache License 2.0 6 votes vote down vote up
GoNamingConventionImplementation: GoNamingConvention = {
  type: (name: string | undefined, ctx) => {
    if (!name) { return ''; }
    let formattedName = FormatHelpers.toPascalCase(name, { transform: pascalCaseTransformMerge });
    if (ctx.reservedKeywordCallback !== undefined && ctx.reservedKeywordCallback(formattedName)) {
      formattedName = FormatHelpers.toPascalCase(`reserved_${formattedName}`);
    }
    return formattedName;
  },
  // eslint-disable-next-line sonarjs/no-identical-functions
  field: (name: string | undefined, ctx) => {
    if (!name) { return ''; }
    let formattedName = FormatHelpers.toPascalCase(name, { transform: pascalCaseTransformMerge });
    if (ctx.reservedKeywordCallback !== undefined && ctx.reservedKeywordCallback(formattedName)) {
      formattedName = FormatHelpers.toPascalCase(`reserved_${formattedName}`);
      if (Object.keys(ctx.model.properties || {}).includes(formattedName)) {
        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
        return GoNamingConventionImplementation.field!(`reserved_${formattedName}`, ctx);
      }
    }
    return formattedName;
  }
}