Skip to content

Conversation

@vkarpov15
Copy link
Collaborator

@vkarpov15 vkarpov15 commented Jan 4, 2023

Re: #12807

Summary

Really not my favorite PR. I haven't been able to figure out exactly why this issue happens, I suspect because there's some self-referential issues that pop up because methods, virtuals, and statics use the inferred document type, and the inferred document type relies on schema options. But this is at least sufficient to unblock anyone using timestamp type inference.

We should consider deprecating timestamps type inference for 7.0 if we don't come up with a better solution. I'm going to take some time to come up with a minimal repro script for the TypeScript team. I don't expect this to end up being a bug that TS is willing to fix. But might as well so we can at least be certain that we're trying to do something TypeScript doesn't support.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

i personally think it is somehow (again) related to

type ObtainSchemaGeneric<TSchema, alias extends 'EnforcedDocType' | 'M' | 'TInstanceMethods' | 'TQueryHelpers' | 'TVirtuals' | 'TStaticMethods' | 'TSchemaOptions' | 'DocType'> =
TSchema extends Schema<infer EnforcedDocType, infer M, infer TInstanceMethods, infer TQueryHelpers, infer TVirtuals, infer TStaticMethods, infer TSchemaOptions, infer DocType>
? {
EnforcedDocType: EnforcedDocType;
M: M;
TInstanceMethods: TInstanceMethods;
TQueryHelpers: TQueryHelpers;
TVirtuals: TVirtuals;
TStaticMethods: TStaticMethods;
TSchemaOptions: TSchemaOptions;
DocType: DocType;
}[alias]
: unknown;

but i havent been able to debug this further because typescript does not show the whole type or allows debugging type stages (like a break-point)

@vkarpov15
Copy link
Collaborator Author

I think so as well. There's some circular reference stuff that's probably confusing TypeScript. In the meantime, I'll merge this to unblock.

@vkarpov15 vkarpov15 merged commit a2af383 into master Jan 6, 2023
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-12807 branch January 6, 2023 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants