编辑 | blame | 历史 | 原始文档
import {DelimiterCase} from './delimiter-case';

/**
Convert a string literal to snake-case.

This can be useful when, for example, converting a camel-cased object property to a snake-cased SQL column name.

@example
```
import {SnakeCase} from 'type-fest';

// Simple

const someVariable: SnakeCase<'fooBar'> = 'foo_bar';

// Advanced

type SnakeCasedProps = {
	[K in keyof T as SnakeCase]: T[K]
};

interface ModelProps {
	isHappy: boolean;
	fullFamilyName: string;
	foo: number;
}

const dbResult: SnakeCasedProps = {
	'is_happy': true,
	'full_family_name': 'Carla Smith',
	foo: 123
};
```
*/
export type SnakeCase = DelimiterCase;