Skip to content

Commit a449eb7

Browse files
committed
fix: cjs-shaped type declaration
Fixes an issue where the compiler complained the default export was not constructable
1 parent 5fa7b83 commit a449eb7

File tree

1 file changed

+69
-65
lines changed

1 file changed

+69
-65
lines changed

metric.d.ts

Lines changed: 69 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,84 @@
1-
/**
2-
* A hint of what type of metric this is. Each numeric value represents a different type of metric:
3-
*
4-
* - `0`: `unknown`
5-
* - `1`: `gauge`
6-
* - `2`: `counter`
7-
* - `3`: `state_set`
8-
* - `4`: `info`
9-
* - `5`: `cumulative histogram`
10-
* - `6`: `gauge histogram`
11-
* - `7`: `summary`
12-
*/
13-
export type MetricType = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
14-
15-
export type MetricLabel = {
16-
/**
17-
* The name must match the regular expression `[a-zA-Z0-9_]`.
18-
*/
19-
name: string;
20-
value: string | number | boolean | null;
21-
}
22-
23-
export type MetricOptions = {
24-
/**
25-
* The name must match the regular expression `[a-zA-Z_:][a-zA-Z0-9_:]*`.
26-
*
27-
* By convention, colons are reserved for monitoring system use, and names
28-
* beginning with underscores are reserved for monitoring-system internal use.
29-
*/
30-
name: string;
31-
description: string;
32-
/**
33-
* @default Date.now() / 1000
34-
*/
35-
timestamp?: number | null;
36-
/**
37-
* @deprecated Use `timestamp` instead.
38-
*/
39-
time?: number | null;
40-
source?: string | null;
41-
labels?: Array<MetricLabel>;
42-
value?: number | null;
43-
/**
44-
* @default 0 (`unknown`)
45-
*/
46-
type?: MetricType;
47-
/**
48-
* Arbitrary metadata to attach to this metric. This field is not validated.
49-
* @default {}
50-
*/
51-
meta?: unknown;
52-
}
53-
54-
export default class Metric {
55-
constructor(args: MetricOptions);
1+
declare class Metric {
2+
constructor(args: Metric.MetricOptions);
563

574
name: Readonly<string>;
585
description: Readonly<string>;
596
value: Readonly<number | null>;
60-
type: Readonly<MetricType>;
7+
type: Readonly<Metric.MetricType>;
618
source: string | null;
629
timestamp: Readonly<number | null>;
6310
/**
6411
* @deprecated Use `timestamp` instead.
6512
*/
6613
time: Readonly<number | null>;
67-
labels: Readonly<Array<MetricLabel>>;
14+
labels: Readonly<Array<Metric.MetricLabel>>;
6815
meta: Readonly<unknown>;
6916

7017
toJSON(): {
71-
name: string;
72-
description: string;
73-
timestamp: number | null;
74-
type: MetricType;
75-
value: number | null;
76-
labels: Array<MetricLabel>;
77-
time: number | null;
78-
meta: unknown;
18+
name: string;
19+
description: string;
20+
timestamp: number | null;
21+
type: Metric.MetricType;
22+
value: number | null;
23+
labels: Array<Metric.MetricLabel>;
24+
time: number | null;
25+
meta: unknown;
26+
};
27+
}
28+
29+
declare namespace Metric {
30+
/**
31+
* A hint of what type of metric this is. Each numeric value represents a different type of metric:
32+
*
33+
* - `0`: `unknown`
34+
* - `1`: `gauge`
35+
* - `2`: `counter`
36+
* - `3`: `state_set`
37+
* - `4`: `info`
38+
* - `5`: `cumulative histogram`
39+
* - `6`: `gauge histogram`
40+
* - `7`: `summary`
41+
*/
42+
export type MetricType = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
43+
44+
export type MetricLabel = {
45+
/**
46+
* The name must match the regular expression `[a-zA-Z0-9_]`.
47+
*/
48+
name: string;
49+
value: string | number | boolean | null;
50+
};
51+
52+
export type MetricOptions = {
53+
/**
54+
* The name must match the regular expression `[a-zA-Z_:][a-zA-Z0-9_:]*`.
55+
*
56+
* By convention, colons are reserved for monitoring system use, and names
57+
* beginning with underscores are reserved for monitoring-system internal use.
58+
*/
59+
name: string;
60+
description: string;
61+
/**
62+
* @default Date.now() / 1000
63+
*/
64+
timestamp?: number | null;
65+
/**
66+
* @deprecated Use `timestamp` instead.
67+
*/
68+
time?: number | null;
69+
source?: string | null;
70+
labels?: Array<MetricLabel>;
71+
value?: number | null;
72+
/**
73+
* @default 0 (`unknown`)
74+
*/
75+
type?: MetricType;
76+
/**
77+
* Arbitrary metadata to attach to this This field is not validated.
78+
* @default {}
79+
*/
80+
meta?: unknown;
7981
};
8082
}
83+
84+
export = Metric;

0 commit comments

Comments
 (0)