INNER CODE UNIT · TypeScript

GEnum

stepci/garph · src/index.ts:357

class GEnum<N extends string, T extends readonly string[] | TSEnumType> extends Type<readonly string[], 'Enum'> {
  declare _name: N
  declare _inner: T extends readonly string[] ? T[number] : keyof T

  constructor(name: string, shape: T) {
    super()

    let enumShape: readonly string[]
    if (Array.isArray(shape)) {
      enumShape = shape
    } else {
      enumShape = getEnumProperties(shape as TSEnumType)
    }

    this.typeDef = {
      name,
      type: 'Enum',
      shape: enumShape

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…