Function return type trap in TS.


In TS there is a trap for function’s return type

function a {
    b();
}
function b {
    // some operations
    return typeC value
}

In the case above, the return type of function a would be void even though it finally returns value in typeC

To fix this problem, add a return before executing function b:

function a {
    return b();
}
function b {
    // some operations
    return typeC value
}

A u t h o r: Joe
P o l i c y: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Joe !
Leave Your Comment Here
  TOC