@@ -255,23 +255,33 @@ export class ClientImpl<Schema extends SchemaDef> {
255255 }
256256
257257 $use ( plugin : RuntimePlugin < Schema > ) {
258- const newOptions = {
258+ // tsc perf
259+ const newPlugins : RuntimePlugin < Schema > [ ] = [ ...( this . $options . plugins ?? [ ] ) , plugin ] ;
260+ const newOptions : ClientOptions < Schema > = {
259261 ...this . options ,
260- plugins : [ ... ( this . options . plugins ?? [ ] ) , plugin ] ,
262+ plugins : newPlugins ,
261263 } ;
262264 return new ClientImpl < Schema > ( this . schema , newOptions , this ) ;
263265 }
264266
265267 $unuse ( pluginId : string ) {
266- const newOptions = {
268+ // tsc perf
269+ const newPlugins : RuntimePlugin < Schema > [ ] = [ ] ;
270+ for ( const plugin of this . options . plugins ?? [ ] ) {
271+ if ( plugin . id !== pluginId ) {
272+ newPlugins . push ( plugin ) ;
273+ }
274+ }
275+ const newOptions : ClientOptions < Schema > = {
267276 ...this . options ,
268- plugins : this . options . plugins ?. filter ( ( p ) => p . id !== pluginId ) ,
277+ plugins : newPlugins ,
269278 } ;
270279 return new ClientImpl < Schema > ( this . schema , newOptions , this ) ;
271280 }
272281
273282 $unuseAll ( ) {
274- const newOptions = {
283+ // tsc perf
284+ const newOptions : ClientOptions < Schema > = {
275285 ...this . options ,
276286 plugins : [ ] as RuntimePlugin < Schema > [ ] ,
277287 } ;
@@ -388,7 +398,7 @@ function createModelCrudHandler<Schema extends SchemaDef, Model extends GetModel
388398 for ( const plugin of plugins ) {
389399 if ( plugin . onQuery && typeof plugin . onQuery === 'object' ) {
390400 // for each model key or "$allModels"
391- for ( const [ _model , modelHooks ] of Object . entries ( plugin . onQuery ) ) {
401+ for ( const [ _model , modelHooks ] of Object . entries < any > ( plugin . onQuery ) ) {
392402 if ( _model === lowerCaseFirst ( model ) || _model === '$allModels' ) {
393403 if ( modelHooks && typeof modelHooks === 'object' ) {
394404 // for each operation key or "$allOperations"
0 commit comments