Created
November 15, 2018 22:01
-
-
Save ORESoftware/8d02fb30c53c19f6b38bddbc96da2475 to your computer and use it in GitHub Desktop.
use case for anonymous object to be cast properly to interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use case for StackOverflow question: | |
// https://stackoverflow.com/questions/53328459/prevent-compilation-unless-all-fields-exist | |
const z = function(req,res,next){ | |
interface ResponseBody { | |
foo1: number; | |
foo2: string; | |
foo3: boolean; | |
} | |
doSomething(v, function(err, d){ | |
if(err){ | |
return next(err); | |
} | |
res.json(<ResponseBody>{foo1:d, foo2:"success",foo3:true}) | |
}); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment