Closed
Description
"typescript": "^2.7.2",
"typescript-eslint-parser": "^14.0.0",
If I have promise like this:
export default function to<T>(promise: Promise<T>) {
return promise
.then((data: T) => {
return { error: undefined, data };
})
.catch((error: Error) => {
return { error, data: undefined };
});
}
And after that I add async await with this logic:
public someMethod() {
const { error, data } = await to<SomeType>(SOME PROMISE HERE);
if(error) {
return;
}
// HERE I WILL NOT BE ABLE TO GET SomeType because Typescript still recognise data as type:
// undefined | SomeType
data.
}
Maybe this is some bug with IDE I don't know. I am usigin Visual Code.