Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

275
Vistas
.tsx files throw errors while .js files work fine

in react-native, when I try to pass parameters to functions/components/etc, typescript files will always complain and it won't work until I have specified the type which often is confusing and the code looks way more like spaghetti..

When using .js file with the same code, everything works fine. Also, there are no errors shown in VSCode when there are missing imports or wrong types being passed. Is there any proper way to handle this? Should I only use .tsx for react-native ? can I somehow get a sweet-spot between having errors with .tsx files and not having any Intellisense with .js files?

Btw: I dont need help fixing the errors in the pictures, I want to avoid that they're being shown as errors.

Thanks in Advance. passing parameters error example error

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You need to type those parameters since this file is TypeScript now.

I don't know the shape of navigation, route and user, but to get rid of the errors, you could type those values as any:

export function AuthStack({navigation, route}: any) {}

and

const [user, setUser] = useState<any>(null);
about 4 years ago · Juan Pablo Isaza Denunciar

0

Files .js are just javaScript, jsx ("React syntax") can run in there or in a .jsx file. But .ts and .tsx are typeScript files, which means that your javaScript now would needs types for the code. You can read more about it on:

https://www.typescriptlang.org/

An easy way to solve the problem is the Ali Klein answer. Or actually use the right types for those variables. For exmaple: useState<string|null>(null);

If you don't want to use types, why not use .jsx instead .tsx for the files?

Another option would be use the comment //@ts-ignore over each line with type checking

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda