New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Types] da1aea152ef929bd33a54a462583a79265831d58 broke HydratedDocument
with Record
inputs
#13094
Comments
i am also running into a weird issue where as long as there is a |
for now i have been running with something like: MergeType<
Require_id<DocType>,
TOverrides extends Record<string, never> ? {} :
IfAny<TOverrides, {}>
> (not handling Some more information about the previously mentioned
|
…ent TOverrides parameter Fix #13094
fix(types): handle `Record<string, never>` as value for HydratedDocument TOverrides parameter
Prerequisites
Mongoose version
7.0.0
Node.js version
does not apply
MongoDB server version
does not apply
Typescript version (if applicable)
4.9.5
Description
i have noticed that since da1aea1 (usage of
MergeType
) results in all thing usingHydratedDocument
withRecord<string, any>
(orunknown
ornever
instead ofany
) results in all properties not being suggested, and when written out completely those types become whatever is set as the second parameter toRecord
reverting to before da1aea1 fixes it
why does this matter?
because typescript-eslint has rule
@typescript-eslint/ban-types
, which is at levelerror
by default when using preset@typescript-eslint/recommended
, which suggests to instead use:object
instead.unknown
instead.Record<string, never>
insteadSteps to Reproduce
Create a new model with either
TInstanceMethods
orTVirtuals
set toRecord<string, any>
(or instead ofany
alsounknown
ornever
)Or directly create a
HydratedDocument
likemongoose.HydratedDocument<DocType, Record<string, never>>
see Reproduction repository & branch
Expected Behavior
to allow usage of
Record<string, never>
at least, orRecord<string, any>
like before da1aea1For anyone just looking for a workaround to have it working: use
{}
, but with disabling lint for the line// eslint-disable-next-line @typescript-eslint/ban-types
The text was updated successfully, but these errors were encountered: