@@ -372,50 +372,50 @@ export function autoTypedSchema() {
372372 }
373373
374374 type TestSchemaType = {
375- string1 ?: string | null ;
376- string2 ?: string | null ;
377- string3 ?: string | null ;
378- string4 ?: string | null ;
375+ string1 ?: string ;
376+ string2 ?: string ;
377+ string3 ?: string ;
378+ string4 ?: string ;
379379 string5 : string ;
380- number1 ?: number | null ;
381- number2 ?: number | null ;
382- number3 ?: number | null ;
383- number4 ?: number | null ;
380+ number1 ?: number ;
381+ number2 ?: number ;
382+ number3 ?: number ;
383+ number4 ?: number ;
384384 number5 : number ;
385- date1 ?: Date | null ;
386- date2 ?: Date | null ;
387- date3 ?: Date | null ;
388- date4 ?: Date | null ;
385+ date1 ?: Date ;
386+ date2 ?: Date ;
387+ date3 ?: Date ;
388+ date4 ?: Date ;
389389 date5 : Date ;
390- buffer1 ?: Buffer | null ;
391- buffer2 ?: Buffer | null ;
392- buffer3 ?: Buffer | null ;
393- buffer4 ?: Buffer | null ;
394- boolean1 ?: boolean | null ;
395- boolean2 ?: boolean | null ;
396- boolean3 ?: boolean | null ;
397- boolean4 ?: boolean | null ;
390+ buffer1 ?: Buffer ;
391+ buffer2 ?: Buffer ;
392+ buffer3 ?: Buffer ;
393+ buffer4 ?: Buffer ;
394+ boolean1 ?: boolean ;
395+ boolean2 ?: boolean ;
396+ boolean3 ?: boolean ;
397+ boolean4 ?: boolean ;
398398 boolean5 : boolean ;
399- mixed1 ?: any | null ;
400- mixed2 ?: any | null ;
401- mixed3 ?: any | null ;
402- objectId1 ?: Types . ObjectId | null ;
403- objectId2 ?: Types . ObjectId | null ;
404- objectId3 ?: Types . ObjectId | null ;
405- customSchema ?: Int8 | null ;
406- map1 ?: Map < string , string > | null ;
407- map2 ?: Map < string , number > | null ;
399+ mixed1 ?: any ;
400+ mixed2 ?: any ;
401+ mixed3 ?: any ;
402+ objectId1 ?: Types . ObjectId ;
403+ objectId2 ?: Types . ObjectId ;
404+ objectId3 ?: Types . ObjectId ;
405+ customSchema ?: Int8 ;
406+ map1 ?: Map < string , string > ;
407+ map2 ?: Map < string , number > ;
408408 array1 : string [ ] ;
409409 array2 : any [ ] ;
410410 array3 : any [ ] ;
411411 array4 : any [ ] ;
412412 array5 : any [ ] ;
413413 array6 : string [ ] ;
414- array7 ?: string [ ] | null ;
415- array8 ?: string [ ] | null ;
416- decimal1 ?: Types . Decimal128 | null ;
417- decimal2 ?: Types . Decimal128 | null ;
418- decimal3 ?: Types . Decimal128 | null ;
414+ array7 ?: string [ ] ;
415+ array8 ?: string [ ] ;
416+ decimal1 ?: Types . Decimal128 ;
417+ decimal2 ?: Types . Decimal128 ;
418+ decimal3 ?: Types . Decimal128 ;
419419 } ;
420420
421421 const TestSchema = new Schema ( {
@@ -552,17 +552,17 @@ export function autoTypedSchema() {
552552export type AutoTypedSchemaType = {
553553 schema : {
554554 userName : string ;
555- description ?: string | null ;
555+ description ?: string ;
556556 nested ?: {
557557 age : number ;
558- hobby ?: string | null
559- } | null ,
560- favoritDrink ?: 'Tea' | 'Coffee' | null ,
558+ hobby ?: string
559+ } ,
560+ favoritDrink ?: 'Tea' | 'Coffee' ,
561561 favoritColorMode : 'dark' | 'light'
562- friendID ?: Types . ObjectId | null ;
562+ friendID ?: Types . ObjectId ;
563563 nestedArray : Types . DocumentArray < {
564564 date : Date ;
565- messages ?: number | null ;
565+ messages ?: number ;
566566 } >
567567 }
568568 , statics : {
@@ -639,7 +639,7 @@ function gh12003() {
639639
640640 expectType < 'type' > ( { } as ObtainSchemaGeneric < typeof BaseSchema , 'TSchemaOptions' > [ 'typeKey' ] ) ;
641641
642- expectType < { name ?: string | null } > ( { } as BaseSchemaType ) ;
642+ expectType < { name ?: string } > ( { } as BaseSchemaType ) ;
643643}
644644
645645function gh11987 ( ) {
@@ -675,7 +675,7 @@ function gh12030() {
675675 }
676676 ] > ;
677677 expectType < {
678- username ?: string | null
678+ username ?: string
679679 } [ ] > ( { } as A ) ;
680680
681681 type B = ObtainDocumentType < {
@@ -687,13 +687,13 @@ function gh12030() {
687687 } > ;
688688 expectType < {
689689 users : {
690- username ?: string | null
690+ username ?: string
691691 } [ ] ;
692692 } > ( { } as B ) ;
693693
694694 expectType < {
695695 users : {
696- username ?: string | null
696+ username ?: string
697697 } [ ] ;
698698 } > ( { } as InferSchemaType < typeof Schema1 > ) ;
699699
@@ -715,7 +715,7 @@ function gh12030() {
715715 expectType < {
716716 users : Types . DocumentArray < {
717717 credit : number ;
718- username ?: string | null ;
718+ username ?: string ;
719719 } > ;
720720 } > ( { } as InferSchemaType < typeof Schema3 > ) ;
721721
@@ -724,7 +724,7 @@ function gh12030() {
724724 data : { type : { role : String } , default : { } }
725725 } ) ;
726726
727- expectType < { data : { role ?: string | null } } > ( { } as InferSchemaType < typeof Schema4 > ) ;
727+ expectType < { data : { role ?: string } } > ( { } as InferSchemaType < typeof Schema4 > ) ;
728728
729729 const Schema5 = new Schema ( {
730730 data : { type : { role : Object } , default : { } }
@@ -749,7 +749,7 @@ function gh12030() {
749749 track ?: {
750750 backupCount : number ;
751751 count : number ;
752- } | null ;
752+ } ;
753753 } > ( { } as InferSchemaType < typeof Schema6 > ) ;
754754
755755}
@@ -826,7 +826,7 @@ function gh12450() {
826826 } ) ;
827827
828828 expectType < {
829- user ?: Types . ObjectId | null ;
829+ user ?: Types . ObjectId ;
830830 } > ( { } as InferSchemaType < typeof ObjectIdSchema > ) ;
831831
832832 const Schema2 = new Schema ( {
@@ -841,14 +841,14 @@ function gh12450() {
841841 decimalValue : { type : Schema . Types . Decimal128 }
842842 } ) ;
843843
844- expectType < { createdAt : Date , decimalValue ?: Types . Decimal128 | null } > ( { } as InferSchemaType < typeof Schema3 > ) ;
844+ expectType < { createdAt : Date , decimalValue ?: Types . Decimal128 } > ( { } as InferSchemaType < typeof Schema3 > ) ;
845845
846846 const Schema4 = new Schema ( {
847847 createdAt : { type : Date } ,
848848 decimalValue : { type : Schema . Types . Decimal128 }
849849 } ) ;
850850
851- expectType < { createdAt ?: Date | null , decimalValue ?: Types . Decimal128 | null } > ( { } as InferSchemaType < typeof Schema4 > ) ;
851+ expectType < { createdAt ?: Date , decimalValue ?: Types . Decimal128 } > ( { } as InferSchemaType < typeof Schema4 > ) ;
852852}
853853
854854function gh12242 ( ) {
@@ -872,7 +872,7 @@ function testInferTimestamps() {
872872 // an error "Parameter type { createdAt: Date; updatedAt: Date; name?: string | undefined; }
873873 // is not identical to argument type { createdAt: NativeDate; updatedAt: NativeDate; } &
874874 // { name?: string | undefined; }"
875- expectType < { createdAt : Date , updatedAt : Date } & { name ?: string | null } > ( { } as WithTimestamps ) ;
875+ expectType < { createdAt : Date , updatedAt : Date } & { name ?: string } > ( { } as WithTimestamps ) ;
876876
877877 const schema2 = new Schema ( {
878878 name : String
@@ -898,25 +898,25 @@ function gh12431() {
898898 } ) ;
899899
900900 type Example = InferSchemaType < typeof testSchema > ;
901- expectType < { testDate ?: Date | null , testDecimal ?: Types . Decimal128 | null } > ( { } as Example ) ;
901+ expectType < { testDate ?: Date , testDecimal ?: Types . Decimal128 } > ( { } as Example ) ;
902902}
903903
904904async function gh12593 ( ) {
905905 const testSchema = new Schema ( { x : { type : Schema . Types . UUID } } ) ;
906906
907907 type Example = InferSchemaType < typeof testSchema > ;
908- expectType < { x ?: Buffer | null } > ( { } as Example ) ;
908+ expectType < { x ?: Buffer } > ( { } as Example ) ;
909909
910910 const Test = model ( 'Test' , testSchema ) ;
911911
912912 const doc = await Test . findOne ( { x : '4709e6d9-61fd-435e-b594-d748eb196d8f' } ) . orFail ( ) ;
913- expectType < Buffer | undefined | null > ( doc . x ) ;
913+ expectType < Buffer | undefined > ( doc . x ) ;
914914
915915 const doc2 = new Test ( { x : '4709e6d9-61fd-435e-b594-d748eb196d8f' } ) ;
916- expectType < Buffer | undefined | null > ( doc2 . x ) ;
916+ expectType < Buffer | undefined > ( doc2 . x ) ;
917917
918918 const doc3 = await Test . findOne ( { } ) . orFail ( ) . lean ( ) ;
919- expectType < Buffer | undefined | null > ( doc3 . x ) ;
919+ expectType < Buffer | undefined > ( doc3 . x ) ;
920920
921921 const arrSchema = new Schema ( { arr : [ { type : Schema . Types . UUID } ] } ) ;
922922
@@ -982,7 +982,7 @@ function gh12611() {
982982 expectType < {
983983 description : string ;
984984 skills : Types . ObjectId [ ] ;
985- anotherField ?: string | null ;
985+ anotherField ?: string ;
986986 } > ( { } as Props ) ;
987987}
988988
0 commit comments