Skip to content

Commit a4593fd

Browse files
authored
Merge pull request microsoft#22261 from ajafff/factory-array
factory: replace Array parameters with ReadonlyArray
2 parents 343bb5a + 62e9d4c commit a4593fd

3 files changed

Lines changed: 38 additions & 38 deletions

File tree

src/compiler/factory.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -592,15 +592,15 @@ namespace ts {
592592
: node;
593593
}
594594

595-
export function createCallSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) {
595+
export function createCallSignature(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined) {
596596
return createSignatureDeclaration(SyntaxKind.CallSignature, typeParameters, parameters, type) as CallSignatureDeclaration;
597597
}
598598

599599
export function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined) {
600600
return updateSignatureDeclaration(node, typeParameters, parameters, type);
601601
}
602602

603-
export function createConstructSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) {
603+
export function createConstructSignature(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined) {
604604
return createSignatureDeclaration(SyntaxKind.ConstructSignature, typeParameters, parameters, type) as ConstructSignatureDeclaration;
605605
}
606606

@@ -636,7 +636,7 @@ namespace ts {
636636
}
637637

638638
/* @internal */
639-
export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, typeArguments?: TypeNode[] | undefined) {
639+
export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, typeArguments?: ReadonlyArray<TypeNode> | undefined) {
640640
const node = createSynthesizedNode(kind) as SignatureDeclaration;
641641
node.typeParameters = asNodeArray(typeParameters);
642642
node.parameters = asNodeArray(parameters);
@@ -687,15 +687,15 @@ namespace ts {
687687
: node;
688688
}
689689

690-
export function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) {
690+
export function createFunctionTypeNode(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined) {
691691
return createSignatureDeclaration(SyntaxKind.FunctionType, typeParameters, parameters, type) as FunctionTypeNode;
692692
}
693693

694694
export function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined) {
695695
return updateSignatureDeclaration(node, typeParameters, parameters, type);
696696
}
697697

698-
export function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) {
698+
export function createConstructorTypeNode(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined) {
699699
return createSignatureDeclaration(SyntaxKind.ConstructorType, typeParameters, parameters, type) as ConstructorTypeNode;
700700
}
701701

@@ -751,15 +751,15 @@ namespace ts {
751751
: node;
752752
}
753753

754-
export function createUnionTypeNode(types: TypeNode[]): UnionTypeNode {
754+
export function createUnionTypeNode(types: ReadonlyArray<TypeNode>): UnionTypeNode {
755755
return <UnionTypeNode>createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, types);
756756
}
757757

758758
export function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray<TypeNode>) {
759759
return updateUnionOrIntersectionTypeNode(node, types);
760760
}
761761

762-
export function createIntersectionTypeNode(types: TypeNode[]): IntersectionTypeNode {
762+
export function createIntersectionTypeNode(types: ReadonlyArray<TypeNode>): IntersectionTypeNode {
763763
return <IntersectionTypeNode>createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, types);
764764
}
765765

@@ -2572,9 +2572,9 @@ namespace ts {
25722572

25732573
// Compound nodes
25742574

2575-
export function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression;
2576-
export function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
2577-
export function createImmediatelyInvokedFunctionExpression(statements: Statement[], param?: ParameterDeclaration, paramValue?: Expression) {
2575+
export function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray<Statement>): CallExpression;
2576+
export function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray<Statement>, param: ParameterDeclaration, paramValue: Expression): CallExpression;
2577+
export function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray<Statement>, param?: ParameterDeclaration, paramValue?: Expression) {
25782578
return createCall(
25792579
createFunctionExpression(
25802580
/*modifiers*/ undefined,
@@ -2590,9 +2590,9 @@ namespace ts {
25902590
);
25912591
}
25922592

2593-
export function createImmediatelyInvokedArrowFunction(statements: Statement[]): CallExpression;
2594-
export function createImmediatelyInvokedArrowFunction(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
2595-
export function createImmediatelyInvokedArrowFunction(statements: Statement[], param?: ParameterDeclaration, paramValue?: Expression) {
2593+
export function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray<Statement>): CallExpression;
2594+
export function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray<Statement>, param: ParameterDeclaration, paramValue: Expression): CallExpression;
2595+
export function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray<Statement>, param?: ParameterDeclaration, paramValue?: Expression) {
25962596
return createCall(
25972597
createArrowFunction(
25982598
/*modifiers*/ undefined,
@@ -3093,7 +3093,7 @@ namespace ts {
30933093
return createCall(createPropertyAccess(array, "slice"), /*typeArguments*/ undefined, argumentsList);
30943094
}
30953095

3096-
export function createArrayConcat(array: Expression, values: Expression[]) {
3096+
export function createArrayConcat(array: Expression, values: ReadonlyArray<Expression>) {
30973097
return createCall(
30983098
createPropertyAccess(array, "concat"),
30993099
/*typeArguments*/ undefined,
@@ -3145,7 +3145,7 @@ namespace ts {
31453145
);
31463146
}
31473147

3148-
export function createExpressionForJsxElement(jsxFactoryEntity: EntityName, reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression {
3148+
export function createExpressionForJsxElement(jsxFactoryEntity: EntityName, reactNamespace: string, tagName: Expression, props: Expression, children: ReadonlyArray<Expression>, parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression {
31493149
const argumentsList = [tagName];
31503150
if (props) {
31513151
argumentsList.push(props);
@@ -3177,7 +3177,7 @@ namespace ts {
31773177
);
31783178
}
31793179

3180-
export function createExpressionForJsxFragment(jsxFactoryEntity: EntityName, reactNamespace: string, children: Expression[], parentElement: JsxOpeningFragment, location: TextRange): LeftHandSideExpression {
3180+
export function createExpressionForJsxFragment(jsxFactoryEntity: EntityName, reactNamespace: string, children: ReadonlyArray<Expression>, parentElement: JsxOpeningFragment, location: TextRange): LeftHandSideExpression {
31813181
const tagName = createPropertyAccess(
31823182
createReactNamespace(reactNamespace, parentElement),
31833183
"Fragment"
@@ -3288,7 +3288,7 @@ namespace ts {
32883288
};`
32893289
};
32903290

3291-
export function createSpreadHelper(context: TransformationContext, argumentList: Expression[], location?: TextRange) {
3291+
export function createSpreadHelper(context: TransformationContext, argumentList: ReadonlyArray<Expression>, location?: TextRange) {
32923292
context.requestEmitHelper(readHelper);
32933293
context.requestEmitHelper(spreadHelper);
32943294
return setTextRange(
@@ -3458,7 +3458,7 @@ namespace ts {
34583458
return { target, thisArg };
34593459
}
34603460

3461-
export function inlineExpressions(expressions: Expression[]) {
3461+
export function inlineExpressions(expressions: ReadonlyArray<Expression>) {
34623462
// Avoid deeply nested comma expressions as traversing them during emit can result in "Maximum call
34633463
// stack size exceeded" errors.
34643464
return expressions.length > 10

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,9 +3497,9 @@ declare namespace ts {
34973497
function updateGetAccessor(node: GetAccessorDeclaration, decorators: ReadonlyArray<Decorator> | undefined, modifiers: ReadonlyArray<Modifier> | undefined, name: PropertyName, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration;
34983498
function createSetAccessor(decorators: ReadonlyArray<Decorator> | undefined, modifiers: ReadonlyArray<Modifier> | undefined, name: string | PropertyName, parameters: ReadonlyArray<ParameterDeclaration>, body: Block | undefined): SetAccessorDeclaration;
34993499
function updateSetAccessor(node: SetAccessorDeclaration, decorators: ReadonlyArray<Decorator> | undefined, modifiers: ReadonlyArray<Modifier> | undefined, name: PropertyName, parameters: ReadonlyArray<ParameterDeclaration>, body: Block | undefined): SetAccessorDeclaration;
3500-
function createCallSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration;
3500+
function createCallSignature(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration;
35013501
function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration;
3502-
function createConstructSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration;
3502+
function createConstructSignature(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration;
35033503
function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration;
35043504
function createIndexSignature(decorators: ReadonlyArray<Decorator> | undefined, modifiers: ReadonlyArray<Modifier> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode): IndexSignatureDeclaration;
35053505
function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray<Decorator> | undefined, modifiers: ReadonlyArray<Modifier> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode): IndexSignatureDeclaration;
@@ -3508,9 +3508,9 @@ declare namespace ts {
35083508
function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode;
35093509
function createTypeReferenceNode(typeName: string | EntityName, typeArguments: ReadonlyArray<TypeNode> | undefined): TypeReferenceNode;
35103510
function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode;
3511-
function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode;
3511+
function createFunctionTypeNode(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined): FunctionTypeNode;
35123512
function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): FunctionTypeNode;
3513-
function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode;
3513+
function createConstructorTypeNode(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructorTypeNode;
35143514
function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructorTypeNode;
35153515
function createTypeQueryNode(exprName: EntityName): TypeQueryNode;
35163516
function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
@@ -3520,9 +3520,9 @@ declare namespace ts {
35203520
function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
35213521
function createTupleTypeNode(elementTypes: ReadonlyArray<TypeNode>): TupleTypeNode;
35223522
function updateTypleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray<TypeNode>): TupleTypeNode;
3523-
function createUnionTypeNode(types: TypeNode[]): UnionTypeNode;
3523+
function createUnionTypeNode(types: ReadonlyArray<TypeNode>): UnionTypeNode;
35243524
function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray<TypeNode>): UnionTypeNode;
3525-
function createIntersectionTypeNode(types: TypeNode[]): IntersectionTypeNode;
3525+
function createIntersectionTypeNode(types: ReadonlyArray<TypeNode>): IntersectionTypeNode;
35263526
function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray<TypeNode>): IntersectionTypeNode;
35273527
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: ReadonlyArray<TypeNode>): UnionOrIntersectionTypeNode;
35283528
function createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode;
@@ -3755,10 +3755,10 @@ declare namespace ts {
37553755
function updateCommaList(node: CommaListExpression, elements: ReadonlyArray<Expression>): CommaListExpression;
37563756
function createBundle(sourceFiles: ReadonlyArray<SourceFile>): Bundle;
37573757
function updateBundle(node: Bundle, sourceFiles: ReadonlyArray<SourceFile>): Bundle;
3758-
function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression;
3759-
function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
3760-
function createImmediatelyInvokedArrowFunction(statements: Statement[]): CallExpression;
3761-
function createImmediatelyInvokedArrowFunction(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
3758+
function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray<Statement>): CallExpression;
3759+
function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray<Statement>, param: ParameterDeclaration, paramValue: Expression): CallExpression;
3760+
function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray<Statement>): CallExpression;
3761+
function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray<Statement>, param: ParameterDeclaration, paramValue: Expression): CallExpression;
37623762
function createComma(left: Expression, right: Expression): Expression;
37633763
function createLessThan(left: Expression, right: Expression): Expression;
37643764
function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment;

0 commit comments

Comments
 (0)