I have a file 'test.js' and I changed it's extension to .ts
. What I'm really trying to do is to slowly migrate a .js
codebase to typescript.
Now I'm getting the following error:
'this' implicitly has type 'any' because it does not have a type annotation.
This is the code:
animalSchema.pre('save', function save(next) {
const animal = this;
if (!animal.isModified('id')) {
return next();
}
animal.name = "Test Animal";
next();
});
});
And this is my tsconfig.js
:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"allowJs": true,
"sourceMap": true,
"outDir": "./build",
"rootDir": "./src",
"strict": false,
"noImplicitAny": false,
"noImplicitThis": false,
"moduleResolution": "node",
"esModuleInterop": true
}
}