When I try to convert a basic JS file to TS while having implicit "any" disabled, I encounter the following error:
Error TS7009: When attempting to create a new expression without a constructor signature, it implicitly defaults to an 'any' type.
interface Logger {
new (): any;
}
interface LoggerInstance {
}
function Logger(): void {
}
var defaultLogger: LoggerInstance = new Logger();//error TS7009
I'm stuck on how to resolve this issue without turning the Logger function into a class.
The TypeScript compiler was providing suggestions for improvement when implicit any wasn't disabled, so I prefer to keep that setting enabled.
Update: After removing "new" from the Logger interface and casting the result of new Logger(...) in the full file, I managed to compile it. However, I still face the same error in my smaller test case.
Update 2: It seems that the error warnings disappear when the plugin highlighting syntax errors crashes. It appears that this method of object creation may not be allowed when "implicit any" is turned off.