3
  1. When I open my TypeScript in Chrome debugger I see strange red dot at the first line. I believe it corresponds to unrendered symbol \ufeff (as popover says). There is no such symbol in the TS file when I open it in editor (e. g., Notepad++ with "show all symbols"). Where does this symbol come from?

  2. This file also contains some lines colored in gray. It seems that I cannot insert breakpoint to that lines (e. g., line #17 on the picture). How can I get rid of it?

TS or JS troubles in Chrome

In FireFox all this issues are not presented. I have no strange symbol at the beginning of the file and I can insert breakpoint to lines which were grayed out in Chrome.

Update. I have found that \ufeff corresponds to BOM. It is likely generated by --emitBOM option of the TypeScript compiler. Now can someone explain how can I remove this option? I can't find any reference to "tsc" in my project file when I open it in a text editor as well as I can't find any proper options in Visual Studio GUI (Web Express).

Update 2. I have learnt from this discussion that with help of \ufeff = BOM Chrome can indicate a developer that there is something wrong in the code. But the BOM appears even when I comment out all code in my file.

Hoborg
  • 891
  • 12
  • 21
  • 1
    You might want to search up what U+FEFF is used for, which might provide some insight into why this happens. – Qantas 94 Heavy Jun 05 '15 at 09:53
  • @Qantas94Heavy Thanks for the clue. I have updated the question. However I am still confused that this symbol (U+FEFF = BOM) is not presented in the file when I view it with text editor. – Hoborg Jun 05 '15 at 10:13
  • @Qantas94Heavy Yes, I have looked at this page but didn't find anything connected with my problem. Do you mean some concrete section on this page? – Hoborg Jun 05 '15 at 10:26
  • 1
    @Qantas94Heavy update to your link: https://en.wikipedia.org/wiki/Byte_order_mark – d48 Jan 10 '17 at 21:23

2 Answers2

3

It seems that Chrome somehow doesn't like UTF-8 with BOM. And this is exactly an encoding which my instance of Visual Studio did save file in. I have switched the encoding to UTF-8 without BOM and the described problems have disappeared.

How to: corresponding StackOverflow question. In two words: 1) select desired encoding while saving via "Save as...", or 2) go to File/Advanced Save Options... and select the encoding for all files (you need to add this menu item if you have no one). The encoding is called "UTF-8 without signature".

Community
  • 1
  • 1
Hoborg
  • 891
  • 12
  • 21
3

When I open my TypeScript in Chrome debugger I see strange red dot at the first line. I believe it corresponds to unrendered symbol \ufeff

Yes this is the BOM as other answers have already pointed out. For 2:

This file also contains some lines colored in gray. It seems that I cannot insert breakpoint to that lines (e. g., line #17 on the picture). How can I get rid of it?

These are lines that are not there in the sourcemap. This is the way chrome dev tools show unmapped to generated JS source code. So you cannot place a breakpoint in here as the runtime doesn't know which JS corresponds to this TS.

basarat
  • 261,912
  • 58
  • 460
  • 511