joshpeng / Sublime-Babel-VSCode

Sublime Text's babel-sublime grammar in VS Code.
MIT License
49 stars 16 forks source link

Parameterized type does not work with arrow functions #24

Open rattrayalex-stripe opened 7 years ago

rattrayalex-stripe commented 7 years ago

This code results in broken syntax highlighting for all following code in the file:

const foo = <Foo>(x: Foo) => {
  return x + x;
};

I have found that this workaround fixes it:

const foo = /* any comment here */<Foo>(x: Foo) => {
  return x + x;
};

But would rather not have to litter my codebase with otherwise-needless comments 😄

joshpeng commented 7 years ago

This seems to be the case even with this plugin disabled. Can you please confirm?

rattrayalex-stripe commented 7 years ago

@joshpeng sorry for the delay.

The default VSCode syntax highlighter also doesn't handle this correctly, if that's what you mean. Other highlighters like vim (and, it seems, github's) don't seem to break, though.

Specifically, I'm told this syntax works with the following vim plugins:

Plugin 'pangloss/vim-javascript'
Plugin 'flowtype/vim-flow'
joshpeng commented 7 years ago

@rattrayalex-stripe This seems to happen both with or without Sublime Babel enabled. The issue is <Foo> because it detects that as a React HTML tag. Not sure what can be done.

rattrayalex-stripe commented 7 years ago

Yeah, it's also an issue "upstream" with https://github.com/babel/babel-sublime and judging from the current status of that repo (https://github.com/babel/babel-sublime/issues/328 and https://github.com/babel/babel-sublime/issues/293) it's not likely to be addressed soon.

It may be possible to go digging in regex's and do something clever (eg; handle a <Foo>( differently from <Foo>) but I certainly understand if you're not up for that 😄

kumarharsh commented 6 years ago

@joshpeng Have you looked at https://github.com/borela/naomi?