Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda