Skip to content

Commit fdcff7d

Browse files
committed
add comments and fix docstring
1 parent fba7c2a commit fdcff7d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/types/src/severity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ export enum Severity {
1818
Critical = 'critical',
1919
}
2020

21-
// TODO: in v7, these can disappear, because they now also exist in `@sentry/utils`. (Having them there rather than here
22-
// is nice because then it enforces the idea that only types are exported from `@sentry/types`.)
21+
// Note: If this is ever changed, the `validSeverityLevels` array in `@sentry/utils` needs to be changed, also. (See
22+
// note there for why we can't derive one from the other.)
2323
export type SeverityLevel = 'fatal' | 'error' | 'warning' | 'log' | 'info' | 'debug' | 'critical';

packages/utils/src/severity.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import { Severity, SeverityLevel } from '@sentry/types';
22

3+
// Note: Ideally the `SeverityLevel` type would be derived from `validSeverityLevels`, but that would mean either
4+
//
5+
// a) moving `validSeverityLevels` to `@sentry/types`,
6+
// b) moving the`SeverityLevel` type here, or
7+
// c) importing `validSeverityLevels` from here into `@sentry/types`.
8+
//
9+
// Option A would make `@sentry/types` a runtime dependency of `@sentry/utils` (not good), and options B and C would
10+
// create a circular dependency between `@sentry/types` and `@sentry/utils` (also not good). So a TODO accompanying the
11+
// type, reminding anyone who changes it to change this list also, will have to do.
12+
313
export const validSeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
414

515
/**
6-
* Converts a string-based level into a {@link Severity}.
16+
* Converts a string-based level into a member of the {@link Severity} enum.
717
*
8-
* @param level string representation of Severity
18+
* @param level String representation of Severity
919
* @returns Severity
1020
*/
1121
export function severityFromString(level: SeverityLevel | string): Severity {

0 commit comments

Comments
 (0)