mirror of
https://github.com/sindresorhus/type-fest.git
synced 2026-02-01 15:59:43 +00:00
25 lines
714 B
TypeScript
25 lines
714 B
TypeScript
import type {SnakeCase} from './snake-case';
|
|
import type {WordsOptions} from './words';
|
|
|
|
/**
|
|
Convert a string literal to screaming-snake-case.
|
|
|
|
This can be useful when, for example, converting a camel-cased object property to a screaming-snake-cased SQL column name.
|
|
|
|
@example
|
|
```
|
|
import type {ScreamingSnakeCase} from 'type-fest';
|
|
|
|
const someVariable: ScreamingSnakeCase<'fooBar'> = 'FOO_BAR';
|
|
const someVariableNoSplitOnNumbers: ScreamingSnakeCase<'p2pNetwork', {splitOnNumbers: false}> = 'P2P_NETWORK';
|
|
|
|
```
|
|
|
|
@category Change case
|
|
@category Template literal
|
|
*/
|
|
export type ScreamingSnakeCase<
|
|
Value,
|
|
Options extends WordsOptions = {},
|
|
> = Value extends string ? Uppercase<SnakeCase<Value, Options>> : Value;
|