about summary refs log tree commit diff
path: root/src/alf/types.ts
blob: dd8d816d2b61bc2139077e4aa5752259a4c91f5d (plain) (blame)
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
import {StyleProp, ViewStyle, TextStyle} from 'react-native'

type LiteralToCommon<T extends PropertyKey> = T extends number
  ? number
  : T extends string
  ? string
  : T extends symbol
  ? symbol
  : never

/**
 * @see https://stackoverflow.com/questions/68249999/use-as-const-in-typescript-without-adding-readonly-modifiers
 */
export type Mutable<T> = {
  -readonly [K in keyof T]: T[K] extends PropertyKey
    ? LiteralToCommon<T[K]>
    : Mutable<T[K]>
}

export type TextStyleProp = {
  style?: StyleProp<TextStyle>
}

export type ViewStyleProp = {
  style?: StyleProp<ViewStyle>
}