Skip to content

Documentation / @ember-data/legacy-compat / utils / formattedType

ts
function formattedType<T>(type): T;

Defined in: utils.ts:106

Converts a potentially unnormalized type into the format expected by our EmberData Cache. Currently this is singular-dasherized.

you should not rely on this function to give you an exact format for display purposes. Formatting for display should be handled differently if the exact format matters.

Asserts invalid types (undefined, null, '') in dev.

Usage

js
import formattedType from 'soxhub-client/helpers/formatted-type';

formattedType('post'); // => 'post'
formattedType('posts'); // => 'post'
formattedType('Posts'); // => 'post'
formattedType('post-comment'); // => 'post-comment'
formattedType('post-comments'); // => 'post-comment'
formattedType('post_comment'); // => 'post-comment'
formattedType('postComment'); // => 'post-comment'
formattedType('PostComment'); // => 'post-comment'

Type Parameters

T

T extends string

Parameters

type

the potentially un-normalized type

string | T

Returns

T

the normalized type

Released under the MIT License.