Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitespace before type parameter list breaks parsing #289

Open
tobil4sk opened this issue Aug 18, 2024 · 2 comments
Open

Whitespace before type parameter list breaks parsing #289

tobil4sk opened this issue Aug 18, 2024 · 2 comments
Labels

Comments

@tobil4sk
Copy link
Contributor

The syntax does not accept type parameters if there is a space before <.

image

This patch seems to solve the issue:

--- a/syntax/ts-common/type.vim
+++ b/syntax/ts-common/type.vim
@@ -26,7 +26,7 @@ syntax match typescriptGenericDefault /=/
 " class A extend B<T> {} // ClassBlock
 " func<T>() // FuncCallArg
 syntax region typescriptTypeArguments matchgroup=typescriptTypeBrackets
-  \ start=/\></ end=/>/
+  \ start=/</ end=/>/
   \ contains=@typescriptType
   \ nextgroup=typescriptFuncCallArg,@typescriptTypeOperator
   \ contained skipwhite

image

@HerringtonDarkholme
Copy link
Owner

This is done on purpose. func < T > (3) is a valid JavaScript and users should avoid adding undesirable spaces.

@tobil4sk
Copy link
Contributor Author

func<T>(3) is also valid JavaScript syntax. The TypeScript compiler intentionally parses both as a generic call, regardless of spaces: microsoft/TypeScript#1121.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants