@@ -2341,7 +2341,7 @@ namespace ts {
2341
2341
else if (!(flags & TypeFormatFlags.InTypeAlias) && type.aliasSymbol &&
2342
2342
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) {
2343
2343
const typeArguments = type.aliasTypeArguments;
2344
- writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments. length : 0 , nextFlags);
2344
+ writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, length(typeArguments) , nextFlags);
2345
2345
}
2346
2346
else if (type.flags & TypeFlags.UnionOrIntersection) {
2347
2347
writeUnionOrIntersectionType(<UnionOrIntersectionType>type, nextFlags);
@@ -3828,9 +3828,9 @@ namespace ts {
3828
3828
}
3829
3829
3830
3830
function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] {
3831
- const typeArgCount = typeArgumentNodes ? typeArgumentNodes. length : 0 ;
3831
+ const typeArgCount = length(typeArgumentNodes) ;
3832
3832
return filter(getSignaturesOfType(type, SignatureKind.Construct),
3833
- sig => typeArgCount >= sig.minTypeArgumentCount && typeArgCount <= (sig.typeParameters ? sig.typeParameters.length : 0 ));
3833
+ sig => typeArgCount >= sig.minTypeArgumentCount && typeArgCount <= length (sig.typeParameters));
3834
3834
}
3835
3835
3836
3836
function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] {
@@ -4431,11 +4431,11 @@ namespace ts {
4431
4431
}
4432
4432
const baseTypeNode = getBaseTypeNodeOfClass(classType);
4433
4433
const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode);
4434
- const typeArgCount = typeArguments ? typeArguments. length : 0 ;
4434
+ const typeArgCount = length(typeArguments) ;
4435
4435
const result: Signature[] = [];
4436
4436
for (const baseSig of baseSignatures) {
4437
4437
const minTypeArgumentCount = baseSig.minTypeArgumentCount;
4438
- const typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0 ;
4438
+ const typeParamCount = length( baseSig.typeParameters) ;
4439
4439
if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) {
4440
4440
const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig);
4441
4441
sig.typeParameters = classType.localTypeParameters;
@@ -5215,9 +5215,9 @@ namespace ts {
5215
5215
* @param minTypeArgumentCount The minimum number of required type arguments.
5216
5216
*/
5217
5217
function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number) {
5218
- const numTypeParameters = typeParameters ? typeParameters. length : 0 ;
5218
+ const numTypeParameters = length(typeParameters) ;
5219
5219
if (numTypeParameters) {
5220
- const numTypeArguments = typeArguments ? typeArguments. length : 0 ;
5220
+ const numTypeArguments = length(typeArguments) ;
5221
5221
if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) {
5222
5222
if (!typeArguments) {
5223
5223
typeArguments = [];
@@ -5601,15 +5601,15 @@ namespace ts {
5601
5601
}
5602
5602
5603
5603
function getTypeReferenceArity(type: TypeReference): number {
5604
- return type.target.typeParameters ? type.target.typeParameters.length : 0 ;
5604
+ return length( type.target.typeParameters) ;
5605
5605
}
5606
5606
5607
5607
// Get type from reference to class or interface
5608
5608
function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol): Type {
5609
5609
const type = <InterfaceType>getDeclaredTypeOfSymbol(getMergedSymbol(symbol));
5610
5610
const typeParameters = type.localTypeParameters;
5611
5611
if (typeParameters) {
5612
- const numTypeArguments = node.typeArguments ? node.typeArguments.length : 0 ;
5612
+ const numTypeArguments = length( node.typeArguments) ;
5613
5613
if (numTypeArguments < type.minTypeArgumentCount || numTypeArguments > typeParameters.length) {
5614
5614
error(node,
5615
5615
type.minTypeArgumentCount === typeParameters.length
@@ -5652,7 +5652,7 @@ namespace ts {
5652
5652
const type = getDeclaredTypeOfSymbol(symbol);
5653
5653
const { typeParameters, minTypeArgumentCount } = getSymbolLinks(symbol);
5654
5654
if (typeParameters) {
5655
- const numTypeArguments = node.typeArguments ? node.typeArguments.length : 0 ;
5655
+ const numTypeArguments = length( node.typeArguments) ;
5656
5656
if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
5657
5657
error(node,
5658
5658
minTypeArgumentCount === typeParameters.length
@@ -5798,7 +5798,7 @@ namespace ts {
5798
5798
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name);
5799
5799
return arity ? emptyGenericType : emptyObjectType;
5800
5800
}
5801
- if (((<InterfaceType>type).typeParameters ? (<InterfaceType>type).typeParameters.length : 0 ) !== arity) {
5801
+ if (length ((<InterfaceType>type).typeParameters) !== arity) {
5802
5802
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity);
5803
5803
return arity ? emptyGenericType : emptyObjectType;
5804
5804
}
@@ -8364,7 +8364,7 @@ namespace ts {
8364
8364
// the constraints with a common set of type arguments to get relatable entities in places where
8365
8365
// type parameters occur in the constraints. The complexity of doing that doesn't seem worthwhile,
8366
8366
// particularly as we're comparing erased versions of the signatures below.
8367
- if ((source.typeParameters ? source.typeParameters.length : 0 ) !== (target.typeParameters ? target.typeParameters.length : 0 )) {
8367
+ if (length (source.typeParameters) !== length (target.typeParameters)) {
8368
8368
return Ternary.False;
8369
8369
}
8370
8370
// Spec 1.0 Section 3.8.3 & 3.8.4:
@@ -12915,7 +12915,7 @@ namespace ts {
12915
12915
12916
12916
// If the user supplied type arguments, but the number of type arguments does not match
12917
12917
// the declared number of type parameters, the call has an incorrect arity.
12918
- const numTypeParameters = signature.typeParameters ? signature.typeParameters.length : 0 ;
12918
+ const numTypeParameters = length( signature.typeParameters) ;
12919
12919
const hasRightNumberOfTypeArgs = !typeArguments ||
12920
12920
(typeArguments.length >= signature.minTypeArgumentCount && typeArguments.length <= numTypeParameters);
12921
12921
if (!hasRightNumberOfTypeArgs) {
@@ -18482,8 +18482,8 @@ namespace ts {
18482
18482
resolveTypeParametersOfClassOrInterface(symbol);
18483
18483
18484
18484
const { typeParameters, minTypeArgumentCount } = getSymbolLinks(symbol);
18485
- const maxTypeArgumentCount = typeParameters ? typeParameters. length : 0 ;
18486
- const numTypeParameters = node.typeParameters ? node.typeParameters.length : 0 ;
18485
+ const maxTypeArgumentCount = length(typeParameters) ;
18486
+ const numTypeParameters = length( node.typeParameters) ;
18487
18487
18488
18488
// If this declaration has too few or too many type parameters, we report an error
18489
18489
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
@@ -18532,7 +18532,7 @@ namespace ts {
18532
18532
for (const declaration of symbol.declarations) {
18533
18533
if (declaration.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.InterfaceDeclaration) {
18534
18534
const typeParameterNodes = (<ClassDeclaration | InterfaceDeclaration>declaration).typeParameters;
18535
- const numTypeParameters = typeParameterNodes ? typeParameterNodes. length : 0 ;
18535
+ const numTypeParameters = length(typeParameterNodes) ;
18536
18536
if (maxTypeArgumentCount === -1) {
18537
18537
// For the first declaration, establish the initial maximum and
18538
18538
// minimum type argument counts. These only change when we
0 commit comments