File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -1645,3 +1645,21 @@ function gh8389() {
16451645function gh14879 ( ) {
16461646 Schema . Types . String . setters . push ( ( val ?: unknown ) => typeof val === 'string' ? val . trim ( ) : val ) ;
16471647}
1648+
1649+ async function gh14950 ( ) {
1650+ const SightingSchema = new Schema (
1651+ {
1652+ _id : { type : Schema . Types . ObjectId , required : true } ,
1653+ location : {
1654+ type : { type : String , required : true } ,
1655+ coordinates : [ { type : Number } ]
1656+ }
1657+ }
1658+ ) ;
1659+
1660+ const TestModel = model ( 'Test' , SightingSchema ) ;
1661+ const doc = await TestModel . findOne ( ) . orFail ( ) ;
1662+
1663+ expectType < string > ( doc . location ! . type ) ;
1664+ expectType < number [ ] > ( doc . location ! . coordinates ) ;
1665+ }
Original file line number Diff line number Diff line change @@ -183,8 +183,16 @@ type TypeHint<T> = T extends { __typehint: infer U } ? U: never;
183183 * @param {TypeKey } TypeKey A generic refers to document definition.
184184 */
185185type ObtainDocumentPathType < PathValueType , TypeKey extends string = DefaultTypeKey > = ResolvePathType <
186- PathValueType extends PathWithTypePropertyBaseType < TypeKey > ? PathValueType [ TypeKey ] : PathValueType ,
187- PathValueType extends PathWithTypePropertyBaseType < TypeKey > ? Omit < PathValueType , TypeKey > : { } ,
186+ PathValueType extends PathWithTypePropertyBaseType < TypeKey >
187+ ? PathValueType [ TypeKey ] extends PathWithTypePropertyBaseType < TypeKey >
188+ ? PathValueType
189+ : PathValueType [ TypeKey ]
190+ : PathValueType ,
191+ PathValueType extends PathWithTypePropertyBaseType < TypeKey >
192+ ? PathValueType [ TypeKey ] extends PathWithTypePropertyBaseType < TypeKey >
193+ ? { }
194+ : Omit < PathValueType , TypeKey >
195+ : { } ,
188196TypeKey ,
189197TypeHint < PathValueType >
190198> ;
You can’t perform that action at this time.
0 commit comments