Move grammar checking: callSignature, constructorType, ConstructSignature, FunctionType, IndexSignature

This commit is contained in:
Yui T
2014-12-10 18:39:24 -08:00
parent 16693316e5
commit 31e49ed93e
14 changed files with 314 additions and 91 deletions
+277 -48
View File
@@ -8667,54 +8667,6 @@ module ts {
return <Identifier>node;
}
// GRAMMAR CHECKING
function checkGrammarForDisallowedTrailingComma(list: NodeArray<Node>): boolean {
if (list && list.hasTrailingComma) {
var start = list.end - ",".length;
var end = list.end;
var sourceFile = getSourceFileOfNode(list[0]);
grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Trailing_comma_not_allowed);
return true;
}
}
function hasParseDiagnostics(sourceFile: SourceFile): boolean {
return sourceFile.parseDiagnostics.length > 0;
}
function scanToken(scanner: Scanner, pos: number) {
scanner.setTextPos(pos);
scanner.scan();
var start = scanner.getTokenPos();
scanner.setTextPos(start);
scanner.scan();
return start;
}
function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void {
var sourceFile = getSourceFileOfNode(node);
if (!hasParseDiagnostics(sourceFile)) {
var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text);
var start = scanToken(scanner, node.pos);
diagnostics.push(createFileDiagnostic(sourceFile, start, scanner.getTextPos() - start, message, arg0, arg1, arg2));
}
}
function grammarErrorAtPos(sourceFile: SourceFile, start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void {
if (!hasParseDiagnostics(sourceFile)) {
diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2));
}
}
function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void {
var sourceFile = getSourceFileOfNode(node);
if (!hasParseDiagnostics(sourceFile)) {
var span = getErrorSpanForNode(node);
var start = span.end > span.pos ? skipTrivia(sourceFile.text, span.pos) : span.pos;
diagnostics.push(createFileDiagnostic(sourceFile, start, span.end - start, message, arg0, arg1, arg2));
}
}
function checkImportDeclaration(node: ImportDeclaration) {
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
@@ -8803,7 +8755,12 @@ module ts {
case SyntaxKind.ConstructorType:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
// Grammar checking
checkGrammarSignatureDeclaration(<SignatureDeclaration>node)
return checkSignatureDeclaration(<SignatureDeclaration>node);
case SyntaxKind.IndexSignature:
// Grammar checking
checkGrammarIndexSignature(<SignatureDeclaration>node);
return checkSignatureDeclaration(<SignatureDeclaration>node);
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
@@ -9682,6 +9639,278 @@ module ts {
anyArrayType = createArrayType(anyType);
}
// GRAMMAR CHECKING
function checkModifiers(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.Constructor:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.IndexSignature:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ExportAssignment:
case SyntaxKind.VariableStatement:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.ImportDeclaration:
case SyntaxKind.Parameter:
break;
default:
return false;
}
if (!node.modifiers) {
return;
}
var lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node;
var flags = 0;
for (var i = 0, n = node.modifiers.length; i < n; i++) {
var modifier = node.modifiers[i];
switch (modifier.kind) {
case SyntaxKind.PublicKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.PrivateKeyword:
var text: string;
if (modifier.kind === SyntaxKind.PublicKeyword) {
text = "public";
}
else if (modifier.kind === SyntaxKind.ProtectedKeyword) {
text = "protected";
lastProtected = modifier;
}
else {
text = "private";
lastPrivate = modifier;
}
if (flags & NodeFlags.AccessibilityModifier) {
return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen);
}
else if (flags & NodeFlags.Static) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
}
else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text);
}
flags |= modifierToFlag(modifier.kind);
break;
case SyntaxKind.StaticKeyword:
if (flags & NodeFlags.Static) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "static");
}
else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static");
}
else if (node.kind === SyntaxKind.Parameter) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
}
flags |= NodeFlags.Static;
lastStatic = modifier;
break;
case SyntaxKind.ExportKeyword:
if (flags & NodeFlags.Export) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "export");
}
else if (flags & NodeFlags.Ambient) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
}
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
}
else if (node.kind === SyntaxKind.Parameter) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
}
flags |= NodeFlags.Export;
break;
case SyntaxKind.DeclareKeyword:
// TODO (yuisu) : Bring back the parser grammar checking
break;
}
}
if (node.kind === SyntaxKind.Constructor) {
if (flags & NodeFlags.Static) {
return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
}
else if (flags & NodeFlags.Protected) {
return grammarErrorOnNode(lastProtected, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected");
}
else if (flags & NodeFlags.Private) {
return grammarErrorOnNode(lastPrivate, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private");
}
}
else if (node.kind === SyntaxKind.ImportDeclaration && flags & NodeFlags.Ambient) {
return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare");
}
else if (node.kind === SyntaxKind.InterfaceDeclaration && flags & NodeFlags.Ambient) {
return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare");
}
}
function checkGrammarForDisallowedTrailingComma(list: NodeArray<Node>): boolean {
if (list && list.hasTrailingComma) {
var start = list.end - ",".length;
var end = list.end;
var sourceFile = getSourceFileOfNode(list[0]);
return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Trailing_comma_not_allowed);
}
}
function checkGrammarTypeParameterList(signatureDecl: SignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration>): boolean {
if (checkGrammarForDisallowedTrailingComma(typeParameters)) {
return true;
}
if (typeParameters && typeParameters.length === 0) {
var start = typeParameters.pos - "<".length;
var sourceFile = getSourceFileOfNode(signatureDecl);
var end = skipTrivia(sourceFile.text, typeParameters.end) + ">".length;
return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty);
}
}
function checkGrammarParameterList(parameters: NodeArray<ParameterDeclaration>) {
if (checkGrammarForDisallowedTrailingComma(parameters)) {
return true;
}
var seenOptionalParameter = false;
var parameterCount = parameters.length;
for (var i = 0; i < parameterCount; i++) {
var parameter = parameters[i];
if (parameter.dotDotDotToken) {
if (i !== (parameterCount - 1)) {
return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
}
if (parameter.questionToken) {
return grammarErrorOnNode(parameter.questionToken, Diagnostics.A_rest_parameter_cannot_be_optional);
}
if (parameter.initializer) {
return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_have_an_initializer);
}
}
else if (parameter.questionToken || parameter.initializer) {
seenOptionalParameter = true;
if (parameter.questionToken && parameter.initializer) {
return grammarErrorOnNode(parameter.name, Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
}
}
else {
if (seenOptionalParameter) {
return grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
}
}
}
}
function checkGrammarSignatureDeclaration(node: SignatureDeclaration) {
if (!checkGrammarTypeParameterList(node, node.typeParameters)) {
checkGrammarParameterList(node.parameters);
}
}
function checkGrammarIndexSignatureParameters(node: SignatureDeclaration): boolean {
var parameter = node.parameters[0];
if (node.parameters.length !== 1) {
if (parameter) {
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_must_have_exactly_one_parameter);
}
else {
return grammarErrorOnNode(node, Diagnostics.An_index_signature_must_have_exactly_one_parameter);
}
}
else if (parameter.dotDotDotToken) {
return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.An_index_signature_cannot_have_a_rest_parameter);
}
else if (parameter.flags & NodeFlags.Modifier) {
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier);
}
else if (parameter.questionToken) {
return grammarErrorOnNode(parameter.questionToken, Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark);
}
else if (parameter.initializer) {
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_cannot_have_an_initializer);
}
else if (!parameter.type) {
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
}
else if (parameter.type.kind !== SyntaxKind.StringKeyword && parameter.type.kind !== SyntaxKind.NumberKeyword) {
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_type_must_be_string_or_number);
}
else if (!node.type) {
return grammarErrorOnNode(node, Diagnostics.An_index_signature_must_have_a_type_annotation);
}
}
function checkGrammarForIndexSignatureModifier(node: SignatureDeclaration): void {
if (node.flags & NodeFlags.Modifier) {
grammarErrorOnFirstToken(node, Diagnostics.Modifiers_not_permitted_on_index_signature_members);
}
}
function checkGrammarIndexSignature(node: SignatureDeclaration) {
var hasErrorFromCheckModifiersOrParameters = checkModifiers(node) ? true: checkGrammarIndexSignatureParameters(node);
if (!hasErrorFromCheckModifiersOrParameters) {
checkGrammarForIndexSignatureModifier(node);
}
}
function hasParseDiagnostics(sourceFile: SourceFile): boolean {
return sourceFile.parseDiagnostics.length > 0;
}
function scanToken(scanner: Scanner, pos: number) {
scanner.setTextPos(pos);
scanner.scan();
var start = scanner.getTokenPos();
scanner.setTextPos(start);
scanner.scan();
return start;
}
function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
var sourceFile = getSourceFileOfNode(node);
if (!hasParseDiagnostics(sourceFile)) {
var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text);
var start = scanToken(scanner, node.pos);
diagnostics.push(createFileDiagnostic(sourceFile, start, scanner.getTextPos() - start, message, arg0, arg1, arg2));
return true;
}
}
function grammarErrorAtPos(sourceFile: SourceFile, start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
if (!hasParseDiagnostics(sourceFile)) {
diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2));
return true;
}
}
function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
var sourceFile = getSourceFileOfNode(node);
if (!hasParseDiagnostics(sourceFile)) {
var span = getErrorSpanForNode(node);
var start = span.end > span.pos ? skipTrivia(sourceFile.text, span.pos) : span.pos;
diagnostics.push(createFileDiagnostic(sourceFile, start, span.end - start, message, arg0, arg1, arg2));
return true;
}
}
initializeTypeChecker();
return checker;
+1 -7
View File
@@ -1002,7 +1002,7 @@ module ts {
return false;
}
function modifierToFlag(token: SyntaxKind): NodeFlags {
export function modifierToFlag(token: SyntaxKind): NodeFlags {
switch (token) {
case SyntaxKind.StaticKeyword: return NodeFlags.Static;
case SyntaxKind.PublicKeyword: return NodeFlags.Public;
@@ -4626,10 +4626,6 @@ module ts {
// Now do node specific checks.
switch (nodeKind) {
case SyntaxKind.ArrowFunction:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructorType:
case SyntaxKind.ConstructSignature:
case SyntaxKind.FunctionType:
return checkAnySignatureDeclaration(<FunctionLikeDeclaration>node);
case SyntaxKind.BreakStatement:
case SyntaxKind.ContinueStatement:
@@ -4655,7 +4651,6 @@ module ts {
case SyntaxKind.FunctionExpression: return checkFunctionExpression(<FunctionExpression>node);
case SyntaxKind.GetAccessor: return checkGetAccessor(<MethodDeclaration>node);
case SyntaxKind.HeritageClause: return checkHeritageClause(<HeritageClause>node);
case SyntaxKind.IndexSignature: return checkIndexSignature(<SignatureDeclaration>node);
case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(<InterfaceDeclaration>node);
case SyntaxKind.LabeledStatement: return checkLabeledStatement(<LabeledStatement>node);
case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(<PropertyAssignment>node);
@@ -5335,7 +5330,6 @@ module ts {
case SyntaxKind.PropertySignature:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.IndexSignature:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.ModuleDeclaration:
@@ -2,15 +2,15 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWith
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(4,22): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(5,22): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(15,9): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(34,6): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(44,9): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(46,9): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(34,6): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(34,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS2322: Type 'string' is not assignable to type 'number'.
@@ -1,8 +1,8 @@
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,19): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(8,16): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(10,21): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(11,22): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(11,26): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,19): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,22): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,26): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(14,23): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
@@ -1,8 +1,8 @@
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,11): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(8,8): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(10,13): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(11,14): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(11,18): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,11): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,14): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,18): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(14,13): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
@@ -1,8 +1,8 @@
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,11): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(8,8): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(10,13): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(11,14): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(11,18): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,11): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,14): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,18): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(14,13): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
@@ -1,8 +1,8 @@
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,19): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(8,16): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(10,21): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(11,22): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(11,26): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,19): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,22): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,26): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(14,23): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
+16 -16
View File
@@ -5,8 +5,6 @@ tests/cases/compiler/giant.ts(30,17): error TS1056: Accessors are only available
tests/cases/compiler/giant.ts(34,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(61,5): error TS1169: Computed property names are not allowed in interfaces.
tests/cases/compiler/giant.ts(62,5): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(63,6): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(88,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(90,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(92,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
@@ -14,8 +12,6 @@ tests/cases/compiler/giant.ts(94,21): error TS1056: Accessors are only available
tests/cases/compiler/giant.ts(98,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(100,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(125,9): error TS1169: Computed property names are not allowed in interfaces.
tests/cases/compiler/giant.ts(126,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(127,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(154,39): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(167,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(169,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
@@ -24,8 +20,6 @@ tests/cases/compiler/giant.ts(173,21): error TS1056: Accessors are only availabl
tests/cases/compiler/giant.ts(177,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(179,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(204,9): error TS1169: Computed property names are not allowed in interfaces.
tests/cases/compiler/giant.ts(205,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(206,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(233,39): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(238,35): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(240,24): error TS1111: A constructor implementation cannot be declared in an ambient context.
@@ -55,8 +49,6 @@ tests/cases/compiler/giant.ts(288,17): error TS1056: Accessors are only availabl
tests/cases/compiler/giant.ts(292,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(294,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(319,5): error TS1169: Computed property names are not allowed in interfaces.
tests/cases/compiler/giant.ts(320,5): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(321,6): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(346,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(348,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(350,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
@@ -64,8 +56,6 @@ tests/cases/compiler/giant.ts(352,21): error TS1056: Accessors are only availabl
tests/cases/compiler/giant.ts(356,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(358,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(383,9): error TS1169: Computed property names are not allowed in interfaces.
tests/cases/compiler/giant.ts(384,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(385,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(412,39): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(425,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(427,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
@@ -74,8 +64,6 @@ tests/cases/compiler/giant.ts(431,21): error TS1056: Accessors are only availabl
tests/cases/compiler/giant.ts(435,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(437,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(462,9): error TS1169: Computed property names are not allowed in interfaces.
tests/cases/compiler/giant.ts(463,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(464,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(491,39): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(496,35): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(498,24): error TS1111: A constructor implementation cannot be declared in an ambient context.
@@ -121,8 +109,6 @@ tests/cases/compiler/giant.ts(558,24): error TS1111: A constructor implementatio
tests/cases/compiler/giant.ts(561,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(563,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(587,9): error TS1169: Computed property names are not allowed in interfaces.
tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(606,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(606,25): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(611,30): error TS1037: A function implementation cannot be declared in an ambient context.
@@ -138,8 +124,6 @@ tests/cases/compiler/giant.ts(623,24): error TS1111: A constructor implementatio
tests/cases/compiler/giant.ts(626,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(628,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(653,9): error TS1169: Computed property names are not allowed in interfaces.
tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(672,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(672,25): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(676,30): error TS1037: A function implementation cannot be declared in an ambient context.
@@ -156,6 +140,8 @@ tests/cases/compiler/giant.ts(33,12): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(34,16): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(35,12): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(36,16): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(62,5): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(63,6): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(76,5): error TS2386: Overload signatures must all be optional or required.
tests/cases/compiler/giant.ts(87,16): error TS2300: Duplicate identifier 'pgF'.
tests/cases/compiler/giant.ts(88,20): error TS2300: Duplicate identifier 'pgF'.
@@ -169,6 +155,8 @@ tests/cases/compiler/giant.ts(97,16): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(98,20): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(99,16): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(100,20): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(126,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(127,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(140,9): error TS2386: Overload signatures must all be optional or required.
tests/cases/compiler/giant.ts(166,16): error TS2300: Duplicate identifier 'pgF'.
tests/cases/compiler/giant.ts(167,20): error TS2300: Duplicate identifier 'pgF'.
@@ -182,6 +170,8 @@ tests/cases/compiler/giant.ts(176,16): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(177,20): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(178,16): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(179,20): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(205,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(206,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(219,9): error TS2386: Overload signatures must all be optional or required.
tests/cases/compiler/giant.ts(245,16): error TS2300: Duplicate identifier 'pgF'.
tests/cases/compiler/giant.ts(246,20): error TS2300: Duplicate identifier 'pgF'.
@@ -207,6 +197,8 @@ tests/cases/compiler/giant.ts(291,12): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(292,16): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(293,12): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(294,16): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(320,5): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(321,6): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(334,5): error TS2386: Overload signatures must all be optional or required.
tests/cases/compiler/giant.ts(345,16): error TS2300: Duplicate identifier 'pgF'.
tests/cases/compiler/giant.ts(346,20): error TS2300: Duplicate identifier 'pgF'.
@@ -220,6 +212,8 @@ tests/cases/compiler/giant.ts(355,16): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(356,20): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(357,16): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(358,20): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(384,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(385,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(398,9): error TS2386: Overload signatures must all be optional or required.
tests/cases/compiler/giant.ts(424,16): error TS2300: Duplicate identifier 'pgF'.
tests/cases/compiler/giant.ts(425,20): error TS2300: Duplicate identifier 'pgF'.
@@ -233,6 +227,8 @@ tests/cases/compiler/giant.ts(434,16): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(435,20): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(436,16): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(437,20): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(463,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(464,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(477,9): error TS2386: Overload signatures must all be optional or required.
tests/cases/compiler/giant.ts(503,16): error TS2300: Duplicate identifier 'pgF'.
tests/cases/compiler/giant.ts(504,20): error TS2300: Duplicate identifier 'pgF'.
@@ -258,7 +254,11 @@ tests/cases/compiler/giant.ts(549,12): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(550,16): error TS2300: Duplicate identifier 'tsF'.
tests/cases/compiler/giant.ts(551,12): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(552,16): error TS2300: Duplicate identifier 'tgF'.
tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(602,9): error TS2386: Overload signatures must all be optional or required.
tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all be optional or required.
@@ -1,6 +1,6 @@
tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(2,5): error TS1169: Computed property names are not allowed in interfaces.
tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(7,5): error TS1166: Computed property names are not allowed in class property declarations.
tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021: An index signature must have a type annotation.
@@ -1,22 +1,22 @@
tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(2,13): error TS1018: An index signature parameter cannot have an accessibility modifier.
tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(6,13): error TS1018: An index signature parameter cannot have an accessibility modifier.
tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(2,6): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(2,13): error TS1018: An index signature parameter cannot have an accessibility modifier.
tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(6,6): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(6,13): error TS1018: An index signature parameter cannot have an accessibility modifier.
==== tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts (4 errors) ====
interface I {
[public x: string]: string;
~
!!! error TS1018: An index signature parameter cannot have an accessibility modifier.
~~~~~~~~~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
~
!!! error TS1018: An index signature parameter cannot have an accessibility modifier.
}
class C {
[public x: string]: string
~
!!! error TS1018: An index signature parameter cannot have an accessibility modifier.
~~~~~~~~~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
~
!!! error TS1018: An index signature parameter cannot have an accessibility modifier.
}
@@ -1,10 +1,10 @@
tests/cases/compiler/indexTypeCheck.ts(2,2): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/indexTypeCheck.ts(3,2): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'.
tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
@@ -1,12 +1,12 @@
tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature2.ts(2,11): error TS1018: An index signature parameter cannot have an accessibility modifier.
tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature2.ts(2,4): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature2.ts(2,11): error TS1018: An index signature parameter cannot have an accessibility modifier.
==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature2.ts (2 errors) ====
interface I {
[public a]
~
!!! error TS1018: An index signature parameter cannot have an accessibility modifier.
~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
~
!!! error TS1018: An index signature parameter cannot have an accessibility modifier.
}
@@ -1,5 +1,5 @@
tests/cases/conformance/parser/ecmascript5/ObjectTypes/parserObjectType6.ts(3,4): error TS1096: An index signature must have exactly one parameter.
tests/cases/conformance/parser/ecmascript5/ObjectTypes/parserObjectType6.ts(2,7): error TS2304: Cannot find name 'B'.
tests/cases/conformance/parser/ecmascript5/ObjectTypes/parserObjectType6.ts(3,4): error TS1096: An index signature must have exactly one parameter.
==== tests/cases/conformance/parser/ecmascript5/ObjectTypes/parserObjectType6.ts (2 errors) ====
@@ -23,7 +23,7 @@ tests/cases/compiler/typeParameterConstraints1.ts(12,26): error TS2304: Cannot f
~
!!! error TS1110: Type expected.
function foo10<T extends (1)> (test: T) { }
~~~
~
!!! error TS1110: Type expected.
function foo11<T extends null> (test: T) { }
~~~~