Skip to content

Commit

Permalink
fix(urns): pass NID and NSS to base class type parameters
Browse files Browse the repository at this point in the history
‘URNSpace’ base class methods were using ‘string‘ type by default
which was preventing type inference that would be achieved by
predicate methods like ‘URNSpace.is’.
  • Loading branch information
szkl committed Jan 21, 2024
1 parent 9f7ddd9 commit 00c6ddd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/urns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class TypedComponentsURNSpace<
RCompType extends CompType = CompType,
QCompType extends CompType = CompType,
URNType extends BaseURN<NID, NSS> = BaseURN<NID, NSS>
> extends URNSpace<string, string, string> {
> extends URNSpace<NID, NSS, string> {
constructor(nid: NID, options?: Partial<SpaceOptions<NSS, string>>) {
super(nid, options)
}
Expand Down Expand Up @@ -100,7 +100,7 @@ class TypedComponentsURNSpace<
}

componentizedParse(
urn: `urn:${string}:${string}${string}`
urn: `urn:${NID}:${NSS}${string}`
): ParsedComponentizedURN<string, string, RCompType, QCompType> {
const s = super.parse(urn)
let rcomps = null
Expand Down Expand Up @@ -128,7 +128,7 @@ class TypedComponentsURNSpace<
return result
}

getBaseURN(urn: `urn:${string}:${string}${string}`): URNType {
getBaseURN(urn: `urn:${NID}:${NSS}${string}`): URNType {
const s = super.parse(urn)
return `urn:${s.nid}:${s.nss}` as URNType
}
Expand Down

0 comments on commit 00c6ddd

Please sign in to comment.