I'm using arrow functions and I'm debugging with Chrome and Firefox Dev Tool. I am getting, this
as undefined, even though the code still works.
For Example: When paused on the following breakpoint, I type this
in the console, and it comes out undefined
, even though the console.log
shows the correct this
:
class A {
f = () => {
debugger;
console.log(this);
};
}
new A().f();
My assumption is, that it has something to do with source-maps.
Here are the tools I use in order to build the my code:
- webpack (devtool: eval)
- babel-loader (es5 preset)
- typescript-loader
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…