11import type { SharedSliceModel } from "@prismicio/client" ;
22import { source , stripIndent } from "common-tags" ;
3- import QuickLRU from "quick-lru" ;
3+ import type QuickLRU from "quick-lru" ;
44
55import { SHARED_SLICES_DOCUMENTATION_URL } from "../constants" ;
66import type { AuxiliaryType , FieldConfigs , FieldPath } from "../types" ;
@@ -27,7 +27,7 @@ type BuildSharedSliceTypeReturnValue = {
2727} ;
2828
2929export function buildSharedSliceType (
30- args : BuildSharedSliceTypeArgs ,
30+ args : BuildSharedSliceTypeArgs
3131) : BuildSharedSliceTypeReturnValue {
3232 if ( args . cache ) {
3333 const key = getCacheKey ( [ args . model , args . fieldConfigs ] ) ;
@@ -54,7 +54,10 @@ export function buildSharedSliceType(
5454 const variationName = buildTypeName ( name , variationModel . id ) ;
5555
5656 let primaryInterfaceName : string | undefined ;
57- if ( variationModel . primary && Object . keys ( variationModel . primary ) . length > 0 ) {
57+ if (
58+ variationModel . primary &&
59+ Object . keys ( variationModel . primary ) . length > 0
60+ ) {
5861 primaryInterfaceName = buildTypeName ( variationName , "Primary" ) ;
5962
6063 const path : FieldPath = [
@@ -101,7 +104,7 @@ export function buildSharedSliceType(
101104 ${ docs }
102105 export interface ${ primaryInterfaceName } {}
103106 ` ,
104- code ,
107+ code
105108 ) ;
106109 }
107110
@@ -149,7 +152,7 @@ export function buildSharedSliceType(
149152 ${ docs }
150153 export interface ${ itemInterfaceName } {}
151154 ` ,
152- code ,
155+ code
153156 ) ;
154157 }
155158
@@ -162,11 +165,15 @@ export function buildSharedSliceType(
162165 * - **Description**: ${ variationModel . description || "*None*" }
163166 * - **Documentation**: ${ SHARED_SLICES_DOCUMENTATION_URL }
164167 */
165- export type ${ variationName } = prismic.SharedSliceVariation<"${ variationModel . id } ", ${
166- primaryInterfaceName ? `Simplify<${ primaryInterfaceName } >` : `Record<string, never>`
167- } , ${ itemInterfaceName ? `Simplify<${ itemInterfaceName } >` : `never` } >;
168+ export type ${ variationName } = prismic.SharedSliceVariation<"${
169+ variationModel . id
170+ } ", ${
171+ primaryInterfaceName
172+ ? `Simplify<${ primaryInterfaceName } >`
173+ : `Record<string, never>`
174+ } , ${ itemInterfaceName ? `Simplify<${ itemInterfaceName } >` : `never` } >;
168175 ` ,
169- code ,
176+ code
170177 ) ;
171178
172179 variationNames . push ( variationName ) ;
@@ -183,9 +190,11 @@ export function buildSharedSliceType(
183190 /**
184191 * Slice variation for *${ humanReadableName } *
185192 */
186- type ${ variationUnionName } = ${ variationNames . length > 0 ? variationsUnion : "never" }
193+ type ${ variationUnionName } = ${
194+ variationNames . length > 0 ? variationsUnion : "never"
195+ }
187196 ` ,
188- code ,
197+ code
189198 ) ;
190199
191200 code = addSection (
@@ -197,9 +206,11 @@ export function buildSharedSliceType(
197206 * - **Description**: ${ args . model . description || "*None*" }
198207 * - **Documentation**: ${ SHARED_SLICES_DOCUMENTATION_URL }
199208 */
200- export type ${ name } = prismic.SharedSlice<"${ args . model . id } ", ${ variationUnionName } >;
209+ export type ${ name } = prismic.SharedSlice<"${
210+ args . model . id
211+ } ", ${ variationUnionName } >;
201212 ` ,
202- code ,
213+ code
203214 ) ;
204215
205216 const result = {
0 commit comments