diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-10-25 20:34:20 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2021-10-31 19:26:12 +0100 |
commit | dc00bb67a9ef7861427f2d5eb86745f5775d1863 (patch) | |
tree | 01e7eea411e538f83cb339173428e769b63cfdf9 /language-web/src/main/js/editor/xtextMessages.ts | |
parent | feat(web): application-level pings (diff) | |
download | refinery-dc00bb67a9ef7861427f2d5eb86745f5775d1863.tar.gz refinery-dc00bb67a9ef7861427f2d5eb86745f5775d1863.tar.zst refinery-dc00bb67a9ef7861427f2d5eb86745f5775d1863.zip |
fix(web): only try to read properties of objects
Diffstat (limited to 'language-web/src/main/js/editor/xtextMessages.ts')
-rw-r--r-- | language-web/src/main/js/editor/xtextMessages.ts | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/language-web/src/main/js/editor/xtextMessages.ts b/language-web/src/main/js/editor/xtextMessages.ts index d3cb9425..be3125e6 100644 --- a/language-web/src/main/js/editor/xtextMessages.ts +++ b/language-web/src/main/js/editor/xtextMessages.ts | |||
@@ -12,7 +12,8 @@ export interface IXtextWebOkResponse { | |||
12 | 12 | ||
13 | export function isOkResponse(response: unknown): response is IXtextWebOkResponse { | 13 | export function isOkResponse(response: unknown): response is IXtextWebOkResponse { |
14 | const okResponse = response as IXtextWebOkResponse; | 14 | const okResponse = response as IXtextWebOkResponse; |
15 | return typeof okResponse.id === 'string' | 15 | return typeof okResponse === 'object' |
16 | && typeof okResponse.id === 'string' | ||
16 | && typeof okResponse.response !== 'undefined'; | 17 | && typeof okResponse.response !== 'undefined'; |
17 | } | 18 | } |
18 | 19 | ||
@@ -30,7 +31,8 @@ export interface IXtextWebErrorResponse { | |||
30 | 31 | ||
31 | export function isErrorResponse(response: unknown): response is IXtextWebErrorResponse { | 32 | export function isErrorResponse(response: unknown): response is IXtextWebErrorResponse { |
32 | const errorResponse = response as IXtextWebErrorResponse; | 33 | const errorResponse = response as IXtextWebErrorResponse; |
33 | return typeof errorResponse.id === 'string' | 34 | return typeof errorResponse === 'object' |
35 | && typeof errorResponse.id === 'string' | ||
34 | && typeof errorResponse.error === 'string' | 36 | && typeof errorResponse.error === 'string' |
35 | && VALID_XTEXT_WEB_ERROR_KINDS.includes(errorResponse.error) | 37 | && VALID_XTEXT_WEB_ERROR_KINDS.includes(errorResponse.error) |
36 | && typeof errorResponse.message === 'string'; | 38 | && typeof errorResponse.message === 'string'; |
@@ -48,7 +50,8 @@ export interface IXtextWebPushMessage { | |||
48 | 50 | ||
49 | export function isPushMessage(response: unknown): response is IXtextWebPushMessage { | 51 | export function isPushMessage(response: unknown): response is IXtextWebPushMessage { |
50 | const pushMessage = response as IXtextWebPushMessage; | 52 | const pushMessage = response as IXtextWebPushMessage; |
51 | return typeof pushMessage.resource === 'string' | 53 | return typeof pushMessage === 'object' |
54 | && typeof pushMessage.resource === 'string' | ||
52 | && typeof pushMessage.stateId === 'string' | 55 | && typeof pushMessage.stateId === 'string' |
53 | && typeof pushMessage.service === 'string' | 56 | && typeof pushMessage.service === 'string' |
54 | && typeof pushMessage.push !== 'undefined'; | 57 | && typeof pushMessage.push !== 'undefined'; |