If we aren't allowed to change type Ghosts and function investigateReport which accepts an array of Ghosts, can we simply return false for both function areGods and function areEctoplasmic?
type Ghosts
function investigateReport
Ghosts
return false
function areGods
function areEctoplasmic
My implementation of function areDemons using user-defined type guard:
function areDemons
type Demons = Extract<Ghosts, {sendBackToHell(): void}> function areDemons(ghosts:Ghosts[]): ghosts is Demons[] { return ghosts.every(ghost => (ghost as Demons).sendBackToHell !== undefined) }
Not if you want to live... and save NYC.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If we aren't allowed to change
type Ghostsandfunction investigateReportwhich accepts an array ofGhosts, can we simplyreturn falsefor bothfunction areGodsandfunction areEctoplasmic?My implementation of
function areDemonsusing user-defined type guard:Not if you want to live... and save NYC.