Skip to content

Commit

Permalink
Fix __UnsetDocument case in FromUuidValidate
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeAbby committed Jan 3, 2025
1 parent a4e4c50 commit e329c89
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/foundry/client/core/utils.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ type FromUuid<Uuid extends string> = Uuid extends `${string}.${string}.${infer R
? Document.ConfiguredInstanceForName<DocumentType>
: InvalidUuid;

// TODO(LukeAbby): The condition `ConcreteDocument extends __UnsetDocument` will not be necessary once `Document.Any` is more type safe.
// TODO(LukeAbby): The usage of `Document.Type` when it's unset will not be necessary once `Document.Any` is more type safe.
type FromUuidValidate<
ConcreteDocument extends Document.Any,
Uuid extends string,
> = ConcreteDocument extends __UnsetDocument
? MustBeValidUuid<Uuid, Document.Type> // Only necessary because `Document.Any` is of type `any` not `Document.Type`.
: MustBeValidUuid<Uuid, ConcreteDocument["documentName"]>;
> = __UnsetDocument extends ConcreteDocument
? MustBeValidUuid<Uuid, Document.Type>
: string extends Uuid
? string
: MustBeValidUuid<Uuid, ConcreteDocument["documentName"]>;

declare global {
/**
Expand Down

0 comments on commit e329c89

Please sign in to comment.