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

139
Views
Need explanations about this Typescript code snippet?

The type in the constructor has two default values active or finished. But I think there should be a parameter type such as number or string.

Any explanation about this?

class ProjectList{
    templateElement: HTMLTemplateElement;

    constructor(private type: 'active' | 'finished'){
    
    }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are declaring that type is a string restricted to only possible 2 values. A default can also be declared, like this:

class ProjectList{
    templateElement: HTMLTemplateElement;

    constructor(private type: 'active' | 'finished' = 'active'){
    
    }
}
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!