Skip to content

Commit

Permalink
try to infer ancestor key substring
Browse files Browse the repository at this point in the history
  • Loading branch information
rsek committed Jan 17, 2024
1 parent 7276776 commit cc4070b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/nodejs/@datasworn/core/dist/IdParser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ interface RecursiveCollectableId<RulesPackage extends string = string, Type exte
get ancestorCollectionKeys(): AncestorKeys;
}
declare namespace RecursiveCollectableId {
type FromString<T extends Strings.RecursiveCollectableId> = T extends Strings.RecursiveCollectableId<infer RulesPackage, infer Type, infer AncestorKeys, infer Key> ? RecursiveCollectableId<RulesPackage, Type, AncestorKeys, Key> & {
type FromString<T extends Strings.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<AncestorPath>, Key> & {
id: T;
} : never;
}
Expand Down
16 changes: 9 additions & 7 deletions src/pkg-core/IdParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,13 +1051,15 @@ interface RecursiveCollectableId<

namespace RecursiveCollectableId {
export type FromString<T extends Strings.RecursiveCollectableId> =
T extends Strings.RecursiveCollectableId<
infer RulesPackage,
infer Type,
infer AncestorKeys,
infer Key
>
? RecursiveCollectableId<RulesPackage, Type, AncestorKeys, Key> & {
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<AncestorPath>,
Key
> & {
id: T
}
: never
Expand Down

0 comments on commit cc4070b

Please sign in to comment.