Skip to content

Commit

Permalink
feat: add expectId util (#9400)
Browse files Browse the repository at this point in the history
* feat: add expectId util

* fix lint
  • Loading branch information
runspired authored May 11, 2024
1 parent 6c492b8 commit b9729ed
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/legacy-compat/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ export function formattedId(id: string | number | null): string | null {
return id === null ? null : String(id);
}

export function expectId(id: string | number): string;
export function expectId(id: null): never;
export function expectId(id: string | number | null): string {
AssertFn('expectId: id must not be null', id !== null);

return formattedId(id);
}

/**
* Compares two types for strict equality, converting them to
* the format expected by the EmberData Cache to ensure
Expand Down

0 comments on commit b9729ed

Please sign in to comment.