Typescript : Type 'Promise<{}>' is not assignable to type 'Promise<void>'

Viewed 25761

I have the following function :

let templateLoader = (onDidFinishLoad : Function, onDidFailLoad : Function) =>
    (url : string) : Promise<void> => 
        new Promise(    
            (resolve,reject) => {
                mainWindow.loadURL(url);
                mainWindow.webContents.once(
                    'did-finish-load',
                    () => { 
                        onDidFinishLoad(resolve);
                    }  
                );  
                mainWindow.webContents.once(
                    'did-fail-load', 
                    (event,errorCode,errorDescription) => {  
                        onDidFailLoad(reject,errorDescription); 
                    }  
                );   
            } 
        ); 

I've got the following compilation error:

ERROR in [at-loader] ./app/loaders.ts:9:9 TS2322: Type 'Promise {}' is not assignable to type Promise void. Type '{}' is not assignable to type 'void'.

1 Answers
Related