Merge pull request #22261 from ajafff/factory-array

factory: replace Array parameters with ReadonlyArray
This commit is contained in:
Mohamed Hegazy
2018-04-03 15:00:56 -07:00
committed by GitHub
3 changed files with 38 additions and 38 deletions

View File

@@ -592,7 +592,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;
}
@@ -600,7 +600,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;
}
@@ -636,7 +636,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);
@@ -687,7 +687,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;
}
@@ -695,7 +695,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;
}
@@ -751,7 +751,7 @@ namespace ts {
: node;
}
export function createUnionTypeNode(types: TypeNode[]): UnionTypeNode {
export function createUnionTypeNode(types: ReadonlyArray<TypeNode>): UnionTypeNode {
return <UnionTypeNode>createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, types);
}
@@ -759,7 +759,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);
}
@@ -2572,9 +2572,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,
@@ -2590,9 +2590,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,
@@ -3093,7 +3093,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,
@@ -3145,7 +3145,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);
@@ -3177,7 +3177,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"
@@ -3288,7 +3288,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(
@@ -3458,7 +3458,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