Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!