Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. interface FooBarCreateDto {
  2. plop: string;
  3. baz?: string | undefined;
  4. }
  5.  
  6. interface FooBarDto extends FooBarCreateDto {
  7. id: string;
  8. baz: string;
  9. }
  10.  
  11. function fooBarExists(fooBar: FooBarCreateDto | FooBarDto): fooBar is FooBarDto {
  12. return !!(fooBar as FooBarDto).id;
  13. }
  14.  
  15. function createOrUpdateFooBar(fooBar: FooBarCreateDto | FooBarDto) {
  16. if (fooBarExists(fooBar)) {
  17. // update FooBarDto
  18. }
  19. // create FooBarCreateDto
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement