@@ -192,10 +192,49 @@ function autoTypedDocument() {
192192 expectType < AutoTypedSchemaType [ 'schema' ] [ 'userName' ] > ( AutoTypeModelInstance . userName ) ;
193193 expectType < AutoTypedSchemaType [ 'schema' ] [ 'favoritDrink' ] > ( AutoTypeModelInstance . favoritDrink ) ;
194194 expectType < AutoTypedSchemaType [ 'schema' ] [ 'favoritColorMode' ] > ( AutoTypeModelInstance . favoritColorMode ) ;
195- expectType < number > ( AutoTypeModelInstance . unExistProperty ) ;
196- expectType < number > ( AutoTypeModelInstance . description ) ;
197195
198196 // Document-Methods-tests
199197 expectType < ReturnType < AutoTypedSchemaType [ 'methods' ] [ 'instanceFn' ] > > ( new AutoTypedModel ( ) . instanceFn ( ) ) ;
200198
199+ }
200+
201+ async function gh11960 ( ) {
202+ type DocumentType < T > = Document < any > & T ;
203+ type SubDocumentType < T > = DocumentType < T > & Types . Subdocument ;
204+ type ArraySubDocumentType < T > = DocumentType < T > & Types . ArraySubdocument ;
205+
206+ interface Nested {
207+ dummy ?: string ;
208+ }
209+
210+ interface Parent {
211+ username ?: string ;
212+ map ?: Map < string , string > ;
213+ nested ?: SubDocumentType < Nested > ;
214+ nestedArray ?: ArraySubDocumentType < Nested > [ ] ;
215+ }
216+
217+ const NestedSchema = new Schema ( {
218+ dummy : { type : String }
219+ } ) ;
220+
221+ const ParentSchema = new Schema ( {
222+ username : { type : String } ,
223+ map : { type : Map , of : String } ,
224+ nested : { type : NestedSchema } ,
225+ nestedArray : [ { type : NestedSchema } ]
226+ } ) ;
227+
228+ const ParentModel = model < DocumentType < Parent > > ( 'Parent' , ParentSchema ) ;
229+
230+ const doc = new ParentModel ( {
231+ username : 'user1' ,
232+ map : { key1 : 'value1' , key2 : 'value2' } ,
233+ nested : { dummy : 'hello' } ,
234+ nestedArray : [ { dummy : 'hello again' } ]
235+ } ) ;
236+
237+ expectType < Map < string , string > | undefined > ( doc . map ) ;
238+ doc . nested ! . parent ( ) ;
239+
201240}
0 commit comments