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

266
Views
cómo referirse a un campo anidado en un objeto en Typescript

Quiero escribir un tipo que se genera automáticamente en función de los datos del usuario

 type CleanPropType = typeof Array | typeof Object | typeof Function | typeof Boolean | typeof String; type Prop = { type: CleanPropType, default?:any } // define the type of properties for all components type Props = { [name:string]:Prop } // define properties for a specific component let customComponentProps = { name:{ type:String } } type customComponentGenerator<T extends Props> = { [name in keyof T]: ReturnType<T[name].type> // here error. WHY ? } // define the type of properties for a specific component // but here an error occurs when accessing the "type" field type customComponent = Partial<customComponentGenerator<typeof customComponentProps>>; // I need the resulting type to work correctly let userComponentProps : customComponent = { name:'ComponentNameString', } // ok let userComponentProps2 : custromComponent = { name:false, // must be err otherField: 'str' // // must be err }

el principal problema es que no puedo acceder al campo anidado 'tipo', aunque T extiende Props. gracias

Enlace

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