vim-jsx-typescript icon indicating copy to clipboard operation
vim-jsx-typescript copied to clipboard

Highlighting and indentation broken when type casting

Open pbondoer opened this issue 4 years ago • 2 comments

Following https://github.com/MaxMEllon/vim-jsx-pretty/issues/114, I was looking for an alternative to vim-jsx-pretty for TypeScript, and found this.

Unfortunately it seems this plugin also suffers from the same bug when inside a tsx file (luckily, it doesn't happen for regular .ts files):

https://uplr.it/3f67b.png

Minimal .vimrc to reproduce (with vim-plug)

call plug#begin()
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
call plug#end()

Additional information

This came up through https://github.com/leafgarland/typescript-vim/issues/134 initially.

Please let me know if I can provide any additional information :)

pbondoer avatar Dec 19 '19 14:12 pbondoer

If you are stumbling on this issue from Google, an alternative is to use the as casting operator:

const bar = foo as string;

pbondoer avatar Dec 19 '19 14:12 pbondoer

According to TypeScript docs:

The two samples are equivalent. Using one over the other is mostly a choice of preference; however, when using TypeScript with JSX, only as-style assertions are allowed.

So perhaps this shouldn't be considered a bug after all. I'll let you be the judge of that :+1:

pbondoer avatar Dec 19 '19 23:12 pbondoer