Remove outdated deprecations (#52314)

This commit is contained in:
Ron Buckton
2023-01-20 12:19:13 -05:00
committed by GitHub
parent 1e99934b29
commit f526e16b2d
11 changed files with 0 additions and 5126 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +0,0 @@
import {
Node,
SyntaxKind,
TypeAssertion,
} from "../_namespaces/ts";
import { deprecate } from "../deprecate";
// DEPRECATION: Renamed node tests
// DEPRECATION PLAN:
// - soft: 4.0
// - warn: 4.1
// - error: TBD
/** @deprecated Use `isTypeAssertionExpression` instead. */
export const isTypeAssertion = deprecate(function isTypeAssertion(node: Node): node is TypeAssertion {
return node.kind === SyntaxKind.TypeAssertionExpression;
}, {
since: "4.0",
warnAfter: "4.1",
message: "Use `isTypeAssertionExpression` instead."
});

View File

@@ -1,80 +0,0 @@
import {
addNodeFactoryPatcher,
buildOverload,
ConstructorTypeNode,
factory,
Modifier,
NodeArray,
NodeFactory,
ParameterDeclaration,
TypeNode,
TypeParameterDeclaration,
} from "../_namespaces/ts";
// DEPRECATION: Overloads for createConstructorTypeNode/updateConstructorTypeNode that do not accept 'modifiers'
// DEPRECATION PLAN:
// - soft: 4.2
// - warn: 4.3
// - error: 5.0
declare module "../../compiler/types" {
// Module transform: converted from interface augmentation
export interface NodeFactory {
/** @deprecated Use the overload that accepts 'modifiers' */
createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode;
/** @deprecated Use the overload that accepts 'modifiers' */
updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode;
}
}
function patchNodeFactory(factory: NodeFactory) {
const {
createConstructorTypeNode,
updateConstructorTypeNode,
} = factory;
factory.createConstructorTypeNode = buildOverload("createConstructorTypeNode")
.overload({
0(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode {
return createConstructorTypeNode(modifiers, typeParameters, parameters, type);
},
1(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode {
return createConstructorTypeNode(/*modifiers*/ undefined, typeParameters, parameters, type);
},
})
.bind({
0: args => args.length === 4,
1: args => args.length === 3,
})
.deprecate({
1: { since: "4.2", warnAfter: "4.3", message: "Use the overload that accepts 'modifiers'" }
})
.finish();
factory.updateConstructorTypeNode = buildOverload("updateConstructorTypeNode")
.overload({
0(node: ConstructorTypeNode, modifiers: readonly Modifier[] | undefined, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode) {
return updateConstructorTypeNode(node, modifiers, typeParameters, parameters, type);
},
1(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode) {
return updateConstructorTypeNode(node, node.modifiers, typeParameters, parameters, type);
}
})
.bind({
0: args => args.length === 5,
1: args => args.length === 4,
})
.deprecate({
1: { since: "4.2", warnAfter: "4.3", message: "Use the overload that accepts 'modifiers'" }
})
.finish();
}
// Patch `createNodeFactory` because it creates the factories that are provided to transformers
// in the public API.
addNodeFactoryPatcher(patchNodeFactory);
// Patch `ts.factory` because its public
patchNodeFactory(factory);

View File

@@ -1,22 +0,0 @@
import {
isMemberName,
MemberName,
Node,
} from "../_namespaces/ts";
import { deprecate } from "../deprecate";
// DEPRECATION: Renamed node tests
// DEPRECATION PLAN:
// - soft: 4.2
// - warn: 4.3
// - error: 5.0
/**
* @deprecated Use `isMemberName` instead.
*/
export const isIdentifierOrPrivateIdentifier = deprecate(function isIdentifierOrPrivateIdentifier(node: Node): node is MemberName {
return isMemberName(node);
}, {
since: "4.2",
warnAfter: "4.3",
message: "Use `isMemberName` instead."
});

View File

@@ -1,102 +0,0 @@
import {
addNodeFactoryPatcher,
buildOverload,
EntityName,
factory,
ImportTypeAssertionContainer,
ImportTypeNode,
isArray,
isEntityName,
isImportTypeAssertionContainer,
NodeFactory,
TypeNode,
} from "../_namespaces/ts";
// DEPRECATION: Overloads to createImportTypeNode/updateImportTypeNode that do not accept `assertions`
// DEPRECATION PLAN:
// - soft: 4.6
// - warn: 4.7
// - error: 5.0
declare module "../../compiler/types" {
// Module transform: converted from interface augmentation
export interface NodeFactory {
// NOTE: The following overload is not deprecated, but exists to ensure we don't mark `createImportTypeNode(argument)` as deprecated due to optional parameters.
createImportTypeNode(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode;
/** @deprecated Use the overload that accepts 'assertions' */
createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode;
/** @deprecated Use the overload that accepts 'assertions' */
updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode;
}
}
function patchNodeFactory(factory: NodeFactory) {
const {
createImportTypeNode,
updateImportTypeNode,
} = factory;
factory.createImportTypeNode = buildOverload("createImportTypeNode")
.overload({
0(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode {
return createImportTypeNode(argument, assertions, qualifier, typeArguments, isTypeOf);
},
1(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode {
return createImportTypeNode(argument, /*assertions*/ undefined, qualifier, typeArguments, isTypeOf);
},
})
.bind({
0: ([, assertions, qualifier, typeArguments, isTypeOf]) =>
(assertions === undefined || isImportTypeAssertionContainer(assertions)) &&
(qualifier === undefined || !isArray(qualifier)) &&
(typeArguments === undefined || isArray(typeArguments)) &&
(isTypeOf === undefined || typeof isTypeOf === "boolean"),
1: ([, qualifier, typeArguments, isTypeOf, other]) =>
(other === undefined) &&
(qualifier === undefined || isEntityName(qualifier)) &&
(typeArguments === undefined || isArray(typeArguments)) &&
(isTypeOf === undefined || typeof isTypeOf === "boolean"),
})
.deprecate({
1: { since: "4.6", warnAfter: "4.7", message: "Use the overload that accepts 'assertions'" }
})
.finish();
factory.updateImportTypeNode = buildOverload("updateImportTypeNode")
.overload({
0(node: ImportTypeNode, argument: TypeNode, assertions: ImportTypeAssertionContainer | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode {
return updateImportTypeNode(node, argument, assertions, qualifier, typeArguments, isTypeOf);
},
1(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode {
return updateImportTypeNode(node, argument, node.assertions, qualifier, typeArguments, isTypeOf);
},
})
.bind({
0: ([, , assertions, qualifier, typeArguments, isTypeOf]) =>
(assertions === undefined || isImportTypeAssertionContainer(assertions)) &&
(qualifier === undefined || !isArray(qualifier)) &&
(typeArguments === undefined || isArray(typeArguments)) &&
(isTypeOf === undefined || typeof isTypeOf === "boolean"),
1: ([, , qualifier, typeArguments, isTypeOf, other]) =>
(other === undefined) &&
(qualifier === undefined || isEntityName(qualifier)) &&
(typeArguments === undefined || isArray(typeArguments)) &&
(isTypeOf === undefined || typeof isTypeOf === "boolean"),
}).
deprecate({
1: { since: "4.6", warnAfter: "4.7", message: "Use the overload that accepts 'assertions'" }
})
.finish();
}
// Patch `createNodeFactory` because it creates the factories that are provided to transformers
// in the public API.
addNodeFactoryPatcher(patchNodeFactory);
// Patch `ts.factory` because its public
patchNodeFactory(factory);

View File

@@ -1,85 +0,0 @@
import {
addNodeFactoryPatcher,
buildOverload,
factory,
Identifier,
isArray,
Modifier,
NodeFactory,
TypeNode,
TypeParameterDeclaration,
} from "../_namespaces/ts";
// DEPRECATION: Overloads to createTypeParameter/updateTypeParameter that does not accept `modifiers`
// DEPRECATION PLAN:
// - soft: 4.7
// - warn: 4.8
// - error: 5.0
declare module "../../compiler/types" {
// Module transform: converted from interface augmentation
export interface NodeFactory {
/** @deprecated Use the overload that accepts 'modifiers' */
createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
/** @deprecated Use the overload that accepts 'modifiers' */
updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
}
}
function patchNodeFactory(factory: NodeFactory) {
const {
createTypeParameterDeclaration,
updateTypeParameterDeclaration,
} = factory;
factory.createTypeParameterDeclaration = buildOverload("createTypeParameterDeclaration")
.overload({
0(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration {
return createTypeParameterDeclaration(modifiers, name, constraint, defaultType);
},
1(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration {
return createTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint, defaultType);
},
})
.bind({
0: ([modifiers]) =>
(modifiers === undefined || isArray(modifiers)),
1: ([name]) =>
(name !== undefined && !isArray(name)),
})
.deprecate({
1: { since: "4.7", warnAfter: "4.8", message: "Use the overload that accepts 'modifiers'" }
})
.finish();
factory.updateTypeParameterDeclaration = buildOverload("updateTypeParameterDeclaration")
.overload({
0(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration {
return updateTypeParameterDeclaration(node, modifiers, name, constraint, defaultType);
},
1(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration {
return updateTypeParameterDeclaration(node, node.modifiers, name, constraint, defaultType);
},
})
.bind({
0: ([, modifiers]) =>
(modifiers === undefined || isArray(modifiers)),
1: ([, name]) =>
(name !== undefined && !isArray(name)),
})
.deprecate({
1: { since: "4.7", warnAfter: "4.8", message: "Use the overload that accepts 'modifiers'" }
})
.finish();
}
// Patch `createNodeFactory` because it creates the factories that are provided to transformers
// in the public API.
addNodeFactoryPatcher(patchNodeFactory);
// Patch `ts.factory` because its public
patchNodeFactory(factory);

File diff suppressed because it is too large Load Diff

View File

@@ -2,11 +2,4 @@
export * from "../../compiler/_namespaces/ts";
export * from "../deprecations";
export * from "../4.0/nodeFactoryTopLevelExports";
export * from "../4.0/renamedNodeTests";
export * from "../4.2/renamedNodeTests";
export * from "../4.2/abstractConstructorTypes";
export * from "../4.6/importTypeAssertions";
export * from "../4.7/typeParameterModifiers";
export * from "../4.8/mergeDecoratorsAndModifiers";
export * from "../5.0/identifierProperties";

View File

@@ -1,6 +1,4 @@
import * as ts from "../_namespaces/ts";
import { setEnableDeprecationWarnings } from "../../deprecatedCompat/deprecate";
import { Modifier } from "../_namespaces/ts";
describe("unittests:: FactoryAPI", () => {
function assertSyntaxKind(node: ts.Node, expected: ts.SyntaxKind) {
@@ -85,38 +83,4 @@ describe("unittests:: FactoryAPI", () => {
});
});
describe("deprecations", () => {
beforeEach(() => {
setEnableDeprecationWarnings(false);
});
afterEach(() => {
setEnableDeprecationWarnings(true);
});
// https://github.com/microsoft/TypeScript/issues/50259
it("deprecated createConstructorDeclaration overload does not throw", () => {
const body = ts.factory.createBlock([]);
assert.doesNotThrow(() => ts.factory.createConstructorDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*parameters*/ [],
body,
));
});
// https://github.com/microsoft/TypeScript/issues/50259
it("deprecated updateConstructorDeclaration overload does not throw", () => {
const body = ts.factory.createBlock([]);
const ctor = ts.factory.createConstructorDeclaration(/*modifiers*/ undefined, [], body);
assert.doesNotThrow(() => ts.factory.updateConstructorDeclaration(
ctor,
ctor.decorators,
ctor.modifiers as readonly Modifier[] | undefined,
ctor.parameters,
ctor.body,
));
});
});
});