You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
7.6.7
Node.js version
18.20.3
MongoDB server version
7.0.12
Typescript version (if applicable)
5.2.2
Description
It looks like the typescript signature for SchemaTypes.path().cast require some (what appear to be) optional fields.
I wanted to create a subdocument instance without creating a model. With reference to #9076,
I had
which works exactly as intended with the //@ts-ignore, but otherwise gives me a type error. Upon further examination,
it appears that
doc and init are required fields in the typescript signature, whereas they seem to be optional in a lot of the documentation I've seen.
This is my top-level schema file:
Please let me know if I'm mistaken somewhere, many thanks!!
Steps to Reproduce
Please see above.
Expected Behavior
Optional (?) fields should be required by typescript signature
The text was updated successfully, but these errors were encountered:
Prerequisites
Mongoose version
7.6.7
Node.js version
18.20.3
MongoDB server version
7.0.12
Typescript version (if applicable)
5.2.2
Description
It looks like the typescript signature for SchemaTypes.path().cast require some (what appear to be) optional fields.
I wanted to create a subdocument instance without creating a model. With reference to #9076,
I had
![image](https://private-user-images.githubusercontent.com/35291549/348793447-d575482b-4d18-4b7d-a998-b717897e5535.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEyNjYwNzUsIm5iZiI6MTcyMTI2NTc3NSwicGF0aCI6Ii8zNTI5MTU0OS8zNDg3OTM0NDctZDU3NTQ4MmItNGQxOC00YjdkLWE5OTgtYjcxNzg5N2U1NTM1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE4VDAxMjI1NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE1OTBmMzJmYzkxZTY1YTIxNzJiNzc3NzBjMjM5YjViMDIyNjI3ZThjYmUzM2YzNTJkZjY5YzYxMGJkNzdiNzUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.drVPxvADiAuKrFH_5PEwafuHMI5UQ5zofy6CLtsHcH8)
which works exactly as intended with the //@ts-ignore, but otherwise gives me a type error. Upon further examination,
![image](https://private-user-images.githubusercontent.com/35291549/348793675-f0f45d6f-4b70-45ea-9025-c61a04b39f25.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEyNjYwNzUsIm5iZiI6MTcyMTI2NTc3NSwicGF0aCI6Ii8zNTI5MTU0OS8zNDg3OTM2NzUtZjBmNDVkNmYtNGI3MC00NWVhLTkwMjUtYzYxYTA0YjM5ZjI1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE4VDAxMjI1NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM5MDMxNmIxNjAzODk2MDRmMGYyNjkwNWQ5MzE0OTBiZTU0MTA4N2RlOGE0YmZjYjU1MWU5ZTJkMTk2OGU2MTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ura0Nvt45UCzu0r3TObwKGW0iD-oBuHxEhUADMiXoT8)
it appears that
doc and init are required fields in the typescript signature, whereas they seem to be optional in a lot of the documentation I've seen.
This is my top-level schema file:
![image](https://private-user-images.githubusercontent.com/35291549/348794971-2f1e7d11-1d9d-4634-b725-2a0b06f8e47d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEyNjYwNzUsIm5iZiI6MTcyMTI2NTc3NSwicGF0aCI6Ii8zNTI5MTU0OS8zNDg3OTQ5NzEtMmYxZTdkMTEtMWQ5ZC00NjM0LWI3MjUtMmEwYjA2ZjhlNDdkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE4VDAxMjI1NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQxMDEyNzFjYzI5YTQ3MjUwM2U3MzFmNWM1MTEzOGQ5OTRkNTQxMWNjZGZiYWM3ZTA2OTljZDNkOTZjYTRhZDYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7M1rDgVwqcJJ6U6TlMlJeFOybDOKRIU62yOCNqIVO6k)
Please let me know if I'm mistaken somewhere, many thanks!!
Steps to Reproduce
Please see above.
Expected Behavior
Optional (?) fields should be required by typescript signature
The text was updated successfully, but these errors were encountered: