Currently, I am using gulp for compiling TS files into JS. In the following code snippet:
function Hello(): Promise<string> {
return new Promise(resolve => {
setTimeout(() => {
resolve('Hello, World!');
}, 3000);
});
}
An error occurs during compilation:
error TS7006: Parameter 'resolve' implicitly has an 'any' type.
This error indicates that I need to use any
type in this manner:
return new Promise((resolve: any) => {
However, why do I have to use any
when I've already defined the Promise as Promise<string>
? This seems contradictory.
Here are the dependencies listed:
"dependencies": {
"gulp": "^4.0.2",
"gulp-typescript": "^6.0.0-alpha.1",
"typescript": "^3.9.5"
}
Thank you