@@ -2670,7 +2670,7 @@ namespace ts {
2670
2670
entityName = nameIdentifier;
2671
2671
}
2672
2672
2673
- let typeArgumentNodes: TypeNode[] | undefined;
2673
+ let typeArgumentNodes: ReadonlyArray< TypeNode> | undefined;
2674
2674
if (typeArguments.length > 0) {
2675
2675
const typeParameterCount = (type.target.typeParameters || emptyArray).length;
2676
2676
typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
@@ -2907,7 +2907,7 @@ namespace ts {
2907
2907
function createEntityNameFromSymbolChain(chain: Symbol[], index: number): EntityName {
2908
2908
Debug.assert(chain && 0 <= index && index < chain.length);
2909
2909
const symbol = chain[index];
2910
- let typeParameterNodes: TypeNode[] | undefined;
2910
+ let typeParameterNodes: ReadonlyArray< TypeNode> | undefined;
2911
2911
if (context.flags & NodeBuilderFlags.WriteTypeParametersInQualifiedName && index > 0) {
2912
2912
const parentSymbol = chain[index - 1];
2913
2913
let typeParameters: TypeParameter[];
@@ -3667,15 +3667,15 @@ namespace ts {
3667
3667
}
3668
3668
}
3669
3669
3670
- function buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[] , writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
3670
+ function buildDisplayForTypeParametersAndDelimiters(typeParameters: ReadonlyArray< TypeParameter> , writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
3671
3671
if (typeParameters && typeParameters.length) {
3672
3672
writePunctuation(writer, SyntaxKind.LessThanToken);
3673
3673
buildDisplayForCommaSeparatedList(typeParameters, writer, p => buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack));
3674
3674
writePunctuation(writer, SyntaxKind.GreaterThanToken);
3675
3675
}
3676
3676
}
3677
3677
3678
- function buildDisplayForCommaSeparatedList<T>(list: T[] , writer: SymbolWriter, action: (item: T) => void) {
3678
+ function buildDisplayForCommaSeparatedList<T>(list: ReadonlyArray<T> , writer: SymbolWriter, action: (item: T) => void) {
3679
3679
for (let i = 0; i < list.length; i++) {
3680
3680
if (i > 0) {
3681
3681
writePunctuation(writer, SyntaxKind.CommaToken);
@@ -3685,7 +3685,7 @@ namespace ts {
3685
3685
}
3686
3686
}
3687
3687
3688
- function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: TypeParameter[] , mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node) {
3688
+ function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: ReadonlyArray< TypeParameter> , mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node) {
3689
3689
if (typeParameters && typeParameters.length) {
3690
3690
writePunctuation(writer, SyntaxKind.LessThanToken);
3691
3691
let flags = TypeFormatFlags.InFirstTypeArgument;
@@ -4738,7 +4738,7 @@ namespace ts {
4738
4738
// Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set.
4739
4739
// The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set
4740
4740
// in-place and returns the same array.
4741
- function appendTypeParameters(typeParameters: TypeParameter[], declarations: TypeParameterDeclaration[] ): TypeParameter[] {
4741
+ function appendTypeParameters(typeParameters: TypeParameter[], declarations: ReadonlyArray< TypeParameterDeclaration> ): TypeParameter[] {
4742
4742
for (const declaration of declarations) {
4743
4743
const tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration));
4744
4744
if (!typeParameters) {
@@ -4825,14 +4825,14 @@ namespace ts {
4825
4825
return getClassExtendsHeritageClauseElement(<ClassLikeDeclaration>type.symbol.valueDeclaration);
4826
4826
}
4827
4827
4828
- function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[] , location: Node): Signature[] {
4828
+ function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray< TypeNode> , location: Node): Signature[] {
4829
4829
const typeArgCount = length(typeArgumentNodes);
4830
4830
const isJavaScript = isInJavaScriptFile(location);
4831
4831
return filter(getSignaturesOfType(type, SignatureKind.Construct),
4832
4832
sig => (isJavaScript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= length(sig.typeParameters));
4833
4833
}
4834
4834
4835
- function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[] , location: Node): Signature[] {
4835
+ function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray< TypeNode> , location: Node): Signature[] {
4836
4836
const signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
4837
4837
const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode);
4838
4838
return sameMap(signatures, sig => some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments) : sig);
@@ -14906,7 +14906,7 @@ namespace ts {
14906
14906
}
14907
14907
}
14908
14908
14909
- function getSpreadArgumentIndex(args: Expression[] ): number {
14909
+ function getSpreadArgumentIndex(args: ReadonlyArray< Expression> ): number {
14910
14910
for (let i = 0; i < args.length; i++) {
14911
14911
const arg = args[i];
14912
14912
if (arg && arg.kind === SyntaxKind.SpreadElement) {
@@ -14916,7 +14916,7 @@ namespace ts {
14916
14916
return -1;
14917
14917
}
14918
14918
14919
- function hasCorrectArity(node: CallLikeExpression, args: Expression[] , signature: Signature, signatureHelpTrailingComma = false) {
14919
+ function hasCorrectArity(node: CallLikeExpression, args: ReadonlyArray< Expression> , signature: Signature, signatureHelpTrailingComma = false) {
14920
14920
let argCount: number; // Apparent number of arguments we will have in this call
14921
14921
let typeArguments: NodeArray<TypeNode>; // Type arguments (undefined if none)
14922
14922
let callIsIncomplete: boolean; // In incomplete call we want to be lenient when we have too few arguments
@@ -15027,7 +15027,7 @@ namespace ts {
15027
15027
return getSignatureInstantiation(signature, getInferredTypes(context));
15028
15028
}
15029
15029
15030
- function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: Expression[] , excludeArgument: boolean[], context: InferenceContext): Type[] {
15030
+ function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: ReadonlyArray< Expression> , excludeArgument: boolean[], context: InferenceContext): Type[] {
15031
15031
// Clear out all the inference results from the last time inferTypeArguments was called on this context
15032
15032
for (const inference of context.inferences) {
15033
15033
// As an optimization, we don't have to clear (and later recompute) inferred types
@@ -15115,7 +15115,7 @@ namespace ts {
15115
15115
return getInferredTypes(context);
15116
15116
}
15117
15117
15118
- function checkTypeArguments(signature: Signature, typeArgumentNodes: TypeNode[] , typeArgumentTypes: Type[], reportErrors: boolean, headMessage?: DiagnosticMessage): boolean {
15118
+ function checkTypeArguments(signature: Signature, typeArgumentNodes: ReadonlyArray< TypeNode> , typeArgumentTypes: Type[], reportErrors: boolean, headMessage?: DiagnosticMessage): boolean {
15119
15119
const typeParameters = signature.typeParameters;
15120
15120
let typeArgumentsAreAssignable = true;
15121
15121
let mapper: TypeMapper;
@@ -15179,7 +15179,13 @@ namespace ts {
15179
15179
return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage);
15180
15180
}
15181
15181
15182
- function checkApplicableSignature(node: CallLikeExpression, args: Expression[], signature: Signature, relation: Map<RelationComparisonResult>, excludeArgument: boolean[], reportErrors: boolean) {
15182
+ function checkApplicableSignature(
15183
+ node: CallLikeExpression,
15184
+ args: ReadonlyArray<Expression>,
15185
+ signature: Signature,
15186
+ relation: Map<RelationComparisonResult>,
15187
+ excludeArgument: boolean[],
15188
+ reportErrors: boolean) {
15183
15189
if (isJsxOpeningLikeElement(node)) {
15184
15190
return checkApplicableSignatureForJsxOpeningLikeElement(<JsxOpeningLikeElement>node, signature, relation);
15185
15191
}
@@ -15247,16 +15253,16 @@ namespace ts {
15247
15253
* If 'node' is a Decorator, the argument list will be `undefined`, and its arguments and types
15248
15254
* will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`.
15249
15255
*/
15250
- function getEffectiveCallArguments(node: CallLikeExpression): Expression[] {
15251
- let args: Expression[];
15256
+ function getEffectiveCallArguments(node: CallLikeExpression): ReadonlyArray<Expression> {
15252
15257
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
15253
15258
const template = (<TaggedTemplateExpression>node).template;
15254
- args = [undefined];
15259
+ const args: Expression[] = [undefined];
15255
15260
if (template.kind === SyntaxKind.TemplateExpression) {
15256
15261
forEach((<TemplateExpression>template).templateSpans, span => {
15257
15262
args.push(span.expression);
15258
15263
});
15259
15264
}
15265
+ return args;
15260
15266
}
15261
15267
else if (node.kind === SyntaxKind.Decorator) {
15262
15268
// For a decorator, we return undefined as we will determine
@@ -15265,13 +15271,11 @@ namespace ts {
15265
15271
return undefined;
15266
15272
}
15267
15273
else if (isJsxOpeningLikeElement(node)) {
15268
- args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray;
15274
+ return node.attributes.properties.length > 0 ? [node.attributes] : emptyArray;
15269
15275
}
15270
15276
else {
15271
- args = node.arguments || emptyArray;
15277
+ return node.arguments || emptyArray;
15272
15278
}
15273
-
15274
- return args;
15275
15279
}
15276
15280
15277
15281
@@ -15288,7 +15292,7 @@ namespace ts {
15288
15292
* us to match a property decorator.
15289
15293
* Otherwise, the argument count is the length of the 'args' array.
15290
15294
*/
15291
- function getEffectiveArgumentCount(node: CallLikeExpression, args: Expression[] , signature: Signature) {
15295
+ function getEffectiveArgumentCount(node: CallLikeExpression, args: ReadonlyArray< Expression> , signature: Signature) {
15292
15296
if (node.kind === SyntaxKind.Decorator) {
15293
15297
switch (node.parent.kind) {
15294
15298
case SyntaxKind.ClassDeclaration:
@@ -15520,7 +15524,7 @@ namespace ts {
15520
15524
/**
15521
15525
* Gets the effective argument expression for an argument in a call expression.
15522
15526
*/
15523
- function getEffectiveArgument(node: CallLikeExpression, args: Expression[] , argIndex: number) {
15527
+ function getEffectiveArgument(node: CallLikeExpression, args: ReadonlyArray< Expression> , argIndex: number) {
15524
15528
// For a decorator or the first argument of a tagged template expression we return undefined.
15525
15529
if (node.kind === SyntaxKind.Decorator ||
15526
15530
(argIndex === 0 && node.kind === SyntaxKind.TaggedTemplateExpression)) {
@@ -15552,7 +15556,7 @@ namespace ts {
15552
15556
const isDecorator = node.kind === SyntaxKind.Decorator;
15553
15557
const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
15554
15558
15555
- let typeArguments: TypeNode[] ;
15559
+ let typeArguments: ReadonlyArray< TypeNode> ;
15556
15560
15557
15561
if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) {
15558
15562
typeArguments = (<CallExpression>node).typeArguments;
@@ -17065,7 +17069,7 @@ namespace ts {
17065
17069
}
17066
17070
17067
17071
/** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */
17068
- function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike, allProperties?: ObjectLiteralElementLike[] ) {
17072
+ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike, allProperties?: ReadonlyArray< ObjectLiteralElementLike> ) {
17069
17073
if (property.kind === SyntaxKind.PropertyAssignment || property.kind === SyntaxKind.ShorthandPropertyAssignment) {
17070
17074
const name = <PropertyName>(<PropertyAssignment>property).name;
17071
17075
if (name.kind === SyntaxKind.ComputedPropertyName) {
@@ -18509,7 +18513,7 @@ namespace ts {
18509
18513
checkDecorators(node);
18510
18514
}
18511
18515
18512
- function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArgumentNodes: TypeNode[] ): boolean {
18516
+ function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArgumentNodes: ReadonlyArray< TypeNode> ): boolean {
18513
18517
const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
18514
18518
let typeArguments: Type[];
18515
18519
let mapper: TypeMapper;
@@ -20955,7 +20959,7 @@ namespace ts {
20955
20959
/**
20956
20960
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
20957
20961
*/
20958
- function checkTypeParameters(typeParameterDeclarations: TypeParameterDeclaration[] ) {
20962
+ function checkTypeParameters(typeParameterDeclarations: ReadonlyArray< TypeParameterDeclaration> ) {
20959
20963
if (typeParameterDeclarations) {
20960
20964
let seenDefault = false;
20961
20965
for (let i = 0; i < typeParameterDeclarations.length; i++) {
0 commit comments