From 0284451d7a42420263327e10436f1690af37a3bc Mon Sep 17 00:00:00 2001 From: Christian Budde Christensen Date: Wed, 18 Nov 2020 23:24:39 +0100 Subject: [PATCH] feat: Remove prepended ampersand and pipe --- src/templates/partials/typeIntersection.hbs | 2 +- src/templates/partials/typeUnion.hbs | 2 +- test/__snapshots__/index.spec.js.snap | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/templates/partials/typeIntersection.hbs b/src/templates/partials/typeIntersection.hbs index c7cad9b9..0e4af219 100644 --- a/src/templates/partials/typeIntersection.hbs +++ b/src/templates/partials/typeIntersection.hbs @@ -1 +1 @@ -({{#each properties}} & {{>type}}{{/each}}){{>isNullable}} +({{#each properties}}{{#unless @first}} & {{/unless}}{{>type}}{{/each}}){{>isNullable}} diff --git a/src/templates/partials/typeUnion.hbs b/src/templates/partials/typeUnion.hbs index 8eab5b5d..13c71eeb 100644 --- a/src/templates/partials/typeUnion.hbs +++ b/src/templates/partials/typeUnion.hbs @@ -1 +1 @@ -({{#each properties}} | {{>type}}{{/each}}){{>isNullable}} +({{#each properties}}{{#unless @first}} | {{/unless}}{{>type}}{{/each}}){{>isNullable}} diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index afab0a21..15d4cf68 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -2905,7 +2905,7 @@ import type { ModelWithString } from './ModelWithString'; /** * This is a model that extends another model */ -export type ModelThatExtends = ( & ModelWithString & { +export type ModelThatExtends = (ModelWithString & { propExtendsA?: string, propExtendsB?: ModelWithString, });" @@ -2922,7 +2922,7 @@ import type { ModelWithString } from './ModelWithString'; /** * This is a model that extends another model */ -export type ModelThatExtendsExtends = ( & ModelWithString & ModelThatExtends & { +export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & { propExtendsC?: string, propExtendsD?: ModelWithString, });" @@ -2941,7 +2941,7 @@ import type { ModelWithEnum } from './ModelWithEnum'; * This is a model with one property with a 'all of' relationship */ export interface ModelWithAllOfAndNullable { - propA?: ( & { + propA?: ({ boolean?: boolean, } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; } @@ -2962,7 +2962,7 @@ import type { ModelWithString } from './ModelWithString'; * This is a model with one property with a 'any of' relationship */ export interface ModelWithAnyOf { - propA?: ( | ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); + propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); } " `; @@ -2980,7 +2980,7 @@ import type { ModelWithEnum } from './ModelWithEnum'; * This is a model with one property with a 'any of' relationship */ export interface ModelWithAnyOfAndNullable { - propA?: ( | { + propA?: ({ boolean?: boolean, } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null; } @@ -3245,7 +3245,7 @@ import type { ModelWithString } from './ModelWithString'; * This is a model with one property with a 'one of' relationship */ export interface ModelWithOneOf { - propA?: ( | ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); + propA?: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); } " `; @@ -3263,7 +3263,7 @@ import type { ModelWithEnum } from './ModelWithEnum'; * This is a model with one property with a 'one of' relationship */ export interface ModelWithOneOfAndNullable { - propA?: ( | { + propA?: ({ boolean?: boolean, } | ModelWithEnum | ModelWithArray | ModelWithDictionary) | null; } @@ -4344,7 +4344,7 @@ export class ComplexService { readonly type: 'Monkey' | 'Horse' | 'Bird', listOfModels?: Array | null, listOfStrings?: Array | null, - parameters: ( | ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), + parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary), readonly user?: { readonly id?: number, readonly name?: string | null,