Skip to content

Commit 95f061e

Browse files
committed
minor cleanup in factory.ts
* remove deprecated signatures * deprecate some legacy signature * remove 2 useless conditions
1 parent 2b14bcb commit 95f061e

File tree

1 file changed

+8
-48
lines changed

1 file changed

+8
-48
lines changed

src/compiler/factory.ts

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ namespace ts {
10581058
: node;
10591059
}
10601060

1061-
export function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression;
1061+
/** @deprecated */ export function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression;
10621062
export function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray<TypeNode> | undefined, template: TemplateLiteral): TaggedTemplateExpression;
10631063
/** @internal */
10641064
export function createTaggedTemplate(tag: Expression, typeArgumentsOrTemplate: ReadonlyArray<TypeNode> | TemplateLiteral | undefined, template?: TemplateLiteral): TaggedTemplateExpression;
@@ -1076,7 +1076,7 @@ namespace ts {
10761076
return node;
10771077
}
10781078

1079-
export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression;
1079+
/** @deprecated */ export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression;
10801080
export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray<TypeNode> | undefined, template: TemplateLiteral): TaggedTemplateExpression;
10811081
export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArgumentsOrTemplate: ReadonlyArray<TypeNode> | TemplateLiteral | undefined, template?: TemplateLiteral) {
10821082
return node.tag !== tag
@@ -1168,43 +1168,15 @@ namespace ts {
11681168
node.body = parenthesizeConciseBody(body);
11691169
return node;
11701170
}
1171-
1172-
/** @deprecated */ export function updateArrowFunction(
1173-
node: ArrowFunction,
1174-
modifiers: ReadonlyArray<Modifier> | undefined,
1175-
typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined,
1176-
parameters: ReadonlyArray<ParameterDeclaration>,
1177-
type: TypeNode | undefined,
1178-
body: ConciseBody): ArrowFunction;
11791171
export function updateArrowFunction(
11801172
node: ArrowFunction,
11811173
modifiers: ReadonlyArray<Modifier> | undefined,
11821174
typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined,
11831175
parameters: ReadonlyArray<ParameterDeclaration>,
11841176
type: TypeNode | undefined,
11851177
equalsGreaterThanToken: Token<SyntaxKind.EqualsGreaterThanToken>,
1186-
body: ConciseBody): ArrowFunction;
1187-
export function updateArrowFunction(
1188-
node: ArrowFunction,
1189-
modifiers: ReadonlyArray<Modifier> | undefined,
1190-
typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined,
1191-
parameters: ReadonlyArray<ParameterDeclaration>,
1192-
type: TypeNode | undefined,
1193-
equalsGreaterThanTokenOrBody: Token<SyntaxKind.EqualsGreaterThanToken> | ConciseBody,
1194-
bodyOrUndefined?: ConciseBody,
1178+
body: ConciseBody
11951179
): ArrowFunction {
1196-
let equalsGreaterThanToken: Token<SyntaxKind.EqualsGreaterThanToken>;
1197-
let body: ConciseBody;
1198-
if (bodyOrUndefined === undefined) {
1199-
equalsGreaterThanToken = node.equalsGreaterThanToken;
1200-
body = cast(equalsGreaterThanTokenOrBody, isConciseBody);
1201-
}
1202-
else {
1203-
equalsGreaterThanToken = cast(equalsGreaterThanTokenOrBody, (n): n is Token<SyntaxKind.EqualsGreaterThanToken> =>
1204-
n.kind === SyntaxKind.EqualsGreaterThanToken);
1205-
body = bodyOrUndefined;
1206-
}
1207-
12081180
return node.modifiers !== modifiers
12091181
|| node.typeParameters !== typeParameters
12101182
|| node.parameters !== parameters
@@ -1306,7 +1278,7 @@ namespace ts {
13061278
: node;
13071279
}
13081280

1309-
export function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression;
1281+
/** @deprecated */ export function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression;
13101282
export function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression;
13111283
export function createConditional(condition: Expression, questionTokenOrWhenTrue: QuestionToken | Expression, whenTrueOrWhenFalse: Expression, colonToken?: ColonToken, whenFalse?: Expression) {
13121284
const node = <ConditionalExpression>createSynthesizedNode(SyntaxKind.ConditionalExpression);
@@ -1317,26 +1289,14 @@ namespace ts {
13171289
node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse);
13181290
return node;
13191291
}
1320-
1321-
/** @deprecated */ export function updateConditional(
1322-
node: ConditionalExpression,
1323-
condition: Expression,
1324-
whenTrue: Expression,
1325-
whenFalse: Expression): ConditionalExpression;
13261292
export function updateConditional(
13271293
node: ConditionalExpression,
13281294
condition: Expression,
13291295
questionToken: Token<SyntaxKind.QuestionToken>,
13301296
whenTrue: Expression,
13311297
colonToken: Token<SyntaxKind.ColonToken>,
1332-
whenFalse: Expression): ConditionalExpression;
1333-
export function updateConditional(node: ConditionalExpression, condition: Expression, ...args: any[]) {
1334-
if (args.length === 2) {
1335-
const [whenTrue, whenFalse] = args;
1336-
return updateConditional(node, condition, node.questionToken, whenTrue, node.colonToken, whenFalse);
1337-
}
1338-
Debug.assert(args.length === 4);
1339-
const [questionToken, whenTrue, colonToken, whenFalse] = args;
1298+
whenFalse: Expression
1299+
): ConditionalExpression {
13401300
return node.condition !== condition
13411301
|| node.questionToken !== questionToken
13421302
|| node.whenTrue !== whenTrue
@@ -2231,7 +2191,7 @@ namespace ts {
22312191
export function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray<TypeNode> | undefined, attributes: JsxAttributes) {
22322192
const node = <JsxSelfClosingElement>createSynthesizedNode(SyntaxKind.JsxSelfClosingElement);
22332193
node.tagName = tagName;
2234-
node.typeArguments = typeArguments && createNodeArray(typeArguments);
2194+
node.typeArguments = asNodeArray(typeArguments);
22352195
node.attributes = attributes;
22362196
return node;
22372197
}
@@ -2247,7 +2207,7 @@ namespace ts {
22472207
export function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray<TypeNode> | undefined, attributes: JsxAttributes) {
22482208
const node = <JsxOpeningElement>createSynthesizedNode(SyntaxKind.JsxOpeningElement);
22492209
node.tagName = tagName;
2250-
node.typeArguments = typeArguments && createNodeArray(typeArguments);
2210+
node.typeArguments = asNodeArray(typeArguments);
22512211
node.attributes = attributes;
22522212
return node;
22532213
}

0 commit comments

Comments
 (0)