なぜモンゴースフックを使用してthis
を参照しているときにTypescriptエラーが発生するのか誰にも分かります。私は矢印の機能を使用していない、と私はそれでレキシカルスコープの問題について知っているが、それでもこのような無名関数を持つ:正確なエラーメッセージがモンゴースのフックがTypescriptと一緒に動作しない
'this' implicitly has type 'any' because it does not have a type annotation.
ある
UserSchema.pre("save", function(next) {
console.log(this.password);
next();
});
誰でも取得する方法を知っていますこの周り?
ところで、私は2.5.2/8.2.1 NodeJS
を活字体を使用していますありがとう!
この質問は役に立ちます:https://stackoverflow.com/questions/41944650/this-implicitly-has-type-any-because-it-does-not-have-a-type-annotation –