9

I have issues getting both Visual Studio Code and Visual Studio 2013 to recognize the special syntax of template strings (ES6):

Visual Studio Code

enter image description here

Visual Studio 2013

enter image description here

What am I missing?

transporter_room_3
  • 2,583
  • 4
  • 33
  • 51
  • Are you using ` (tick) or ' (single quote) ? – Johnie Karr Dec 10 '15 at 18:40
  • I just looked it up...I wasn't familiar with template strings, and hadn't ever seen the back tick used, looks like it is correct :) – Johnie Karr Dec 10 '15 at 18:43
  • There was a lot of small things like that that drove me away from visual studio code. You should file it as a bug on git hub https://github.com/Microsoft/vscode/issues – pizzarob Dec 10 '15 at 18:55
  • The proper name is "template literal" FYI, since if you tag it with something, it doesn't have to return a string :) – loganfsmyth Dec 10 '15 at 19:04
  • Interesting. I read about them on MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings) and they refer to them as strings. I guess I should also read the official ES6 specification! :-) – transporter_room_3 Dec 10 '15 at 19:56
  • @transporter_room_3 I think you are confusing not *recognizing* the syntax with not coloring it correctly. If you hover over `var test`, you should see it picks it up as a string (`var test: string`). I don't think VS2013 has ES6 support, so it's no surprise you're not getting it there – CodingIntrigue Dec 11 '15 at 08:32
  • 1
    You may need to upgrade IDE... First came out in VS2015 https://blogs.msdn.microsoft.com/visualstudio/2015/06/10/javascript-editor-improvements-in-visual-studio-2015/ Duplicate question https://stackoverflow.com/questions/24034668/how-to-use-ecmascript-6-syntax-with-visual-studio-2013 – JGFMK Jul 13 '17 at 12:41

2 Answers2

1

This should be working now, there is no issue for basic examples in VSCode 1.14.0

enter image description here

I suspect they were just a bit late to the backtick party. There are however still many unclosed issues relating to things like better support for template grammars and language support in ES6 template strings so it appears there is much work to do for advanced capabilities being included.

Anthropic
  • 681
  • 1
  • 11
  • 29
1

Try to use back ticks (`), not single or double quotes

var name = 'Walton';
console.log(`Hi ${name}`);
David Buck
  • 3,752
  • 35
  • 31
  • 35
akash maurya
  • 607
  • 9
  • 16