Skip to content

Commit

Permalink
use separator constant instad of hardcoding
Browse files Browse the repository at this point in the history
  • Loading branch information
rsek committed Jan 17, 2024
1 parent 7e67a39 commit cb128cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions pkg/nodejs/@datasworn/core/dist/IdParser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ interface CollectionId<RulesPackage extends string = string, Subtype extends Typ
declare namespace CollectionId {
/** A lenient typing for a parsed ID representing any collection object. */
interface Any extends IdParser.Any {
readonly id: `${string}/${TypeElements.Collection}/${TypeElements.Collectable.Any}/${string}`;
readonly id: `${string}${CONST.Sep}${TypeElements.Collection}${CONST.Sep}${TypeElements.Collectable.Any}${CONST.Sep}${string}`;
readonly ancestorCollectionKeys: string[];
readonly typeRootKey: TypeElements.Collectable.Any;
readonly elements: [
Expand Down Expand Up @@ -269,7 +269,7 @@ declare class NonCollectableId<RulesPackage extends string = string, Type extend
constructor(rulesPackage: RulesPackage, type: Type, key: Key);
}
declare namespace NonCollectableId {
type FromString<T extends Strings.NonCollectableId> = T extends `${infer RulesPackage}/${infer Type extends TypeElements.NonCollectable}/${infer Key}` ? NonCollectableId<RulesPackage, Type, Key> & {
type FromString<T extends Strings.NonCollectableId> = T extends `${infer RulesPackage}${CONST.Sep}${infer Type extends TypeElements.NonCollectable}${CONST.Sep}${infer Key}` ? NonCollectableId<RulesPackage, Type, Key> & {
id: T;
} : never;
}
Expand Down Expand Up @@ -297,7 +297,7 @@ interface NonRecursiveCollectableId<RulesPackage extends string, Type extends Ty
get id(): Strings.NonRecursiveCollectableId<RulesPackage, Type, ParentKey, Key>;
}
declare namespace NonRecursiveCollectableId {
type FromString<T extends Strings.NonRecursiveCollectableId> = T extends `${infer RulesPackage}/${infer Type extends TypeElements.Collectable.NonRecursive}/${infer ParentKey}/${infer Key}` ? NonRecursiveCollectableId<RulesPackage, Type, ParentKey, Key> & {
type FromString<T extends Strings.NonRecursiveCollectableId> = T extends `${infer RulesPackage}${CONST.Sep}${infer Type extends TypeElements.Collectable.NonRecursive}${CONST.Sep}${infer ParentKey}${CONST.Sep}${infer Key}` ? NonRecursiveCollectableId<RulesPackage, Type, ParentKey, Key> & {
id: T;
} : never;
}
Expand All @@ -311,7 +311,7 @@ interface NonRecursiveCollectionId<RulesPackage extends string, Subtype extends
get id(): Strings.NonRecursiveCollectionId<RulesPackage, Subtype, Key>;
}
declare namespace NonRecursiveCollectionId {
type FromString<T extends Strings.NonRecursiveCollectionId> = T extends `${infer RulesPackage}/${TypeElements.Collection}/${infer Subtype extends TypeElements.Collectable.NonRecursive}/${infer Key}` ? NonRecursiveCollectionId<RulesPackage, Subtype, Key> & {
type FromString<T extends Strings.NonRecursiveCollectionId> = T extends `${infer RulesPackage}${CONST.Sep}${TypeElements.Collection}${CONST.Sep}${infer Subtype extends TypeElements.Collectable.NonRecursive}${CONST.Sep}${infer Key}` ? NonRecursiveCollectionId<RulesPackage, Subtype, Key> & {
id: T;
} : never;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ interface RecursiveCollectionId<RulesPackage extends string = string, Subtype ex
get isRecursive(): true;
}
declare namespace RecursiveCollectionId {
type FromString<T extends Strings.RecursiveCollectionId> = T extends `${infer RulesPackage}/${TypeElements.Collection}/${infer Subtype extends TypeElements.Collectable.Recursive}/${string}` ? RecursiveCollectionId<RulesPackage, Subtype, Utils.ExtractAncestorCollectionPathElements<T>, Utils.ExtractKey<T>> & {
type FromString<T extends Strings.RecursiveCollectionId> = T extends `${infer RulesPackage}${CONST.Sep}${TypeElements.Collection}${CONST.Sep}${infer Subtype extends TypeElements.Collectable.Recursive}${CONST.Sep}${string}` ? RecursiveCollectionId<RulesPackage, Subtype, Utils.ExtractAncestorCollectionPathElements<T>, Utils.ExtractKey<T>> & {
id: T;
} : never;
interface Options<T extends Strings.RecursiveCollectionId> extends CollectionId.Options<T> {
Expand Down
18 changes: 9 additions & 9 deletions src/pkg-core/IdParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ interface CollectionId<
namespace CollectionId {
/** A lenient typing for a parsed ID representing any collection object. */
export interface Any extends IdParser.Any {
readonly id: `${string}/${TypeElements.Collection}/${TypeElements.Collectable.Any}/${string}`
readonly id: `${string}${CONST.Sep}${TypeElements.Collection}${CONST.Sep}${TypeElements.Collectable.Any}${CONST.Sep}${string}`
readonly ancestorCollectionKeys: string[]
readonly typeRootKey: TypeElements.Collectable.Any
readonly elements: [
Expand Down Expand Up @@ -911,8 +911,8 @@ class NonCollectableId<
}
namespace NonCollectableId {
export type FromString<T extends Strings.NonCollectableId> =
T extends `${infer RulesPackage}/${infer Type extends
TypeElements.NonCollectable}/${infer Key}`
T extends `${infer RulesPackage}${CONST.Sep}${infer Type extends
TypeElements.NonCollectable}${CONST.Sep}${infer Key}`
? NonCollectableId<RulesPackage, Type, Key> & { id: T }
: never
}
Expand Down Expand Up @@ -973,8 +973,8 @@ interface NonRecursiveCollectableId<
}
namespace NonRecursiveCollectableId {
export type FromString<T extends Strings.NonRecursiveCollectableId> =
T extends `${infer RulesPackage}/${infer Type extends
TypeElements.Collectable.NonRecursive}/${infer ParentKey}/${infer Key}`
T extends `${infer RulesPackage}${CONST.Sep}${infer Type extends
TypeElements.Collectable.NonRecursive}${CONST.Sep}${infer ParentKey}${CONST.Sep}${infer Key}`
? NonRecursiveCollectableId<RulesPackage, Type, ParentKey, Key> & {
id: T
}
Expand Down Expand Up @@ -1008,8 +1008,8 @@ interface NonRecursiveCollectionId<

namespace NonRecursiveCollectionId {
export type FromString<T extends Strings.NonRecursiveCollectionId> =
T extends `${infer RulesPackage}/${TypeElements.Collection}/${infer Subtype extends
TypeElements.Collectable.NonRecursive}/${infer Key}`
T extends `${infer RulesPackage}${CONST.Sep}${TypeElements.Collection}${CONST.Sep}${infer Subtype extends
TypeElements.Collectable.NonRecursive}${CONST.Sep}${infer Key}`
? NonRecursiveCollectionId<RulesPackage, Subtype, Key> & { id: T }
: never
}
Expand Down Expand Up @@ -1168,8 +1168,8 @@ interface RecursiveCollectionId<
}
namespace RecursiveCollectionId {
export type FromString<T extends Strings.RecursiveCollectionId> =
T extends `${infer RulesPackage}/${TypeElements.Collection}/${infer Subtype extends
TypeElements.Collectable.Recursive}/${string}`
T extends `${infer RulesPackage}${CONST.Sep}${TypeElements.Collection}${CONST.Sep}${infer Subtype extends
TypeElements.Collectable.Recursive}${CONST.Sep}${string}`
? RecursiveCollectionId<
RulesPackage,
Subtype,
Expand Down

0 comments on commit cb128cd

Please sign in to comment.