Skip to content

Commit 178a0d2

Browse files
committed
add comments and fix docstring
1 parent 0df9e1c commit 178a0d2

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-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: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import { Severity, SeverityLevel } from '@sentry/types';
22

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

517
/**
6-
* Converts a string-based level into a {@link Severity}.
18+
* Converts a string-based level into a member of the {@link Severity} enum.
719
*
8-
* @param level string representation of Severity
20+
* @param level String representation of Severity
921
* @returns Severity
1022
*/
1123
export function severityFromString(level: SeverityLevel | string): Severity {

0 commit comments

Comments
 (0)