Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
129
rated 0 times [  136] [ 7]  / answers: 1 / hits: 29246  / 7 Years ago, fri, july 28, 2017, 12:00:00

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'.



More From » typescript

 Answers
7

it works by modifying : Promise<void> into : Promise<any>,



or to cast new Promise into new Promise<void>.


[#56944] Wednesday, July 26, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaylynbrynnk

Total Points: 706
Total Questions: 98
Total Answers: 91

Location: Israel
Member since Thu, Jan 7, 2021
3 Years ago
;