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

152
Vistas
Computed interface values in TypeScript?

So basically, I was looking around discordjs's typings folder and found this:

export interface ClientEvents {
  ...
  messageCreate: [message: Message] <- what?
  messageDelete: [message: Message | PartialMessage]
}

What exactly are they trying to do here? I've heard of index signatures, like in this example here:

interface Foo {
  [bar: string]: any
}

But I've never seen any syntax that resembles this in both TS and JS.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Credits to jonrsharpe's comment under the question. The syntax mentioned was a variation of a tuple in TypeScript 4.0 which includes labels:

Regular tuple:

// has no indication of parameter names
type Range = [number, number] 

Labelled tuple:

type Range = [start: number, end: number] 
// spreading this labelled tuple in a function's parameters...
function getRange(...range: Range) 

// ... results in the following at compile time:
function getRange(start: number, end: number)

Very cool!

about 4 years ago · Juan Pablo Isaza Denunciar
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