types: handle compiling with exactOptionalPropertyTypes#16277
Merged
types: handle compiling with exactOptionalPropertyTypes#16277
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Mongoose’s published TypeScript declaration files to compile cleanly when consumers enable exactOptionalPropertyTypes (and skipLibCheck: false), and adds a dedicated type-test setup to continuously validate that configuration.
Changes:
- Fix
TS2344errors underexactOptionalPropertyTypesby excludingundefinedfromOptions['enum']when threading enum options through recursive path-type resolution. - Add a new
test/types/exactOptionalPropertyTypesfolder with its owntsconfig.jsonthat enablesexactOptionalPropertyTypes+skipLibCheck: false. - Expand
tstyche’s test glob to include nestedtest/types/**type tests.
Reviewed changes
Copilot reviewed 3 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| types/inferschematype.d.ts | Removes undefined from Options['enum'] in recursive ResolvePathType calls to satisfy SchemaTypeOptions constraints under exact optional semantics. |
| types/inferrawdoctype.d.ts | Same enum/undefined exclusion fix for ResolveRawPathType recursion. |
| types/inferhydrateddoctype.d.ts | Same enum/undefined exclusion fix for hydrated doc path inference recursion. |
| tstyche.json | Updates test file matching to include nested test/types/**/*.test.* files. |
| test/types/exactOptionalPropertyTypes/tsconfig.json | Adds a stricter TS config for this sub-suite (exactOptionalPropertyTypes: true, skipLibCheck: false). |
| test/types/exactOptionalPropertyTypes/exactOptionalPropertyTypes.test.ts | Adds a type test to ensure Mongoose’s .d.ts files type-check under the stricter config. |
Contributor
|
It is more involving, but perhaps it is worth setting I can do this next week (after my vacation). |
Collaborator
Author
|
That seems reasonable. I'll merge this for now to unblock people. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #16273
Summary
Fix compiling with TypeScript's
exactOptionalPropertyTypesflag. I also added a separate test folder with a separatetsconfig.jsonfor testing compiling with that flag set.Examples