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

112
Views
¿Cómo extiendo una interfaz base dinámicamente?

Estoy usando react-query y tengo muchos ganchos useQuery que aceptan estos parámetros:

 export interface UseQueryHookProps<K> { client: K; isEnabled?: boolean; }

¿Cómo escribiría la interfaz para que sea más genérica para aceptar cualquier interfaz adicional o más bien desconocida?

Así que algo como esto:

 export interface UseQueryHookProps<K, T> extends T { client: K; isEnabled?: boolean; }

Donde se llamaría a UseQueryHookProps :

 export const useGetJob = ({ client: monitoringService, isEnabled = true, jobId, }: UseQueryHookProps<MonitoringServiceClient, {jobId: string}>)

No estoy seguro de cómo escribir esto?

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

0

No se le permite ampliar la interfaz con T . Para hacer eso, T debe conocerse estáticamente.

Si desea extender UseQueryHookProps con T , debe usar la sintaxis de type en lugar de interface .

 export interface UseQueryHookProps<K> { client: K; isEnabled?: boolean; } type ExtendHookProps<K, T> = UseQueryHookProps<K> & T interface MonitoringServiceClient { tag: 'MonitoringServiceClient' } export const useGetJob = ({ client: monitoringService, isEnabled = true, jobId, }: ExtendHookProps<MonitoringServiceClient, { jobId: string }>) => { }

Patio de juegos

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!