Skip to content

Commit 8dc9523

Browse files
author
Andy Hanson
committed
Allow number too
1 parent 1f7f67d commit 8dc9523

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ namespace ts {
368368
return emitResolver;
369369
}
370370

371-
function error(location: Node, message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void {
371+
function error(location: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): void {
372372
const diagnostic = location
373373
? createDiagnosticForNode(location, message, arg0, arg1, arg2)
374374
: createCompilerDiagnostic(message, arg0, arg1, arg2);
@@ -3004,8 +3004,7 @@ namespace ts {
30043004
: elementType;
30053005
if (!type) {
30063006
if (isTupleType(parentType)) {
3007-
error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2,
3008-
typeToString(parentType), getTypeReferenceArity(<TypeReference>parentType).toString(), pattern.elements.length.toString());
3007+
error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(<TypeReference>parentType), pattern.elements.length);
30093008
}
30103009
else {
30113010
error(declaration, Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName);
@@ -5104,7 +5103,7 @@ namespace ts {
51045103
const typeParameters = type.localTypeParameters;
51055104
if (typeParameters) {
51065105
if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) {
5107-
error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType), typeParameters.length.toString());
5106+
error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType), typeParameters.length);
51085107
return unknownType;
51095108
}
51105109
// In a type reference, the outer type parameters of the referenced class or interface are automatically
@@ -5128,7 +5127,7 @@ namespace ts {
51285127
const typeParameters = links.typeParameters;
51295128
if (typeParameters) {
51305129
if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) {
5131-
error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length.toString());
5130+
error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length);
51325131
return unknownType;
51335132
}
51345133
const typeArguments = map(node.typeArguments, getTypeFromTypeNodeNoAlias);
@@ -5271,7 +5270,7 @@ namespace ts {
52715270
return arity ? emptyGenericType : emptyObjectType;
52725271
}
52735272
if (((<InterfaceType>type).typeParameters ? (<InterfaceType>type).typeParameters.length : 0) !== arity) {
5274-
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity.toString());
5273+
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity);
52755274
return arity ? emptyGenericType : emptyObjectType;
52765275
}
52775276
return <ObjectType>type;
@@ -13631,8 +13630,7 @@ namespace ts {
1363113630
// such as NodeCheckFlags.LexicalThis on "this"expression.
1363213631
checkExpression(element);
1363313632
if (isTupleType(sourceType)) {
13634-
error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2,
13635-
typeToString(sourceType), getTypeReferenceArity(<TypeReference>sourceType).toString(), elements.length.toString());
13633+
error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(<TypeReference>sourceType), elements.length);
1363613634
}
1363713635
else {
1363813636
error(element, Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName);

src/compiler/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ namespace ts {
952952
return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
953953
}
954954

955-
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: string[]): Diagnostic;
955+
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
956956
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
957957
const end = start + length;
958958

@@ -992,7 +992,7 @@ namespace ts {
992992
return text;
993993
}
994994

995-
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: string[]): Diagnostic;
995+
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
996996
export function createCompilerDiagnostic(message: DiagnosticMessage): Diagnostic {
997997
let text = getLocaleSpecificMessage(message);
998998

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ namespace ts {
503503
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
504504
}
505505

506-
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): Diagnostic {
506+
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic {
507507
const sourceFile = getSourceFileOfNode(node);
508508
const span = getErrorSpanForNode(sourceFile, node);
509509
return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2);

0 commit comments

Comments
 (0)