annotations-design-patterns
    Preparing search index...

    Function IterableOver

    • Patrón Iterator: hace la clase iterable (for...of, spread, Array.from) delegando en la propiedad iterable indicada (normalmente un array interno).

      Symbol.iterator existe en runtime; para que el sistema de tipos lo vea, castea con WithIterator<Clase, Elemento> (los decoradores TC39 no pueden ampliar el tipo de la clase, igual que ocurre con @Adapt).

      Parameters

      • property: string

      Returns <T extends new (...args: any[]) => object>(
          target: T,
          context: ClassDecoratorContext<T>,
      ) => T

      @IterableOver('items')
      class Playlist {
      items: Song[] = [];
      }
      for (const song of playlist as WithIterator<Playlist, Song>) { ... }