I defined a custom type alias:
export type ActivationPromise = Promise<void>;
I have created the following two functions:
async function derp(): ActivationPromise {
await test();
}
function test(): ActivationPromise {
return Promise.resolve();
}
This is the content of my tsconfig.json file:
{
"compilerOptions": {
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"module": "commonjs",
"target": "es5",
"allowJs": true,
"alwaysStrict": true,
"importHelpers": true,
"lib": [ "dom", "es5", "es2015.promise", "es2015.iterable", "scripthost"]
},
"compileOnSave": false
}
Upon compilation, the following error is encountered:
error TS1055: Type 'ActivationPromise' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor
When I change the return type to just Promise<void>
, the code compiles without any issues. The problem only arises when using the type alias. Can someone explain why this is happening, given that the type alias is intended to function as a typedef
?