diff --git a/typeid/typeid-js/package.json b/typeid/typeid-js/package.json index 1cac2de..b950361 100644 --- a/typeid/typeid-js/package.json +++ b/typeid/typeid-js/package.json @@ -1,6 +1,6 @@ { "name": "typeid-js", - "version": "1.1.0", + "version": "1.2.0", "description": "Official implementation of the TypeID specification in TypeScript. TypeIDs are type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs", "keywords": [ "typeid", diff --git a/typeid/typeid-js/src/typeid.ts b/typeid/typeid-js/src/typeid.ts index df9e796..599a30e 100644 --- a/typeid/typeid-js/src/typeid.ts +++ b/typeid/typeid-js/src/typeid.ts @@ -41,11 +41,11 @@ export class TypeID { return stringify(this.toUUIDBytes()); } - public toString(): `${T}_${string}` | string { + public toString(): T extends "" ? string : `${T}_${string}` { if (this.prefix === "") { - return this.suffix; + return this.suffix as T extends "" ? string : `${T}_${string}`; } - return `${this.prefix}_${this.suffix}`; + return `${this.prefix}_${this.suffix}` as T extends "" ? string : `${T}_${string}`; } static fromString(