Type alias CqlType2TSType<T, Def>

CqlType2TSType<T, Def>: T extends keyof CqlNonGenericType2TSTypeDict
    ? CqlNonGenericType2TSTypeDict[T]
    : T extends keyof CqlGenericType2TSTypeDict<Def>
        ? CqlGenericType2TSTypeDict<Def>[T]
        : unknown

Converts a CQL type to its TS equivalent. If the type isn't some collection type, the second typeparam is irrelevant.

Type Parameters

  • T extends string
  • Def

Example

// number
CqlType2TSType<'int', ...>

// DataAPIDuration
CqlType2TSType<'duration', ...>

// Map<string, number>
CqlType2TSType<'map', { keyType: 'text', valueType: 'int' }>

// unknown
CqlType2TSType<'idk', ...>

// TypeErr<'Invalid generics definition for \'map\'; should have keyType and valueType set as scalar CQL types (e.g. \'text\')'>
CqlType2TSType<'map', 123>

See

  • InferTableSchema
  • InferTablePrimaryKey