Skip to content

Commit

Permalink
fix: Use correct types for event context data
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed Sep 29, 2020
1 parent a575c83 commit 150f7f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions packages/hub/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ export class Scope implements ScopeInterface {
protected _tags: { [key: string]: string } = {};

/** Extra */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected _extra: { [key: string]: any } = {};
protected _extra: { [key: string]: unknown } = {};

/** Contexts */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected _contexts: { [key: string]: any } = {};
protected _contexts: { [key: string]: Record<string, unknown> } = {};

/** Fingerprint */
protected _fingerprint?: string[];
Expand Down Expand Up @@ -185,9 +183,14 @@ export class Scope implements ScopeInterface {
/**
* @inheritDoc
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public setContext(key: string, context: { [key: string]: any } | null): this {
this._contexts = { ...this._contexts, [key]: context };
public setContext(key: string, context: Record<string, unknown> | null): this {
if (context === null) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete this._contexts[key];
} else {
this._contexts = { ...this._contexts, [key]: context };
}

this._notifyScopeListeners();
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface ScopeContext {
user: User;
level: Severity;
extra: { [key: string]: any };
contexts: { [key: string]: any };
contexts: { [key: string]: Record<any, any> };

This comment has been minimized.

Copy link
@rhcarvalho

rhcarvalho Sep 29, 2020

Contributor

Why is this one different? Should it be Record<string, Record<string, any>>?

This comment has been minimized.

Copy link
@kamilogorek

kamilogorek Sep 29, 2020

Author Contributor

Should be contexts: { [key: string]: Record<string, unknown> };. Fixed.

tags: { [key: string]: string };
fingerprint: string[];
}
Expand Down

0 comments on commit 150f7f2

Please sign in to comment.