-
-
Notifications
You must be signed in to change notification settings - Fork 919
/
deprecated.ts
48 lines (41 loc) · 1.04 KB
/
deprecated.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint-disable jsdoc/require-param */
/**
* A deprecation should never be done in a patch.
*/
type DeprecationSemVer = `${number}.${number}`;
/** @internal */
export interface DeprecatedOptions {
/**
* The name of the function, following the syntax `faker.[module].[function]()`.
*/
deprecated: string;
/**
* An alternative solution.
*/
proposed?: string;
/**
* The semver since when this is deprecated.
*/
since?: DeprecationSemVer;
/**
* The semver when this will be removed.
*/
until?: DeprecationSemVer;
}
/**
* @internal
*/
export function deprecated(opts: DeprecatedOptions): void {
let message = `[@faker-js/faker]: ${opts.deprecated} is deprecated`;
if (opts.since) {
message += ` since v${opts.since}`;
}
if (opts.until) {
message += ` and will be removed in v${opts.until}`;
}
if (opts.proposed) {
message += `. Please use ${opts.proposed} instead`;
}
// eslint-disable-next-line no-undef -- Using console here is intentional and required
console.warn(`${message}.`);
}