Skip to content

Commit

Permalink
Add isObject check to ProblemMarker
Browse files Browse the repository at this point in the history
The `in` operator does not work on undefined objects.
So in order to check the node kind we need to make sure,
that the node is an object.

Contributed on behalf of STMicroelectronics

Fixes #12250
  • Loading branch information
eneufeld committed Mar 2, 2023
1 parent f7ef6b5 commit 8d9b560
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/markers/src/common/problem-marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { Marker } from './marker';
import { Diagnostic } from '@theia/core/shared/vscode-languageserver-protocol';
import { isObject } from '@theia/core/lib/common';

export const PROBLEM_KIND = 'problem';

Expand All @@ -24,7 +25,7 @@ export interface ProblemMarker extends Marker<Diagnostic> {
}

export namespace ProblemMarker {
export function is(node: Marker<object>): node is ProblemMarker {
return 'kind' in node && node.kind === PROBLEM_KIND;
export function is(node: unknown): node is ProblemMarker {
return isObject<Marker<object>>(node) && node.kind === PROBLEM_KIND;
}
}

0 comments on commit 8d9b560

Please sign in to comment.