@@ -1063,6 +1063,30 @@ function stringEnumInfer() {
10631063 type StringEnumRequiredExample = InferSchemaType < typeof stringEnumSchemaRequired > ;
10641064 expectAssignable < StringEnum > ( { } as StringEnumRequiredExample [ 'active' ] ) ;
10651065}
1066+ function stringEnumArrayInfer ( ) {
1067+ enum StringEnum {
1068+ Foo = 'foo' ,
1069+ Bar = 'bar'
1070+ }
1071+
1072+ const stringEnumSchema = new Schema (
1073+ {
1074+ active : { type : [ String ] , enum : StringEnum , required : false }
1075+ }
1076+ ) ;
1077+
1078+ type StringEnumExample = InferSchemaType < typeof stringEnumSchema > ;
1079+ expectAssignable < StringEnum [ ] | null | undefined > ( { } as StringEnumExample [ 'active' ] ) ;
1080+
1081+ const stringEnumSchemaRequired = new Schema (
1082+ {
1083+ active : { type : [ String ] , enum : StringEnum , required : true }
1084+ }
1085+ ) ;
1086+
1087+ type StringEnumRequiredExample = InferSchemaType < typeof stringEnumSchemaRequired > ;
1088+ expectAssignable < StringEnum [ ] > ( { } as StringEnumRequiredExample [ 'active' ] ) ;
1089+ }
10661090
10671091function gh12882 ( ) {
10681092 // Array of strings
@@ -1976,3 +2000,19 @@ function gh10894() {
19762000 expectType < string | number | null | undefined > ( { } as RawDocType [ 'testProp' ] ) ;
19772001 }
19782002}
2003+
2004+ function autoInferredNestedMaps ( ) {
2005+ const schema = new Schema ( {
2006+ nestedMap : {
2007+ type : Map ,
2008+ required : true ,
2009+ of : {
2010+ type : Map ,
2011+ of : String
2012+ }
2013+ }
2014+ } ) ;
2015+ const TestModel = model ( 'Test' , schema ) ;
2016+ const doc = new TestModel ( { nestedMap : new Map ( [ [ '1' , new Map ( [ [ '2' , 'value' ] ] ) ] ] ) } ) ;
2017+ expectType < Map < string , Map < string , string > > > ( doc . nestedMap ) ;
2018+ }
0 commit comments