factory: replace Array parameters with ReadonlyArray

This commit is contained in:
Klaus Meinhardt
2018-03-01 12:53:04 +01:00
parent c487a9dc04
commit 0e171abf32

View File

@@ -544,7 +544,7 @@ namespace ts {
: node;
}
export function createCallSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) {
export function createCallSignature(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined) {
return createSignatureDeclaration(SyntaxKind.CallSignature, typeParameters, parameters, type) as CallSignatureDeclaration;
}
@@ -552,7 +552,7 @@ namespace ts {
return updateSignatureDeclaration(node, typeParameters, parameters, type);
}
export function createConstructSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) {
export function createConstructSignature(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined) {
return createSignatureDeclaration(SyntaxKind.ConstructSignature, typeParameters, parameters, type) as ConstructSignatureDeclaration;
}
@@ -588,7 +588,7 @@ namespace ts {
}
/* @internal */
export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, typeArguments?: TypeNode[] | undefined) {
export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, typeArguments?: ReadonlyArray<TypeNode> | undefined) {
const node = createSynthesizedNode(kind) as SignatureDeclaration;
node.typeParameters = asNodeArray(typeParameters);
node.parameters = asNodeArray(parameters);
@@ -639,7 +639,7 @@ namespace ts {
: node;
}
export function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) {
export function createFunctionTypeNode(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined) {
return createSignatureDeclaration(SyntaxKind.FunctionType, typeParameters, parameters, type) as FunctionTypeNode;
}
@@ -647,7 +647,7 @@ namespace ts {
return updateSignatureDeclaration(node, typeParameters, parameters, type);
}
export function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) {
export function createConstructorTypeNode(typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined) {
return createSignatureDeclaration(SyntaxKind.ConstructorType, typeParameters, parameters, type) as ConstructorTypeNode;
}
@@ -703,7 +703,7 @@ namespace ts {
: node;
}
export function createUnionTypeNode(types: TypeNode[]): UnionTypeNode {
export function createUnionTypeNode(types: ReadonlyArray<TypeNode>): UnionTypeNode {
return <UnionTypeNode>createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, types);
}
@@ -711,7 +711,7 @@ namespace ts {
return updateUnionOrIntersectionTypeNode(node, types);
}
export function createIntersectionTypeNode(types: TypeNode[]): IntersectionTypeNode {
export function createIntersectionTypeNode(types: ReadonlyArray<TypeNode>): IntersectionTypeNode {
return <IntersectionTypeNode>createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, types);
}
@@ -2496,9 +2496,9 @@ namespace ts {
// Compound nodes
export function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression;
export function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
export function createImmediatelyInvokedFunctionExpression(statements: Statement[], param?: ParameterDeclaration, paramValue?: Expression) {
export function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray<Statement>): CallExpression;
export function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray<Statement>, param: ParameterDeclaration, paramValue: Expression): CallExpression;
export function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray<Statement>, param?: ParameterDeclaration, paramValue?: Expression) {
return createCall(
createFunctionExpression(
/*modifiers*/ undefined,
@@ -2514,9 +2514,9 @@ namespace ts {
);
}
export function createImmediatelyInvokedArrowFunction(statements: Statement[]): CallExpression;
export function createImmediatelyInvokedArrowFunction(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
export function createImmediatelyInvokedArrowFunction(statements: Statement[], param?: ParameterDeclaration, paramValue?: Expression) {
export function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray<Statement>): CallExpression;
export function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray<Statement>, param: ParameterDeclaration, paramValue: Expression): CallExpression;
export function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray<Statement>, param?: ParameterDeclaration, paramValue?: Expression) {
return createCall(
createArrowFunction(
/*modifiers*/ undefined,
@@ -3016,7 +3016,7 @@ namespace ts {
return createCall(createPropertyAccess(array, "slice"), /*typeArguments*/ undefined, argumentsList);
}
export function createArrayConcat(array: Expression, values: Expression[]) {
export function createArrayConcat(array: Expression, values: ReadonlyArray<Expression>) {
return createCall(
createPropertyAccess(array, "concat"),
/*typeArguments*/ undefined,
@@ -3068,7 +3068,7 @@ namespace ts {
);
}
export function createExpressionForJsxElement(jsxFactoryEntity: EntityName, reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression {
export function createExpressionForJsxElement(jsxFactoryEntity: EntityName, reactNamespace: string, tagName: Expression, props: Expression, children: ReadonlyArray<Expression>, parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression {
const argumentsList = [tagName];
if (props) {
argumentsList.push(props);
@@ -3100,7 +3100,7 @@ namespace ts {
);
}
export function createExpressionForJsxFragment(jsxFactoryEntity: EntityName, reactNamespace: string, children: Expression[], parentElement: JsxOpeningFragment, location: TextRange): LeftHandSideExpression {
export function createExpressionForJsxFragment(jsxFactoryEntity: EntityName, reactNamespace: string, children: ReadonlyArray<Expression>, parentElement: JsxOpeningFragment, location: TextRange): LeftHandSideExpression {
const tagName = createPropertyAccess(
createReactNamespace(reactNamespace, parentElement),
"Fragment"
@@ -3213,7 +3213,7 @@ namespace ts {
};`
};
export function createSpreadHelper(context: TransformationContext, argumentList: Expression[], location?: TextRange) {
export function createSpreadHelper(context: TransformationContext, argumentList: ReadonlyArray<Expression>, location?: TextRange) {
context.requestEmitHelper(readHelper);
context.requestEmitHelper(spreadHelper);
return setTextRange(
@@ -3383,7 +3383,7 @@ namespace ts {
return { target, thisArg };
}
export function inlineExpressions(expressions: Expression[]) {
export function inlineExpressions(expressions: ReadonlyArray<Expression>) {
// Avoid deeply nested comma expressions as traversing them during emit can result in "Maximum call
// stack size exceeded" errors.
return expressions.length > 10