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

135
Views
Reemplazo de propiedades en texto mecanografiado

Estoy tratando de reemplazar propiedades en un tipo de mecanografiado. Observa el siguiente ejemplo:

 type WithDifferentKeyValue< T, K extends keyof T, R extends { [Key in K]: any }, > = Omit<T, K> & R; type Child = { wanted: string; unwanted: string; } type Parent = { child: Child; } type ModifiedChild = Omit<Child, 'unwanted'> type ModifiedParent = WithDifferentKeyValue< Parent, 'child', { child: ModifiedChild } > const invalidModifiedChild: ModifiedChild = { wanted: "yay i'm wanted!", unwanted: "oh no I'm not wanted!" // this is correctly marked invalid } const invalidModifiedParent1: ModifiedParent = { child: invalidModifiedChild // for some reason this is considered valid } const invalidModifiedParent2: ModifiedParent = { child: { wanted: "yay i'm wanted!", unwanted: "oh no I'm not wanted!" // this is correctly marked invalid } }

Tengo un padre que estoy tratando de reemplazar la clave secundaria con la clave secundaria modificada. Este hijo modificado debe tener la clave wanted pero omitir la clave unwanted .

WithDifferentKeyValue es mi mejor intento de crear un ayudante de "reemplazo".

Por alguna razón, mi tipo ModifiedParent identificará correctamente los errores si el objeto secundario está en línea, pero no identificará los errores si el objeto secundario se pasa como una variable. ¿Hay algún gurú mecanografiado que pueda explicarme esto? ¿O sugerir una solución alternativa en la que ModifiedParent cometerá un error correcto incluso en las variables pasadas para child? Gracias por adelantado

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!