4

In .tsx files, when writing a type definition containing a sub type, VSCode (Emmet) expands it as if it was a JSX tag. Does anybody know how to prevent this behaviour while keeping the functionality for standard JSX?

Example:

const a: MyType<Something

generates the following when typing the closing >:

const a: MyType<Something></Something>

While the expected result is:

const a: MyType<Something>

Note that this happens inside and outside of React components and JSX statements.

FMCorz
  • 2,586
  • 1
  • 21
  • 18
  • Instead of typing `>` just type `/` i should autocomplete the closing tag `>` and not expand that and then remove `/` – Zunaib Imtiaz Jan 30 '20 at 04:52
  • 1
    Thanks, but I'm looking for a complete solution. – FMCorz Jan 30 '20 at 05:01
  • 3
    I would think ` "emmet.excludeLanguages": ["typescriptreact", "javascriptreact"],` in your settings would do it but they have no effect for me. Perhaps you have better luck. – Mark Jan 30 '20 at 05:45
  • 1
    Yes, but that would completely disable Emmet in these `tsx` files which is not what I'm looking for. – FMCorz Jan 30 '20 at 06:09
  • It should be `type`, not `const`. That's not a valid location in syntax for defining TypeScript generic parameters. – Patrick Roberts Feb 04 '20 at 22:44
  • @PatrickRoberts You're right but the behaviour I'm describing happens where it shouldn't regardless. – FMCorz Feb 04 '20 at 23:46
  • Updated my comment, thanks. Though, your example of Partial is invalid, if you try `Partial<` followed by, for instance `ButtonHTMLAttributes`, you end up with `Partial`. – FMCorz Mar 17 '23 at 05:19
  • hm. what happens for you if you do `const a: Partial – starball Mar 17 '23 at 05:36

0 Answers0