Skip to content

Instantly share code, notes, and snippets.

@sebinsua
Last active August 3, 2022 14:44
Show Gist options
  • Save sebinsua/4ad2feb86e64e3fd12b5d40668b61f98 to your computer and use it in GitHub Desktop.
Save sebinsua/4ad2feb86e64e3fd12b5d40668b61f98 to your computer and use it in GitHub Desktop.
type LeftRight = 'left' | 'right';
type LeftRightNet = 'left' | 'right' | 'net';
type ExpandNumericFields<Str> = Str extends `${infer Prefix}_numeric` ? `${Prefix}_numeric_${LeftRightNet}` : Str extends 'weight' ? `weight_${LeftRightNet}` : Str extends string ? `${Str}_${LeftRight}` : never;
type T1 = ExpandNumericFields<'base_numeric'>
type T2 = ExpandNumericFields<'weight'>
type T3 = ExpandNumericFields<'numeric_exposure'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment