Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

16.2K
Visualizações
What is the difference between .ts and .tsx extensions. Both are used as extensions for typescript files in react. So where should we use them?

I am new to react and I am working on a project. I come across both .ts and .tsx extensions. I don't understand where should I use .ts and .tsx. Any help on this is much appreciated. Thank you!

over 4 years ago · Santiago Trujillo
5 Respostas
Responde à pergunta

0

.tsx extension is used when we want to embed JSX elements inside the files while .ts is used for plain Typescript files and do not support adding JSX Elements.

over 4 years ago · Santiago Trujillo Relatório

0

All of the above answers are correct.

.ts files contains only pure TypeScript

.tsx have included JSX also.

On another point of view, you can copy everything from a .ts file and paste on .tsx file, and you don't need to modify anything. But if you're copying from a .tsx file you need to refactor it by removing the JSX elements.

over 4 years ago · Santiago Trujillo Relatório

0

The difference is simple: .ts is used for TypeScript files without JSX , while .tsx is used when the file contains JSX (React components) . Generally, use .tsx for React components that render UI and .ts for utilities, services, types, interfaces, and logic that don't include JSX.

3 months ago · Ruben Alexander Serrano Porras Relatório

0

Use .ts for pure TypeScript files.

Use .tsx for files which contain JSX.

For example, a React component would be .tsx, but a file containing helper functions would be .ts.

over 4 years ago · Santiago Trujillo Relatório

0

Use .ts for pure TypeScript files.

Use .tsx for files which contain JSX.

For example, a React component would be .tsx, but a file containing helper functions would be .ts.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda