-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add guards for types needed for prop types by mobile #44
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,6 +259,28 @@ | |
file_id: string; | ||
}; | ||
|
||
export function isCaption(obj: unknown): obj is Caption { | ||
if (typeof obj !== 'object' || obj === null) { | ||
return false; | ||
} | ||
|
||
const caption = obj as Caption; | ||
|
||
if (typeof caption.title !== 'string') { | ||
return false; | ||
} | ||
|
||
if (typeof caption.language !== 'string') { | ||
return false; | ||
} | ||
|
||
if (typeof caption.file_id !== 'string') { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
export type JobStopData = { | ||
job_id: string; | ||
}; | ||
|
@@ -270,6 +292,32 @@ | |
rec_id?: string; | ||
}; | ||
|
||
export function isCallJobMetadata(obj: unknown): obj is CallJobMetadata { | ||
if (typeof obj !== 'object' || obj === null) { | ||
return false; | ||
} | ||
|
||
const metadata = obj as CallJobMetadata; | ||
|
||
if (typeof metadata.file_id !== 'string') { | ||
return false; | ||
} | ||
|
||
if (typeof metadata.post_id !== 'string') { | ||
return false; | ||
} | ||
|
||
if (metadata.tr_id !== undefined && typeof metadata.tr_id !== 'string') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason to use
If we don't check for undefined, we have the following things that may happen:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Could we add exceptions to make the linter happy? |
||
return false; | ||
} | ||
|
||
if (metadata.rec_id !== undefined && typeof metadata.rec_id !== 'string') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
export type CallRecordingPropsMap = { | ||
[key: string]: CallJobMetadata; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate js sometimes. 😭