@@ -40,7 +40,7 @@ interface Actor {
40
40
age : number
41
41
}
42
42
const actorSchema =
43
- new Schema < Actor & Document , Model < Actor & Document > , Actor > ( { name : { type : String } , age : { type : Number } } ) ;
43
+ new Schema < unknown , Actor & Document , Model < Actor & Document > , Actor > ( { name : { type : String } , age : { type : Number } } ) ;
44
44
45
45
interface Movie {
46
46
title ?: string ,
@@ -52,7 +52,7 @@ interface Movie {
52
52
actors : Actor [ ]
53
53
}
54
54
55
- const movieSchema = new Schema < Document & Movie , Model < Document & Movie > > ( {
55
+ const movieSchema = new Schema < unknown , Document & Movie , Model < Document & Movie > > ( {
56
56
title : {
57
57
type : String ,
58
58
index : 'text'
@@ -122,7 +122,7 @@ interface IProfile {
122
122
age : number ;
123
123
}
124
124
const ProfileSchemaDef : SchemaDefinition < IProfile > = { age : Number } ;
125
- export const ProfileSchema = new Schema < IProfile , Model < IProfile > > ( ProfileSchemaDef ) ;
125
+ export const ProfileSchema = new Schema < unknown , IProfile , Model < IProfile > > ( ProfileSchemaDef ) ;
126
126
127
127
interface IUser {
128
128
email : string ;
@@ -133,7 +133,7 @@ const ProfileSchemaDef2: SchemaDefinition<IProfile> = {
133
133
age : Schema . Types . Number
134
134
} ;
135
135
136
- const ProfileSchema2 : Schema < IProfile , Model < IProfile > > = new Schema < IProfile > ( ProfileSchemaDef2 ) ;
136
+ const ProfileSchema2 = new Schema < unknown , IProfile , Model < IProfile > > ( ProfileSchemaDef2 ) ;
137
137
138
138
const UserSchemaDef : SchemaDefinition < IUser > = {
139
139
email : String ,
@@ -178,27 +178,27 @@ function gh10287() {
178
178
testProp : string ;
179
179
}
180
180
181
- const subSchema = new Schema < Document & SubSchema , Model < Document & SubSchema > , SubSchema > ( {
181
+ const subSchema = new Schema < unknown , Document & SubSchema , Model < Document & SubSchema > , SubSchema > ( {
182
182
testProp : Schema . Types . String
183
183
} ) ;
184
184
185
185
interface MainSchema {
186
186
subProp : SubSchema
187
187
}
188
188
189
- const mainSchema1 = new Schema < Document & MainSchema , Model < Document & MainSchema > , MainSchema > ( {
189
+ const mainSchema1 = new Schema < unknown , Document & MainSchema , Model < Document & MainSchema > , MainSchema > ( {
190
190
subProp : subSchema
191
191
} ) ;
192
192
193
- const mainSchema2 = new Schema < Document & MainSchema , Model < Document & MainSchema > , MainSchema > ( {
193
+ const mainSchema2 = new Schema < unknown , Document & MainSchema , Model < Document & MainSchema > , MainSchema > ( {
194
194
subProp : {
195
195
type : subSchema
196
196
}
197
197
} ) ;
198
198
}
199
199
200
200
function gh10370 ( ) {
201
- const movieSchema = new Schema < Document & Movie , Model < Document & Movie > , Movie > ( {
201
+ const movieSchema = new Schema < unknown , Document & Movie , Model < Document & Movie > , Movie > ( {
202
202
actors : {
203
203
type : [ actorSchema ]
204
204
}
@@ -209,7 +209,7 @@ function gh10409() {
209
209
interface Something {
210
210
field : Date ;
211
211
}
212
- const someSchema = new Schema < Something , Model < Something > , Something > ( {
212
+ const someSchema = new Schema < unknown , Something , Model < Something > , Something > ( {
213
213
field : { type : Date }
214
214
} ) ;
215
215
}
@@ -221,7 +221,7 @@ function gh10605() {
221
221
value : number
222
222
} ;
223
223
}
224
- const schema = new Schema < ITest > ( {
224
+ const schema = new Schema < unknown , ITest > ( {
225
225
arrayField : [ String ] ,
226
226
object : {
227
227
type : {
@@ -238,7 +238,7 @@ function gh10605_2() {
238
238
someObject : Array < { id : string } >
239
239
}
240
240
241
- const testSchema = new Schema < ITestSchema > ( {
241
+ const testSchema = new Schema < unknown , ITestSchema > ( {
242
242
someObject : { type : [ { id : String } ] }
243
243
} ) ;
244
244
}
@@ -248,7 +248,7 @@ function gh10731() {
248
248
keywords : string [ ] ;
249
249
}
250
250
251
- const productSchema = new Schema < IProduct > ( {
251
+ const productSchema = new Schema < unknown , IProduct > ( {
252
252
keywords : {
253
253
type : [
254
254
{
@@ -275,7 +275,7 @@ function gh10789() {
275
275
addresses : IAddress [ ] ;
276
276
}
277
277
278
- const addressSchema = new Schema < IAddress > ( {
278
+ const addressSchema = new Schema < unknown , IAddress > ( {
279
279
city : {
280
280
type : String ,
281
281
required : true
@@ -290,7 +290,7 @@ function gh10789() {
290
290
}
291
291
} ) ;
292
292
293
- const userSchema = new Schema < IUser > ( {
293
+ const userSchema = new Schema < unknown , IUser > ( {
294
294
name : {
295
295
type : String ,
296
296
required : true
@@ -312,7 +312,7 @@ function gh11439() {
312
312
collection : string
313
313
} ;
314
314
315
- const bookSchema = new Schema < Book > ( {
315
+ const bookSchema = new Schema < unknown , Book > ( {
316
316
collection : String
317
317
} , {
318
318
suppressReservedKeysWarning : true
@@ -325,7 +325,7 @@ function gh11448() {
325
325
age : number ;
326
326
}
327
327
328
- const userSchema = new Schema < IUser > ( { name : String , age : Number } ) ;
328
+ const userSchema = new Schema < unknown , IUser > ( { name : String , age : Number } ) ;
329
329
330
330
userSchema . pick < Pick < IUser , 'age' > > ( [ 'age' ] ) ;
331
331
}
@@ -335,7 +335,7 @@ function gh11435(): void {
335
335
ids : Types . Array < Types . ObjectId > ;
336
336
}
337
337
338
- const schema = new Schema < User > ( {
338
+ const schema = new Schema < unknown , User > ( {
339
339
ids : {
340
340
type : [ { type : Schema . Types . ObjectId , ref : 'Something' } ] ,
341
341
default : [ ]
@@ -355,7 +355,7 @@ function gh10900(): void {
355
355
menuStatus : TMenuStatus ;
356
356
}
357
357
358
- const patientSchema = new Schema < IUserProp > ( {
358
+ const patientSchema = new Schema < unknown , IUserProp > ( {
359
359
menuStatus : { type : Schema . Types . Mixed , default : { } }
360
360
} ) ;
361
361
}
@@ -578,8 +578,8 @@ export type AutoTypedSchemaType = {
578
578
} ;
579
579
580
580
// discriminator
581
- const eventSchema = new Schema < { message : string } > ( { message : String } , { discriminatorKey : 'kind' } ) ;
582
- const batchSchema = new Schema < { name : string } > ( { name : String } , { discriminatorKey : 'kind' } ) ;
581
+ const eventSchema = new Schema < unknown , { message : string } > ( { message : String } , { discriminatorKey : 'kind' } ) ;
582
+ const batchSchema = new Schema < unknown , { name : string } > ( { name : String } , { discriminatorKey : 'kind' } ) ;
583
583
batchSchema . discriminator ( 'event' , eventSchema ) ;
584
584
585
585
// discriminator statics
@@ -594,11 +594,11 @@ batchSchema2.discriminator('event', eventSchema2);
594
594
595
595
function encryptionType ( ) {
596
596
const keyId = new BSON . UUID ( ) ;
597
- expectError < Schema > ( new Schema ( { name : { type : String , encrypt : { keyId } } } , { encryptionType : 'newFakeEncryptionType' } ) ) ;
598
- expectError < Schema > ( new Schema ( { name : { type : String , encrypt : { keyId } } } , { encryptionType : 1 } ) ) ;
597
+ expectError ( new Schema < unknown > ( { name : { type : String , encrypt : { keyId } } } , { encryptionType : 'newFakeEncryptionType' } ) ) ;
598
+ expectError ( new Schema < unknown > ( { name : { type : String , encrypt : { keyId } } } , { encryptionType : 1 } ) ) ;
599
599
600
- expectType < Schema > ( new Schema ( { name : { type : String , encrypt : { keyId } } } , { encryptionType : 'queryableEncryption' } ) ) ;
601
- expectType < Schema > ( new Schema ( { name : { type : String , encrypt : { keyId } } } , { encryptionType : 'csfle' } ) ) ;
600
+ expectType < Schema > ( new Schema < unknown > ( { name : { type : String , encrypt : { keyId } } } , { encryptionType : 'queryableEncryption' } ) ) ;
601
+ expectType < Schema > ( new Schema < unknown > ( { name : { type : String , encrypt : { keyId } } } , { encryptionType : 'csfle' } ) ) ;
602
602
}
603
603
604
604
function gh11828 ( ) {
@@ -616,7 +616,7 @@ function gh11828() {
616
616
}
617
617
} ;
618
618
619
- new Schema < IUser > ( {
619
+ new Schema < unknown , IUser > ( {
620
620
name : { type : String , default : ( ) => 'Hafez' } ,
621
621
age : { type : Number , default : ( ) => 27 } ,
622
622
bornAt : { type : Date , default : ( ) => new Date ( ) } ,
@@ -634,7 +634,7 @@ function gh11997() {
634
634
name : string ;
635
635
}
636
636
637
- const userSchema = new Schema < IUser > ( {
637
+ const userSchema = new Schema < unknown , IUser > ( {
638
638
name : { type : String , default : ( ) => 'Hafez' }
639
639
} ) ;
640
640
userSchema . index ( { name : 1 } , { weights : { name : 1 } } ) ;
@@ -664,7 +664,7 @@ function gh11987() {
664
664
organization : Types . ObjectId ;
665
665
}
666
666
667
- const userSchema = new Schema < IUser > ( {
667
+ const userSchema = new Schema < unknown , IUser > ( {
668
668
name : { type : String , required : true } ,
669
669
email : { type : String , required : true } ,
670
670
organization : { type : Schema . Types . ObjectId , ref : 'Organization' }
@@ -775,12 +775,12 @@ function pluginOptions() {
775
775
option2 : number ;
776
776
}
777
777
778
- function pluginFunction ( schema : Schema < any > , options : SomePluginOptions ) {
778
+ function pluginFunction ( schema : Schema < any , any > , options : SomePluginOptions ) {
779
779
return ; // empty function, to satisfy lint option
780
780
}
781
781
782
782
const schema = new Schema ( { } ) ;
783
- expectType < Schema < any > > ( schema . plugin ( pluginFunction ) ) ; // test that chaining would be possible
783
+ expectType < Schema < any , any > > ( schema . plugin ( pluginFunction ) ) ; // test that chaining would be possible
784
784
785
785
// could not add strict tests that the parameters are inferred correctly, because i dont know how this would be done in tsd
786
786
@@ -1216,7 +1216,7 @@ function gh13800() {
1216
1216
type UserModel = Model < IUser , { } , IUserMethods > ;
1217
1217
1218
1218
// Typed Schema
1219
- const schema = new Schema < IUser , UserModel , IUserMethods > ( {
1219
+ const schema = new Schema < unknown , IUser , UserModel , IUserMethods > ( {
1220
1220
firstName : { type : String , required : true } ,
1221
1221
lastName : { type : String , required : true }
1222
1222
} ) ;
@@ -1243,7 +1243,7 @@ async function gh13797() {
1243
1243
interface IUser {
1244
1244
name : string ;
1245
1245
}
1246
- new Schema < IUser > ( {
1246
+ new Schema < unknown , IUser > ( {
1247
1247
name : {
1248
1248
type : String ,
1249
1249
required : function ( ) {
@@ -1252,7 +1252,7 @@ async function gh13797() {
1252
1252
}
1253
1253
}
1254
1254
} ) ;
1255
- new Schema < IUser > ( {
1255
+ new Schema < unknown , IUser > ( {
1256
1256
name : {
1257
1257
type : String ,
1258
1258
default : function ( ) {
@@ -1293,7 +1293,7 @@ function gh14028_methods() {
1293
1293
type UserModel = Model < IUser , { } , IUserMethods > ;
1294
1294
1295
1295
// Define methods on schema
1296
- const schema = new Schema < IUser , UserModel , IUserMethods > ( {
1296
+ const schema = new Schema < unknown , IUser , UserModel , IUserMethods > ( {
1297
1297
firstName : { type : String , required : true } ,
1298
1298
lastName : { type : String , required : true } ,
1299
1299
age : { type : Number , required : true }
@@ -1323,7 +1323,7 @@ function gh14028_methods() {
1323
1323
expectType < IUserMethods [ 'isAdult' ] > ( schema . methods . isAdult ) ;
1324
1324
1325
1325
// Define methods outside of schema
1326
- const schema2 = new Schema < IUser , UserModel , IUserMethods > ( {
1326
+ const schema2 = new Schema < unknown , IUser , UserModel , IUserMethods > ( {
1327
1327
firstName : { type : String , required : true } ,
1328
1328
lastName : { type : String , required : true } ,
1329
1329
age : { type : Number , required : true }
@@ -1346,7 +1346,7 @@ function gh14028_methods() {
1346
1346
1347
1347
type UserModelWithoutMethods = Model < IUser > ;
1348
1348
// Skip InstanceMethods
1349
- const schema3 = new Schema < IUser , UserModelWithoutMethods > ( {
1349
+ const schema3 = new Schema < unknown , IUser , UserModelWithoutMethods > ( {
1350
1350
firstName : { type : String , required : true } ,
1351
1351
lastName : { type : String , required : true } ,
1352
1352
age : { type : Number , required : true }
@@ -1380,7 +1380,7 @@ function gh14028_statics() {
1380
1380
type UserModel = Model < IUser , { } > ;
1381
1381
1382
1382
// Define statics on schema
1383
- const schema = new Schema < IUser , UserModel , { } , { } , { } , IUserStatics > ( {
1383
+ const schema = new Schema < unknown , IUser , UserModel , { } , { } , { } , IUserStatics > ( {
1384
1384
firstName : { type : String , required : true } ,
1385
1385
lastName : { type : String , required : true } ,
1386
1386
age : { type : Number , required : true }
@@ -1434,7 +1434,7 @@ function gh14235() {
1434
1434
age : number ;
1435
1435
}
1436
1436
1437
- const userSchema = new Schema < IUser > ( { name : String , age : Number } ) ;
1437
+ const userSchema = new Schema < unknown , IUser > ( { name : String , age : Number } ) ;
1438
1438
1439
1439
userSchema . omit < Omit < IUser , 'age' > > ( [ 'age' ] ) ;
1440
1440
}
@@ -1498,18 +1498,18 @@ function gh14573() {
1498
1498
type UserModelType = Model < User , { } , UserMethods , { } , THydratedUserDocument > ;
1499
1499
1500
1500
const userSchema = new Schema <
1501
+ unknown ,
1501
1502
User ,
1502
1503
UserModelType ,
1503
1504
UserMethods ,
1504
1505
{ } ,
1505
1506
{ } ,
1506
1507
{ } ,
1507
1508
DefaultSchemaOptions ,
1508
- User ,
1509
1509
THydratedUserDocument
1510
1510
> (
1511
1511
{
1512
- names : new Schema < Names > ( { firstName : String } )
1512
+ names : new Schema < unknown , Names > ( { firstName : String } )
1513
1513
} ,
1514
1514
{
1515
1515
methods : {
@@ -1562,7 +1562,7 @@ function gh14696() {
1562
1562
}
1563
1563
1564
1564
type UserModelType = Model < User , { } , IUserMethods > ;
1565
- const userSchema = new Schema < User , UserModelType , IUserMethods > ( {
1565
+ const userSchema = new Schema < unknown , User , UserModelType , IUserMethods > ( {
1566
1566
name : {
1567
1567
type : String ,
1568
1568
required : [ true , 'Name on card is required' ]
@@ -1787,7 +1787,7 @@ function gh15301() {
1787
1787
interface IUser {
1788
1788
time : { hours : number , minutes : number }
1789
1789
}
1790
- const userSchema = new Schema < IUser > ( {
1790
+ const userSchema = new Schema < unknown , IUser > ( {
1791
1791
time : {
1792
1792
type : new Schema (
1793
1793
{
@@ -1831,7 +1831,7 @@ function gh15412() {
1831
1831
}
1832
1832
1833
1833
function defaultReturnsUndefined ( ) {
1834
- const schema = new Schema < { arr : number [ ] } > ( {
1834
+ const schema = new Schema < unknown , { arr : number [ ] } > ( {
1835
1835
arr : {
1836
1836
type : [ Number ] ,
1837
1837
default : ( ) => void 0
0 commit comments