Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface FooBarCreateDto {
- plop: string;
- baz?: string | undefined;
- }
- interface FooBarDto extends FooBarCreateDto {
- id: string;
- baz: string;
- }
- function fooBarExists(fooBar: FooBarCreateDto | FooBarDto): fooBar is FooBarDto {
- return !!(fooBar as FooBarDto).id;
- }
- function createOrUpdateFooBar(fooBar: FooBarCreateDto | FooBarDto) {
- if (fooBarExists(fooBar)) {
- // update FooBarDto
- }
- // create FooBarCreateDto
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement