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

263
Views
Extending recursive Typescript interfaces

I'm using the TS type for JSON Schema: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/json-schema/index.d.ts

Short version:

interface JSONSchema4 {
  properties?: {
    [k: string]: JSONSchema4;
  } | undefined;
}

This type is recursive. I'd like to extend this type with custom properties. E.g. currently, something like this doesn't match the type:

{ instanceof: 'Date' }

I'd like to add instanceof?: string as a field to JSONSchema4. Is this possible?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In TypeScript, interfaces are open, unlike types that are closed. So, you can add your keyword simply by declaring an interface with the same name that contains your keyword. That interface effectively extends the original type.

interface JSONSchema4 {
  instanceof?: string;
}
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!