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() {
1645
1645
function gh14879 ( ) {
1646
1646
Schema . Types . String . setters . push ( ( val ?: unknown ) => typeof val === 'string' ? val . trim ( ) : val ) ;
1647
1647
}
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;
183
183
* @param {TypeKey } TypeKey A generic refers to document definition.
184
184
*/
185
185
type 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
+ : { } ,
188
196
TypeKey ,
189
197
TypeHint < PathValueType >
190
198
> ;
You can’t perform that action at this time.
0 commit comments