diff --git a/packages/legacy-compat/src/utils.ts b/packages/legacy-compat/src/utils.ts index b7fc485f60f..552002ca035 100644 --- a/packages/legacy-compat/src/utils.ts +++ b/packages/legacy-compat/src/utils.ts @@ -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