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

186
Views
El argumento de tipo 'cadena' no se puede asignar al parámetro de tipo 'nunca' ¿cómo solucionarlo?

Cómo solucionar el problema de Tipo en React TypeScript.

Soy nuevo en react-typescript y estoy obteniendo objetos con propiedad de cadena del servidor. Y actualizando el estado.

Cómo corregir el error con el tipo:

 Argument of type 'string' is not assignable to parameter of type 'never'

formMethods y setValue provenientes del formulario de gancho de reacción

 useEffect(() => { if (address.postalCode?.length === 5) { const getCityState = async () => { const response = await getUspsCityState(address.postalCode); if (response) { const { city, state } = response; // HERE I AM getting error: // Argument of type 'string' is not assignable to parameter of type 'never' formMethods.setValue('address.city', city, { shouldDirty: true, shouldValidate: true, }); } }; getCityState(); } }, [formMethods, watchPostalCode]);

Esta es la función getUspsCityState:

 export const getUspsCityState = ( zipcode: string, ): Promise<UspsCityState | null> => new Promise((resolve, reject) => { try { const xmlString = `<?xml version="1.0"?><CityStateLookupRequest USERID="${USPS_USER_ID}"><ZipCode><Zip5>${zipcode}</Zip5></ZipCode></CityStateLookupRequest>`; const api = 'CityStateLookup'; return fetch(`${USPS_SERVER}?API=${api}&XML=${xmlString}`, { method: 'GET', }) .then(response => response.text()) .then(xmlResponse => { const state = xmlResponse.match(/<State>([^<]+)<\/State>/i); const city = xmlResponse.match(/<City>([^<]+)<\/City>/i); if (state && state[1] && city && city[1]) { return resolve({ state: state[1], city: city[1] }); } return resolve(null); }); } catch (e) { return reject(e); } });

ERROR ingrese la descripción de la imagen aquí

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!