From cc4070bf2deda10168431e007dd9cb60af532ae2 Mon Sep 17 00:00:00 2001 From: rsek <5354757+rsek@users.noreply.github.com> Date: Wed, 17 Jan 2024 12:34:31 -0800 Subject: [PATCH] try to infer ancestor key substring --- pkg/nodejs/@datasworn/core/dist/IdParser.d.ts | 2 +- src/pkg-core/IdParser.ts | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/nodejs/@datasworn/core/dist/IdParser.d.ts b/pkg/nodejs/@datasworn/core/dist/IdParser.d.ts index f89f720a2..9ffb4b994 100644 --- a/pkg/nodejs/@datasworn/core/dist/IdParser.d.ts +++ b/pkg/nodejs/@datasworn/core/dist/IdParser.d.ts @@ -325,7 +325,7 @@ interface RecursiveCollectableId = T extends Strings.RecursiveCollectableId ? RecursiveCollectableId & { + type FromString = T extends `${infer RulesPackage}${CONST.Sep}${infer Type extends TypeElements.Collectable.Recursive}${infer AncestorPath extends `${CONST.Sep}${string}`}${CONST.Sep}${infer Key}` ? RecursiveCollectableId, Key> & { id: T; } : never; } diff --git a/src/pkg-core/IdParser.ts b/src/pkg-core/IdParser.ts index a04cdcc6a..796f98412 100644 --- a/src/pkg-core/IdParser.ts +++ b/src/pkg-core/IdParser.ts @@ -1051,13 +1051,15 @@ interface RecursiveCollectableId< namespace RecursiveCollectableId { export type FromString = - T extends Strings.RecursiveCollectableId< - infer RulesPackage, - infer Type, - infer AncestorKeys, - infer Key - > - ? RecursiveCollectableId & { + T extends `${infer RulesPackage}${CONST.Sep}${infer Type extends + TypeElements.Collectable.Recursive}${infer AncestorPath extends + `${CONST.Sep}${string}`}${CONST.Sep}${infer Key}` + ? RecursiveCollectableId< + RulesPackage, + Type, + Utils.Split, + Key + > & { id: T } : never