From abf666d0e7c3f7a2e42b6734a5a66f4103f46d36 Mon Sep 17 00:00:00 2001 From: Kononnable Date: Tue, 12 Mar 2019 22:01:11 +0100 Subject: [PATCH] fixed shadowed variables tslint errors closes #141 --- src/Engine.ts | 3 +++ src/entity.mst | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Engine.ts b/src/Engine.ts index a9b08c3..48655a8 100644 --- a/src/Engine.ts +++ b/src/Engine.ts @@ -278,6 +278,9 @@ function createHandlebarsHelpers(generationOptions: IGenerationOptions) { return retStr; }); Handlebars.registerHelper("toLowerCase", str => str.toLowerCase()); + Handlebars.registerHelper("tolowerCaseFirst", str => + changeCase.lowerCaseFirst(str) + ); Handlebars.registerHelper("toLazy", str => { if (generationOptions.lazy) { return `Promise<${str}>`; diff --git a/src/entity.mst b/src/entity.mst index 3dc4226..b9b0a2d 100644 --- a/src/entity.mst +++ b/src/entity.mst @@ -25,7 +25,7 @@ import {BaseEntity,Column,Entity,Index,JoinColumn,JoinTable,ManyToMany,ManyToOne }){{/options}} {{printPropertyVisibility}}{{toPropertyName tsName}}:{{tsType}}{{#options/nullable}} | null{{/options/nullable}}; {{/relations}}{{#relations}} - @{{relationType}}(type=>{{toEntityName relatedTable}}, {{toEntityName relatedTable}}=>{{toEntityName relatedTable}}.{{#if isOwner}}{{toPropertyName ownerColumn}},{ {{#../options/primary}}primary:true,{{/../options/primary}}{{^../options/nullable}} nullable:false,{{/../options/nullable}}{{#actionOnDelete}}onDelete: '{{.}}',{{/actionOnDelete}}{{#actionOnUpdate}}onUpdate: '{{.}}'{{/actionOnUpdate}} }{{else}}{{toPropertyName relatedColumn}}{{#if (or actionOnDelete actionOnUpdate ) }}{{#actionOnDelete}},{ onDelete: '{{.}}' ,{{/actionOnDelete}}{{#actionOnUpdate}}onUpdate: '{{.}}'{{/actionOnUpdate}} }{{/if}}{{/if}}){{#isOwner}} + @{{relationType}}(type=>{{toEntityName relatedTable}}, {{tolowerCaseFirst relatedTable}}=>{{tolowerCaseFirst relatedTable}}.{{#if isOwner}}{{toPropertyName ownerColumn}},{ {{#../options/primary}}primary:true,{{/../options/primary}}{{^../options/nullable}} nullable:false,{{/../options/nullable}}{{#actionOnDelete}}onDelete: '{{.}}',{{/actionOnDelete}}{{#actionOnUpdate}}onUpdate: '{{.}}'{{/actionOnUpdate}} }{{else}}{{toPropertyName relatedColumn}}{{#if (or actionOnDelete actionOnUpdate ) }}{{#actionOnDelete}},{ onDelete: '{{.}}' ,{{/actionOnDelete}}{{#actionOnUpdate}}onUpdate: '{{.}}'{{/actionOnUpdate}} }{{/if}}{{/if}}){{#isOwner}} {{#if isManyToMany}}@JoinTable({ name:'{{ ../options/name}}'}){{else}}@JoinColumn({ name:'{{ ../options/name}}'}){{/if}}{{/isOwner}} {{#if (or isOneToMany isManyToMany)}}{{printPropertyVisibility}}{{toPropertyName ../tsName}}:{{toLazy (concat (toEntityName relatedTable) "[]")}}; {{else}}{{printPropertyVisibility}}{{toPropertyName ../tsName}}:{{toLazy (concat (toEntityName relatedTable) ' | null')}};