From b2ace0ce49fdf9ef13efb703b638c9f3ba8badf7 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Thu, 19 Dec 2019 22:36:24 +0800 Subject: [PATCH] Fix the ambiguity of typescript and jsx syntax (#115) --- after/syntax/typescript.vim | 6 ++++-- test.tsx | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/after/syntax/typescript.vim b/after/syntax/typescript.vim index 10acecd..f8258f7 100644 --- a/after/syntax/typescript.vim +++ b/after/syntax/typescript.vim @@ -46,9 +46,11 @@ if !hlexists('typescriptTypeCast') \ fold endif -syntax cluster typescriptExpression add=jsxRegion,typescriptParens - runtime syntax/jsx_pretty.vim +syntax cluster typescriptExpression add=jsxRegion,typescriptParens,tsCast +" Fix type casting ambiguity with JSX syntax +syntax match typescriptTypeBrackets +[<>]+ contained +syntax match typescriptTypeCast +<\([_$A-Za-z0-9]\+\)>\%(\s*\%([_$A-Za-z0-9]\+\s*;\?\|(\)\%(\_[^<]*\)\@!\)\@=+ contains=typescriptTypeBrackets,@typescriptType let b:current_syntax = 'typescript.tsx' diff --git a/test.tsx b/test.tsx index 18088fe..e3267cb 100644 --- a/test.tsx +++ b/test.tsx @@ -2,6 +2,10 @@ import React from 'react'; const head = (arr: T[]): T => arr[0] +const foo = bar; +const foo = bar; + + function test() { const a = 1; let foo;