Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

268
Vistas
Operator precedence in typescript shorthand array notation: typeof unknown[]

In puppeteer's declaration file types.d.ts, I came across the following type definition:

  export declare type EvaluateFunc<T extends unknown[]>
      = (...params: InnerParams<T>) => Awaitable<unknown>;


  export declare type InnerParams<T extends unknown[]> = {
      [K in keyof T]: FlattenHandle<T[K]>;
  };

My question is in regards to <T extends unknown[]> and the operator precedence for typeof and [] .. is T extending unknown? Or is it extending unknown[], and, if it's the latter, then is the keyof operator able to be used on type Array? If so, does typescript take this to mean 'any numeric property of an array'? (aka, array item).

Assuming it's the former, and T is extending unknown, then how does the array shorthand [] operator affect the typeof operator? Just for context, here is the definition for FlattenHandle:

export declare type FlattenHandle<T> = T extends HandleOr<infer U> ? U : never;

Sub-question: export declare -- I've taken a break from TS for half a year and now that I'm back, I'm seeing these more and more. Is it a recent addition? What are we trying to say here? That, the type exists but was not exported in the source? One of the affects of this export declare is that my IDE (PHPStorm) thinks that the class ElementHandle exists, and even appears in console.log, but, if you Console.log(ElementHandle) you will get undefined:

export declare class ElementHandle<ElementType extends Node = Element> extends JSHandle<ElementType> {
    #private;
    // ...

Thank you for your help.

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda