.tsx File Extension
.tsx file is, how to open and compile TSX source, how Poly supports it, and when .ts or .jsx is a better choice. File extension details for .tsx
Full Support| File type | TypeScript source with JSX |
|---|---|
| MIME type | None registered |
| Encoding | Unicode source text, normally UTF-8 |
| Operating systems | Windows, macOS, Linux, ChromeOS |
| Opens with | Visual Studio Code, WebStorm, Visual Studio, Sublime Text |
| Poly support | Yes. Poly recognizes .tsx files as readable source code. |
| Indexed by Poly | Yes. Poly indexes readable source for exact and semantic search. |
| Preview in Poly | Yes. .tsx files open in Poly's read-only code editor. |
| Poly agent | Yes. The Poly agent can read and reason about the source without executing it. |
What kind of file is a .tsx?
A .tsx file contains TypeScript source with JSX, the XML-like syntax commonly used to describe user interfaces. TypeScript uses this suffix to distinguish source that may contain JSX from an ordinary .ts file. The compiler requires both the .tsx suffix and an enabled jsx option to process JSX syntax.1
TSX is most familiar in React projects, but JSX is not exclusive to React. Its runtime meaning depends on the project's compiler settings, JSX library, imports, and type declarations. React's TypeScript guide says every React file containing JSX must use .tsx.2
There is no magic byte sequence for TSX. It is text, so confirming the format requires a TypeScript-aware parser and the surrounding project configuration. The suffix also has no dedicated IANA-registered MIME type.
Component.ts or Component.jsx to Component.tsx does not add types, enable JSX, or configure a compiler. It changes only the filename.How do I open a .tsx on my computer?
Open .tsx files on Windows, macOS, Linux, or ChromeOS with a code editor such as Visual Studio Code, WebStorm, Visual Studio, or Sublime Text. Visual Studio Code recognizes TSX as the typescriptreact language mode and provides TypeScript language features.3
To check or build a file, use the repository's documented scripts and tsconfig.json. A typical project-wide type check is:
npx tsc --noEmit
The correct command may instead use a framework or another build tool. Review package scripts and dependencies before running an unfamiliar project because source code, plugins, and install scripts can access resources available to their process.
Poly support for .tsx
Poly opens .tsx source in a read-only code editor with syntax highlighting, word wrap, and in-file search. Its readable text is indexed for exact and semantic search. The Poly agent can summarize components, explain props and state, and reason about the source without executing it.
Poly does not run the application, install packages, type-check the project, or resolve every import automatically. Keep tsconfig.json, dependency manifests, type declarations, styles, and related modules alongside the file when those details are important.
History of .tsx
Microsoft introduced the new .tsx extension with TypeScript 1.6 in September 2015. That release added React and JSX support so JSX syntax and TypeScript types could coexist in one file.4
The separate suffix also resolves a parsing ambiguity. Angle brackets can begin either JSX or an older TypeScript type assertion, so .tsx files must use the value as Type assertion style rather than <Type>value.1
Working with .tsx and alternatives
Choose a suffix that matches the syntax and configured toolchain:
| Extension | Best fit | Key distinction |
|---|---|---|
.tsx | TypeScript containing JSX | Supports JSX parsing plus TypeScript type checking |
.ts | TypeScript without JSX | Avoids JSX-specific parsing rules |
.jsx | JavaScript containing JSX | Does not require TypeScript syntax or checking |
.js | Plain JavaScript, or JSX where tooling allows it | The suffix alone does not signal JSX |
TypeScript can emit different JavaScript depending on the jsx compiler option. For example, preserve leaves JSX for another transformation step and emits .jsx, while react-jsx transforms JSX and emits .js.1 The output is generated code, not a renamed copy.
Converting .jsx to .tsx often requires typing component props, resolving implicit types, and aligning library declarations. Converting .tsx to JavaScript removes TypeScript-only syntax during compilation, but the result still depends on the chosen JSX runtime and module target.
Footnotes
- TypeScript. JSX. Documents the
.tsxrequirement, JSX compiler modes, output suffixes, and assertion syntax. ↩ ↩2 ↩3 - React. Using TypeScript. Explains React's
.tsxconvention and required compiler settings. ↩ - Microsoft. Language Identifiers. Lists
typescriptreactfor the.tsxextension. ↩ - TypeScript. Announcing TypeScript 1.6. Introduced
.tsxwith TypeScript's React and JSX support on September 16, 2015. ↩