diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index bb00a967336..e1b970576ab 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -544,7 +544,7 @@ namespace ts { : node; } - export function createCallSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + export function createCallSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, 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 | undefined, parameters: ReadonlyArray, 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 | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, typeArguments?: TypeNode[] | undefined) { + export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, typeArguments?: ReadonlyArray | 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 | undefined, parameters: ReadonlyArray, 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 | undefined, parameters: ReadonlyArray, 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): UnionTypeNode { return 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): IntersectionTypeNode { return 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): CallExpression; + export function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + export function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, 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): CallExpression; + export function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + export function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, 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) { 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, 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, 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, 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) { // Avoid deeply nested comma expressions as traversing them during emit can result in "Maximum call // stack size exceeded" errors. return expressions.length > 10