-
-
Notifications
You must be signed in to change notification settings - Fork 679
Expand file tree
/
Copy pathscreaming-snake-case.d.ts
More file actions
31 lines (24 loc) · 1.04 KB
/
screaming-snake-case.d.ts
File metadata and controls
31 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type {_DefaultDelimiterCaseOptions} from './delimiter-case.d.ts';
import type {ApplyDefaultOptions} from './internal/index.d.ts';
import type {SnakeCase} from './snake-case.d.ts';
import type {WordsOptions} from './words.d.ts';
/**
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';
const someVariableWithPunctuation: ScreamingSnakeCase<'div.card::after', {splitOnPunctuation: true}> = 'DIV_CARD_AFTER';
```
@category Change case
@category Template literal
*/
export type ScreamingSnakeCase<
Value,
Options extends WordsOptions = {},
> = Value extends string
? Uppercase<SnakeCase<Value, ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>>
: Value;
export {};