How to tell the Typescript compiler to compile JSX in .ts files?

I have several files .tsthat have .jsx syntax in them. I want to say tsccompile my .ts files, for example, compile .tsx files.

Can I customize tscfor this?

How to configure vscode to support syntax highlighting for JSX syntax in these files?

+4
source share
1 answer

No, you should have your reaction code in the files .tsx, as the docs say :

To use JSX, you have to do two things.

  • Name your files the extension .tsx
  • Enable jsx option

, typescript :

interface Point {
    x: number;
    y: number;
}

let p = <Point> {};

tsx , <Point> Point.
- tsx , assert:

let p = {} as Point;

.ts - , , jsx.

+3

Source: https://habr.com/ru/post/1656785/


All Articles