@@ -114,21 +114,18 @@ export class EnhancerGenerator {
114114
115115 if ( this . needsLogicalClient ) {
116116 prismaTypesFixed = true ;
117- resultPrismaTypeImport = `${ LOGICAL_CLIENT_GENERATION_PATH } /index-fixed ` ;
117+ resultPrismaTypeImport = `${ LOGICAL_CLIENT_GENERATION_PATH } /index` ;
118118 const result = await this . generateLogicalPrisma ( ) ;
119119 dmmf = result . dmmf ;
120120 }
121121
122122 // reexport PrismaClient types (original or fixed)
123- const modelsDts = this . project . createSourceFile (
124- path . join ( this . outDir , 'models.d. ts' ) ,
123+ const modelsTs = this . project . createSourceFile (
124+ path . join ( this . outDir , 'models.ts' ) ,
125125 `export * from '${ resultPrismaTypeImport } ';` ,
126126 { overwrite : true }
127127 ) ;
128- await modelsDts . save ( ) ;
129-
130- // reexport values from the original PrismaClient (enums, etc.)
131- fs . writeFileSync ( path . join ( this . outDir , 'models.js' ) , `module.exports = require('${ prismaImport } ');` ) ;
128+ await modelsTs . save ( ) ;
132129
133130 const authDecl = getAuthDecl ( getDataModelAndTypeDefs ( this . model ) ) ;
134131 const authTypes = authDecl ? generateAuthType ( this . model , authDecl ) : '' ;
177174 return {
178175 dmmf,
179176 newPrismaClientDtsPath : prismaTypesFixed
180- ? path . resolve ( this . outDir , LOGICAL_CLIENT_GENERATION_PATH , 'index-fixed .d.ts' )
177+ ? path . resolve ( this . outDir , LOGICAL_CLIENT_GENERATION_PATH , 'index.d.ts' )
181178 : undefined ,
182179 } ;
183180 }
@@ -457,7 +454,7 @@ export type Enhanced<Client> =
457454 }
458455
459456 private async processClientTypes ( prismaClientDir : string ) {
460- // make necessary updates to the generated `index.d.ts` file and save it as `index-fixed.d.ts`
457+ // make necessary updates to the generated `index.d.ts` file and overwrite it
461458 const project = new Project ( ) ;
462459 const sf = project . addSourceFileAtPath ( path . join ( prismaClientDir , 'index.d.ts' ) ) ;
463460
@@ -473,7 +470,6 @@ export type Enhanced<Client> =
473470 } ) ;
474471
475472 // transform index.d.ts and save it into a new file (better perf than in-line editing)
476-
477473 const sfNew = project . createSourceFile ( path . join ( prismaClientDir , 'index-fixed.d.ts' ) , undefined , {
478474 overwrite : true ,
479475 } ) ;
@@ -483,7 +479,7 @@ export type Enhanced<Client> =
483479 this . generateExtraTypes ( sfNew ) ;
484480
485481 sfNew . formatText ( ) ;
486- await sfNew . save ( ) ;
482+ await sfNew . copyImmediately ( sf . getFilePath ( ) , { overwrite : true } ) ;
487483 }
488484
489485 private transformPrismaTypes ( sf : SourceFile , sfNew : SourceFile , delegateInfo : DelegateInfo ) {
0 commit comments