0

I have an angular 2 service in which I have this line :

transformedObjects.push(new MyObject(myObject.x, myObject._id));

When I use debugger in Chrome Dev tool and follow the process I see this line

transformedObjects.push(new myObject_model_1.MyObject(myObject.y, myObject._id));

Why I have diference on : myObject.x and myObject.y ?

Constantin Groß
  • 10,719
  • 4
  • 24
  • 50
  • Can you post the js code or take a screenshot then? As you'd appreciate it'd be impossible to say something based on this data. – eko May 11 '17 at 18:35
  • do you have `sourcemaps` enabled in your tsconfig.json? this seems like an issue with typescript or babel, not with angular or google-chrome. – Claies May 11 '17 at 18:37
  • sourcemaps is not enabled in my tsconfig.json. I add "debugger" in my angular component, this component call for the service.myMethod() and in it I see diference between source code and the code displayed in chrome source map – chrismakerfr May 11 '17 at 19:00
  • It seems to be a sort of cache in my debugger... I tried to change : return this.http.get('http://localhost:3000/aaa') by return this.http.get('http://localhost:3000/bbb') and reload APP and relaunch debugger, 'bbb' is again used. Do you have an idea ? I already checked 'Disable cache (while DevTools is open)'. – chrismakerfr May 12 '17 at 16:44
  • Ok, I find the error : I have myService.ts which get the last version of code and in my IDE I have a subfile : myService.js which get the old source. It's seems the .ts not erase the.js when I launch angular... I deleted the.js and it's working now.. I dont now why I got this .js generated – chrismakerfr May 12 '17 at 17:54

1 Answers1

1

It's part of Angular and Typescript's compilation magic. There is some renaming behind the scenes to allow for static class members and the like, but everything should work as expected.

If you want to debug live in your Typescript files, ensure Enable Javascript source maps is enabled in Dev Tools settings, and you should get a Sourcemap detected popup when inspecting the source, with an option to enable the mapping.

This of course depends on your compilation setup; as long as your build process produces sourcemaps, you should be good.

joh04667
  • 7,159
  • 27
  • 34
  • Thank for your response. I have sourcemap activated and the code I provided is from the sourcemap. I dont understand why I have diference. – chrismakerfr May 11 '17 at 18:55