|
1 | 1 | import * as ts from "./_namespaces/ts";
|
2 | 2 | import {
|
3 | 3 | AnyFunction, AssertionLevel, BigIntLiteralType, CheckMode, compareValues, EmitFlags, every, FlowFlags, FlowLabel, FlowNode,
|
4 |
| - FlowNodeBase, FlowSwitchClause, formatStringFromArgs, getEffectiveModifierFlagsNoCache, getEmitFlags, getOwnKeys, |
| 4 | + FlowNodeBase, FlowSwitchClause, getEffectiveModifierFlagsNoCache, getEmitFlags, getOwnKeys, |
5 | 5 | getParseTreeNode, getSourceFileOfNode, getSourceTextOfNodeFromSourceFile, hasProperty, idText, IntrinsicType,
|
6 | 6 | isArrayTypeNode, isBigIntLiteral, isCallSignatureDeclaration, isConditionalTypeNode, isConstructorDeclaration,
|
7 | 7 | isConstructorTypeNode, isConstructSignatureDeclaration, isDefaultClause, isFunctionTypeNode, isGeneratedIdentifier,
|
@@ -31,17 +31,6 @@ export interface LoggingHost {
|
31 | 31 | log(level: LogLevel, s: string): void;
|
32 | 32 | }
|
33 | 33 |
|
34 |
| -/** @internal */ |
35 |
| -export interface DeprecationOptions { |
36 |
| - message?: string; |
37 |
| - error?: boolean; |
38 |
| - since?: Version | string; |
39 |
| - warnAfter?: Version | string; |
40 |
| - errorAfter?: Version | string; |
41 |
| - typeScriptVersion?: Version | string; |
42 |
| - name?: string; |
43 |
| -} |
44 |
| - |
45 | 34 | /** @internal */
|
46 | 35 | export namespace Debug {
|
47 | 36 | let typeScriptVersion: Version | undefined;
|
@@ -697,58 +686,6 @@ export namespace Debug {
|
697 | 686 | isDebugInfoEnabled = true;
|
698 | 687 | }
|
699 | 688 |
|
700 |
| - function formatDeprecationMessage(name: string, error: boolean | undefined, errorAfter: Version | undefined, since: Version | undefined, message: string | undefined) { |
701 |
| - let deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; |
702 |
| - deprecationMessage += `'${name}' `; |
703 |
| - deprecationMessage += since ? `has been deprecated since v${since}` : "is deprecated"; |
704 |
| - deprecationMessage += error ? " and can no longer be used." : errorAfter ? ` and will no longer be usable after v${errorAfter}.` : "."; |
705 |
| - deprecationMessage += message ? ` ${formatStringFromArgs(message, [name], 0)}` : ""; |
706 |
| - return deprecationMessage; |
707 |
| - } |
708 |
| - |
709 |
| - function createErrorDeprecation(name: string, errorAfter: Version | undefined, since: Version | undefined, message: string | undefined) { |
710 |
| - const deprecationMessage = formatDeprecationMessage(name, /*error*/ true, errorAfter, since, message); |
711 |
| - return () => { |
712 |
| - throw new TypeError(deprecationMessage); |
713 |
| - }; |
714 |
| - } |
715 |
| - |
716 |
| - function createWarningDeprecation(name: string, errorAfter: Version | undefined, since: Version | undefined, message: string | undefined) { |
717 |
| - let hasWrittenDeprecation = false; |
718 |
| - return () => { |
719 |
| - if (enableDeprecationWarnings && !hasWrittenDeprecation) { |
720 |
| - log.warn(formatDeprecationMessage(name, /*error*/ false, errorAfter, since, message)); |
721 |
| - hasWrittenDeprecation = true; |
722 |
| - } |
723 |
| - }; |
724 |
| - } |
725 |
| - |
726 |
| - export function createDeprecation(name: string, options: DeprecationOptions & { error: true }): () => never; |
727 |
| - export function createDeprecation(name: string, options?: DeprecationOptions): () => void; |
728 |
| - export function createDeprecation(name: string, options: DeprecationOptions = {}) { |
729 |
| - const version = typeof options.typeScriptVersion === "string" ? new Version(options.typeScriptVersion) : options.typeScriptVersion ?? getTypeScriptVersion(); |
730 |
| - const errorAfter = typeof options.errorAfter === "string" ? new Version(options.errorAfter) : options.errorAfter; |
731 |
| - const warnAfter = typeof options.warnAfter === "string" ? new Version(options.warnAfter) : options.warnAfter; |
732 |
| - const since = typeof options.since === "string" ? new Version(options.since) : options.since ?? warnAfter; |
733 |
| - const error = options.error || errorAfter && version.compareTo(errorAfter) <= 0; |
734 |
| - const warn = !warnAfter || version.compareTo(warnAfter) >= 0; |
735 |
| - return error ? createErrorDeprecation(name, errorAfter, since, options.message) : |
736 |
| - warn ? createWarningDeprecation(name, errorAfter, since, options.message) : |
737 |
| - noop; |
738 |
| - } |
739 |
| - |
740 |
| - function wrapFunction<F extends (...args: any[]) => any>(deprecation: () => void, func: F): F { |
741 |
| - return function (this: unknown) { |
742 |
| - deprecation(); |
743 |
| - return func.apply(this, arguments); |
744 |
| - } as F; |
745 |
| - } |
746 |
| - |
747 |
| - export function deprecate<F extends (...args: any[]) => any>(func: F, options?: DeprecationOptions): F { |
748 |
| - const deprecation = createDeprecation(options?.name ?? getFunctionName(func), options); |
749 |
| - return wrapFunction(deprecation, func); |
750 |
| - } |
751 |
| - |
752 | 689 | export function formatVariance(varianceFlags: VarianceFlags) {
|
753 | 690 | const variance = varianceFlags & VarianceFlags.VarianceMask;
|
754 | 691 | let result =
|
|
0 commit comments