score:198

Accepted answer

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.

score:7

when you use .tsx you can use jsx in that particular file while .ts gives you error.

score:15

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.

score:39

.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.


Related Query

More Query from same tag