Merge branch 'grammarChecks' of https://github.com/Microsoft/TypeScript into grammarChecks

This commit is contained in:
Vladimir Matveev 2014-11-19 14:20:17 -08:00
commit dab9ebba3e
19 changed files with 231 additions and 362 deletions

View File

@ -2682,20 +2682,12 @@ module ts {
function parseWithStatement(): WithStatement {
var node = <WithStatement>createNode(SyntaxKind.WithStatement);
var startPos = scanner.getTokenPos();
parseExpected(SyntaxKind.WithKeyword);
var endPos = scanner.getStartPos();
parseExpected(SyntaxKind.OpenParenToken);
node.expression = parseExpression();
parseExpected(SyntaxKind.CloseParenToken);
node.statement = parseStatement();
node = finishNode(node);
if (isInStrictMode) {
// Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such
// a context is an
grammarErrorAtPos(startPos, endPos - startPos, Diagnostics.with_statements_are_not_allowed_in_strict_mode);
}
return node;
return finishNode(node);
}
function parseCaseClause(): CaseOrDefaultClause {
@ -2730,16 +2722,6 @@ module ts {
node.clauses = parseList(ParsingContext.SwitchClauses, /*checkForStrictMode*/ false, parseCaseOrDefaultClause);
parseExpected(SyntaxKind.CloseBraceToken);
// Error on duplicate 'default' clauses.
var defaultClauses: CaseOrDefaultClause[] = filter(node.clauses, clause => clause.kind === SyntaxKind.DefaultClause);
for (var i = 1, n = defaultClauses.length; i < n; i++) {
var clause = defaultClauses[i];
var start = skipTrivia(file.text, clause.pos);
var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end;
grammarErrorAtPos(start, end - start, Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement);
}
return finishNode(node);
}
@ -2935,21 +2917,16 @@ module ts {
}
}
function parseAndCheckFunctionBody(isConstructor: boolean): Block {
var initialPosition = scanner.getTokenPos();
var errorCountBeforeBody = file._parserDiagnostics.length;
function parseFunctionBlockOrSemicolon(): Block {
if (token === SyntaxKind.OpenBraceToken) {
var body = parseBody(/* ignoreMissingOpenBrace */ false);
if (body && inAmbientContext && file._parserDiagnostics.length === errorCountBeforeBody) {
var diagnostic = isConstructor ? Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context;
grammarErrorAtPos(initialPosition, 1, diagnostic);
}
return body;
return parseBody(/* ignoreMissingOpenBrace */ false);
}
if (canParseSemicolon()) {
parseSemicolon();
return undefined;
}
error(Diagnostics.Block_or_expected); // block or ';' expected
}
@ -3004,7 +2981,7 @@ module ts {
node.typeParameters = sig.typeParameters;
node.parameters = sig.parameters;
node.type = sig.type;
node.body = parseAndCheckFunctionBody(/*isConstructor*/ false);
node.body = parseFunctionBlockOrSemicolon();
return finishNode(node);
}
@ -3016,7 +2993,7 @@ module ts {
node.typeParameters = sig.typeParameters;
node.parameters = sig.parameters;
node.type = sig.type;
node.body = parseAndCheckFunctionBody(/*isConstructor*/ true);
node.body = parseFunctionBlockOrSemicolon();
return finishNode(node);
}
@ -3037,7 +3014,7 @@ module ts {
method.typeParameters = sig.typeParameters;
method.parameters = sig.parameters;
method.type = sig.type;
method.body = parseAndCheckFunctionBody(/*isConstructor*/ false);
method.body = parseFunctionBlockOrSemicolon();
return finishNode(method);
}
else {
@ -3312,16 +3289,13 @@ module ts {
function parseClassDeclaration(pos: number, flags: NodeFlags): ClassDeclaration {
var node = <ClassDeclaration>createNode(SyntaxKind.ClassDeclaration, pos);
node.flags = flags;
var errorCountBeforeClassDeclaration = file._parserDiagnostics.length;
parseExpected(SyntaxKind.ClassKeyword);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
// TODO(jfreeman): Parse arbitrary sequence of heritage clauses and error for order and duplicates
node.baseType = parseOptional(SyntaxKind.ExtendsKeyword) ? parseTypeReference() : undefined;
var implementsKeywordStart = scanner.getTokenPos();
var implementsKeywordLength: number;
if (parseOptional(SyntaxKind.ImplementsKeyword)) {
implementsKeywordLength = scanner.getStartPos() - implementsKeywordStart;
node.implementedTypes = parseDelimitedList(ParsingContext.BaseTypeReferences, parseTypeReference);
}
var errorCountBeforeClassBody = file._parserDiagnostics.length;
@ -3332,31 +3306,20 @@ module ts {
else {
node.members = createMissingList<Declaration>();
}
if (node.implementedTypes && !node.implementedTypes.length && errorCountBeforeClassBody === errorCountBeforeClassDeclaration) {
grammarErrorAtPos(implementsKeywordStart, implementsKeywordLength, Diagnostics._0_list_cannot_be_empty, "implements");
}
return finishNode(node);
}
function parseInterfaceDeclaration(pos: number, flags: NodeFlags): InterfaceDeclaration {
var node = <InterfaceDeclaration>createNode(SyntaxKind.InterfaceDeclaration, pos);
node.flags = flags;
var errorCountBeforeInterfaceDeclaration = file._parserDiagnostics.length;
parseExpected(SyntaxKind.InterfaceKeyword);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
// TODO(jfreeman): Parse arbitrary sequence of heritage clauses and error for order and duplicates
var extendsKeywordStart = scanner.getTokenPos();
var extendsKeywordLength: number;
if (parseOptional(SyntaxKind.ExtendsKeyword)) {
extendsKeywordLength = scanner.getStartPos() - extendsKeywordStart;
node.baseTypes = parseDelimitedList(ParsingContext.BaseTypeReferences, parseTypeReference);
}
var errorCountBeforeInterfaceBody = file._parserDiagnostics.length;
node.members = parseTypeLiteral().members;
if (node.baseTypes && !node.baseTypes.length && errorCountBeforeInterfaceBody === errorCountBeforeInterfaceDeclaration) {
grammarErrorAtPos(extendsKeywordStart, extendsKeywordLength, Diagnostics._0_list_cannot_be_empty, "extends");
}
return finishNode(node);
}
@ -3589,20 +3552,9 @@ module ts {
}
function parseSourceElementOrModuleElement(modifierContext: ModifierContext): Statement {
if (isDeclarationStart()) {
return parseDeclaration(modifierContext);
}
var statementStart = scanner.getTokenPos();
var statementFirstTokenLength = scanner.getTextPos() - statementStart;
var errorCountBeforeStatement = file._parserDiagnostics.length;
var statement = parseStatement();
if (inAmbientContext && file._parserDiagnostics.length === errorCountBeforeStatement) {
grammarErrorAtPos(statementStart, statementFirstTokenLength, Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
}
return statement;
return isDeclarationStart()
? parseDeclaration(modifierContext)
: parseStatement();
}
function processReferenceComments(): ReferenceComments {
@ -3749,6 +3701,7 @@ module ts {
function checkGrammar(sourceText: string, languageVersion: ScriptTarget, file: SourceFileInternal) {
var syntacticDiagnostics = file._syntacticDiagnostics;
var scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceText);
// We're automatically in an ambient context if this is a .d.ts file.
var inAmbientContext = fileExtensionIs(file.filename, ".d.ts");
@ -3756,31 +3709,44 @@ module ts {
visitNode(file);
function visitNode(node: Node): void {
// Store and restore our recursive state here.
var savedParent = parent;
node.parent = parent;
parent = node;
// First recurse and perform all grammar checks on the children of this node.
var savedInAmbientContext = inAmbientContext
if (node.flags & NodeFlags.Ambient) {
inAmbientContext = true;
}
var diagnosticCount = syntacticDiagnostics.length;
forEachChild(node, visitNode);
// If any children had an grammar error, then skip reporting errors for this node or
// anything higher.
if (diagnosticCount === syntacticDiagnostics.length) {
checkNode(node);
}
checkNode(node);
inAmbientContext = savedInAmbientContext;
parent = savedParent;
}
function checkNode(node: Node) {
// No grammar errors on any of our children. Check this node for grammar errors.
// First, check if you have a statement in a place where it is not allowed. We want
// to do this before recursing, because we'd prefer to report these errors at the top
// level instead of at some nested level.
if (checkForStatementInAmbientContext(node)) {
return;
}
// Now recurse and perform all grammar checks on the children of this node.
var diagnosticCount = syntacticDiagnostics.length;
forEachChild(node, visitNode);
// if we got any errors, just stop performing any more checks on this node or higher.
if (diagnosticCount !== syntacticDiagnostics.length) {
return;
}
// Now do node specific checks.
dispatch(node);
}
function dispatch(node: Node) {
switch (node.kind) {
case SyntaxKind.ArrowFunction: return visitArrowFunction(<FunctionExpression>node);
case SyntaxKind.BinaryExpression: return visitBinaryExpression(<BinaryExpression>node);
@ -3811,14 +3777,25 @@ module ts {
case SyntaxKind.PostfixOperator: return visitPostfixOperator(<UnaryExpression>node);
case SyntaxKind.PrefixOperator: return visitPrefixOperator(<UnaryExpression>node);
case SyntaxKind.SetAccessor: return visitSetAccessor(<MethodDeclaration>node);
case SyntaxKind.SwitchStatement: return visitSwitchStatement(<SwitchStatement>node);
case SyntaxKind.TaggedTemplateExpression: return visitTaggedTemplateExpression(<TaggedTemplateExpression>node);
case SyntaxKind.TupleType: return visitTupleType(<TupleTypeNode>node);
case SyntaxKind.TypeReference: return visitTypeReference(<TypeReferenceNode>node);
case SyntaxKind.VariableDeclaration: return visitVariableDeclaration(<VariableDeclaration>node);
case SyntaxKind.VariableStatement: return visitVariableStatement(<VariableStatement>node);
case SyntaxKind.WithStatement: return visitWithStatement(<WithStatement>node);
}
}
function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
var start = skipTrivia(sourceText, node.pos);
scanner.setTextPos(start);
scanner.scan();
var end = scanner.getTextPos();
file._syntacticDiagnostics.push(createFileDiagnostic(file, start, end - start, message, arg0, arg1, arg2));
return true;
}
function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
var span = getErrorSpanForNode(node);
var start = span.end > span.pos ? skipTrivia(file.text, span.pos) : span.pos;
@ -3839,6 +3816,31 @@ module ts {
return grammarErrorOnNode(node, Diagnostics.Invalid_use_of_0_in_strict_mode, name);
}
function checkForStatementInAmbientContext(node: Node): boolean {
if (inAmbientContext) {
switch (node.kind) {
case SyntaxKind.Block:
case SyntaxKind.EmptyStatement:
case SyntaxKind.IfStatement:
case SyntaxKind.DoStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ContinueStatement:
case SyntaxKind.BreakStatement:
case SyntaxKind.ReturnStatement:
case SyntaxKind.WithStatement:
case SyntaxKind.SwitchStatement:
case SyntaxKind.ThrowStatement:
case SyntaxKind.TryStatement:
case SyntaxKind.DebuggerStatement:
case SyntaxKind.LabeledStatement:
case SyntaxKind.ExpressionStatement:
return grammarErrorOnFirstToken(node, Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
}
}
}
function visitArrowFunction(node: FunctionExpression) {
checkTypeParameterList(node.typeParameters) ||
checkParameterList(node.parameters);
@ -3955,7 +3957,7 @@ module ts {
function checkForAtLeastOneTypeArgument(typeArguments: NodeArray<TypeNode>) {
if (typeArguments && typeArguments.length === 0) {
var start = typeArguments.pos - "<".length;
var end = typeArguments.end + ">".length;
var end = skipTrivia(sourceText, typeArguments.end) + ">".length;
return grammarErrorAtPos(start, end - start, Diagnostics.Type_argument_list_cannot_be_empty);
}
}
@ -3986,14 +3988,22 @@ module ts {
}
function visitClassDeclaration(node: ClassDeclaration) {
checkForTrailingComma(node.implementedTypes);
checkForTrailingComma(node.implementedTypes) ||
checkForAtLeastOneHeritageClause(node.implementedTypes, "implements");
}
function checkForAtLeastOneHeritageClause(types: NodeArray<TypeNode>, listType: string): boolean {
if (types && types.length === 0) {
return grammarErrorAtPos(types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType)
}
}
function visitConstructor(node: ConstructorDeclaration) {
checkTypeParameterList(node.typeParameters) ||
checkParameterList(node.parameters) ||
checkConstructorTypeParameters(node) ||
checkConstructorTypeAnnotation(node);
checkConstructorTypeAnnotation(node) ||
checkForBodyInAmbientContext(node.body, /*isConstructor:*/ true);
}
function checkConstructorTypeParameters(node: ConstructorDeclaration) {
@ -4083,7 +4093,8 @@ module ts {
function visitFunctionDeclaration(node: FunctionLikeDeclaration) {
checkTypeParameterList(node.typeParameters) ||
checkParameterList(node.parameters) ||
checkFunctionName(node.name);
checkFunctionName(node.name) ||
checkForBodyInAmbientContext(node.body, /*isConstructor:*/ false);
}
function visitFunctionExpression(node: FunctionExpression) {
@ -4149,12 +4160,23 @@ module ts {
}
function visitInterfaceDeclaration(node: InterfaceDeclaration) {
checkForTrailingComma(node.baseTypes);
checkForTrailingComma(node.baseTypes) ||
checkForAtLeastOneHeritageClause(node.baseTypes, "extends");
}
function visitMethod(node: MethodDeclaration) {
checkTypeParameterList(node.typeParameters) ||
checkParameterList(node.parameters);
checkParameterList(node.parameters) ||
checkForBodyInAmbientContext(node.body, /*isConstructor:*/ false);
}
function checkForBodyInAmbientContext(body: Block | Expression, isConstructor: boolean): boolean {
if (inAmbientContext && body && body.kind === SyntaxKind.FunctionBlock) {
var diagnostic = isConstructor
? Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context
: Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context;
return grammarErrorOnFirstToken(body, diagnostic);
}
}
function visitModuleDeclaration(node: ModuleDeclaration): void {
@ -4264,7 +4286,7 @@ module ts {
if (typeParameters && typeParameters.length === 0) {
var start = typeParameters.pos - "<".length;
var end = typeParameters.end + ">".length;
var end = skipTrivia(sourceText, typeParameters.end) + ">".length;
return grammarErrorAtPos(start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty);
}
}
@ -4377,6 +4399,25 @@ module ts {
}
}
function visitSwitchStatement(node: SwitchStatement) {
var firstDefaultClause: CaseOrDefaultClause;
// Error on duplicate 'default' clauses.
for (var i = 0, n = node.clauses.length; i < n; i++) {
var clause = node.clauses[i];
if (clause.kind === SyntaxKind.DefaultClause) {
if (firstDefaultClause === undefined) {
firstDefaultClause = clause;
}
else {
var start = skipTrivia(file.text, clause.pos);
var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end;
grammarErrorAtPos(start, end - start, Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement);
}
}
}
}
function visitTaggedTemplateExpression(node: TaggedTemplateExpression) {
if (languageVersion < ScriptTarget.ES6) {
grammarErrorOnNode(node, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher);
@ -4444,8 +4485,8 @@ module ts {
}
}
function allowLetAndConstDeclarations(node: Node): boolean {
switch (node.kind) {
function allowLetAndConstDeclarations(parent: Node): boolean {
switch (parent.kind) {
case SyntaxKind.IfStatement:
case SyntaxKind.DoStatement:
case SyntaxKind.WhileStatement:
@ -4454,11 +4495,19 @@ module ts {
case SyntaxKind.ForInStatement:
return false;
case SyntaxKind.LabeledStatement:
return allowLetAndConstDeclarations(node.parent);
return allowLetAndConstDeclarations(parent.parent);
}
return true;
}
}
function visitWithStatement(node: WithStatement): void {
if (node.flags & NodeFlags.ParsedInStrictMode) {
// Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such
// a context is an
grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode);
}
}
}
export function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program {

View File

@ -1,10 +1,10 @@
tests/cases/compiler/accessorsInAmbientContext.ts(4,13): error TS1086: An accessor cannot be declared in an ambient context.
tests/cases/compiler/accessorsInAmbientContext.ts(4,19): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/accessorsInAmbientContext.ts(5,13): error TS1086: An accessor cannot be declared in an ambient context.
tests/cases/compiler/accessorsInAmbientContext.ts(7,20): error TS1086: An accessor cannot be declared in an ambient context.
tests/cases/compiler/accessorsInAmbientContext.ts(7,26): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/accessorsInAmbientContext.ts(8,20): error TS1086: An accessor cannot be declared in an ambient context.
tests/cases/compiler/accessorsInAmbientContext.ts(13,9): error TS1086: An accessor cannot be declared in an ambient context.
tests/cases/compiler/accessorsInAmbientContext.ts(13,15): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/accessorsInAmbientContext.ts(14,9): error TS1086: An accessor cannot be declared in an ambient context.
tests/cases/compiler/accessorsInAmbientContext.ts(16,16): error TS1086: An accessor cannot be declared in an ambient context.
tests/cases/compiler/accessorsInAmbientContext.ts(16,22): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/accessorsInAmbientContext.ts(17,16): error TS1086: An accessor cannot be declared in an ambient context.
@ -13,15 +13,15 @@ tests/cases/compiler/accessorsInAmbientContext.ts(17,16): error TS1086: An acces
declare module M {
class C {
get X() { return 1; }
~
!!! error TS1086: An accessor cannot be declared in an ambient context.
~~~~~~
!!! error TS1036: Statements are not allowed in ambient contexts.
set X(v) { }
~
!!! error TS1086: An accessor cannot be declared in an ambient context.
static get Y() { return 1; }
~
!!! error TS1086: An accessor cannot be declared in an ambient context.
~~~~~~
!!! error TS1036: Statements are not allowed in ambient contexts.
static set Y(v) { }
~
!!! error TS1086: An accessor cannot be declared in an ambient context.
@ -30,15 +30,15 @@ tests/cases/compiler/accessorsInAmbientContext.ts(17,16): error TS1086: An acces
declare class C {
get X() { return 1; }
~
!!! error TS1086: An accessor cannot be declared in an ambient context.
~~~~~~
!!! error TS1036: Statements are not allowed in ambient contexts.
set X(v) { }
~
!!! error TS1086: An accessor cannot be declared in an ambient context.
static get Y() { return 1; }
~
!!! error TS1086: An accessor cannot be declared in an ambient context.
~~~~~~
!!! error TS1036: Statements are not allowed in ambient contexts.
static set Y(v) { }
~
!!! error TS1086: An accessor cannot be declared in an ambient context.

View File

@ -1,10 +1,5 @@
tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/conformance/ambient/ambientErrors.ts(37,18): error TS1039: Initializers are not allowed in ambient contexts.
tests/cases/conformance/ambient/ambientErrors.ts(38,11): error TS1039: Initializers are not allowed in ambient contexts.
tests/cases/conformance/ambient/ambientErrors.ts(39,23): error TS1111: A constructor implementation cannot be declared in an ambient context.
tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/conformance/ambient/ambientErrors.ts(6,1): error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
tests/cases/conformance/ambient/ambientErrors.ts(17,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/ambient/ambientErrors.ts(47,20): error TS2435: Ambient external modules cannot be nested in other modules.
@ -12,7 +7,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(51,16): error TS2436: Ambient e
tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export assignment cannot be used in a module with other exported elements.
==== tests/cases/conformance/ambient/ambientErrors.ts (12 errors) ====
==== tests/cases/conformance/ambient/ambientErrors.ts (7 errors) ====
// Ambient variable with an initializer
declare var x = 4;
@ -37,8 +32,6 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export
// Ambient function with function body
declare function fn4() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
// Ambient enum with non - integer literal constant member
declare enum E1 {
@ -54,8 +47,6 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export
declare module M1 {
var x = 3;
function fn() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
class C {
static x = 3;
~
@ -64,14 +55,8 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export
~
!!! error TS1039: Initializers are not allowed in ambient contexts.
constructor() { }
~
!!! error TS1111: A constructor implementation cannot be declared in an ambient context.
fn() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
static sfn() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
}
}

View File

@ -1,5 +1,5 @@
tests/cases/compiler/ambientGetters.ts(3,9): error TS1086: An accessor cannot be declared in an ambient context.
tests/cases/compiler/ambientGetters.ts(7,9): error TS1086: An accessor cannot be declared in an ambient context.
tests/cases/compiler/ambientGetters.ts(7,20): error TS1036: Statements are not allowed in ambient contexts.
==== tests/cases/compiler/ambientGetters.ts (2 errors) ====
@ -12,6 +12,6 @@ tests/cases/compiler/ambientGetters.ts(7,9): error TS1086: An accessor cannot be
declare class B {
get length() { return 0; }
~~~~~~
!!! error TS1086: An accessor cannot be declared in an ambient context.
~~~~~~
!!! error TS1036: Statements are not allowed in ambient contexts.
}

View File

@ -0,0 +1,14 @@
tests/cases/compiler/ambientStatement1.ts(2,6): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/ambientStatement1.ts(4,20): error TS1039: Initializers are not allowed in ambient contexts.
==== tests/cases/compiler/ambientStatement1.ts (2 errors) ====
declare module M1 {
while(true);
~~~~~
!!! error TS1036: Statements are not allowed in ambient contexts.
export var v1 = () => false;
~
!!! error TS1039: Initializers are not allowed in ambient contexts.
}

View File

@ -1,19 +1,13 @@
tests/cases/compiler/exportDeclareClass1.ts(2,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/exportDeclareClass1.ts(2,24): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/exportDeclareClass1.ts(3,31): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/exportDeclareClass1.ts(3,34): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
==== tests/cases/compiler/exportDeclareClass1.ts (4 errors) ====
==== tests/cases/compiler/exportDeclareClass1.ts (2 errors) ====
export declare class eaC {
static tF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
static tsF(param:any) { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
};

View File

@ -10,29 +10,12 @@ tests/cases/compiler/giant.ts(93,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(95,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(99,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(101,5): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(154,39): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(168,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(170,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(172,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(174,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(178,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(180,5): error TS1005: '{' expected.
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.
tests/cases/compiler/giant.ts(243,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(244,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(245,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(247,31): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(249,23): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(251,32): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(254,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(255,31): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(257,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(262,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(262,25): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(267,30): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(267,33): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(283,5): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(285,5): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(287,5): error TS1005: '{' expected.
@ -45,64 +28,16 @@ tests/cases/compiler/giant.ts(351,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(353,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(357,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(359,5): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(412,39): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(426,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(428,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(430,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(432,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(436,9): error TS1005: '{' expected.
tests/cases/compiler/giant.ts(438,5): error TS1005: '{' expected.
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.
tests/cases/compiler/giant.ts(501,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(502,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(503,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(505,31): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(507,23): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(509,32): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(512,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(513,31): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(515,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(520,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(520,25): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(525,30): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(525,33): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(532,31): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(534,20): error TS1111: A constructor implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(537,17): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(538,18): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(539,18): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(541,27): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(543,19): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(545,28): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(548,17): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(549,27): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(551,18): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(556,18): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(556,21): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(558,24): error TS1111: A constructor implementation cannot be declared in an ambient context.
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(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.
tests/cases/compiler/giant.ts(611,33): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(615,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
tests/cases/compiler/giant.ts(616,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
tests/cases/compiler/giant.ts(616,39): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(616,42): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(617,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
tests/cases/compiler/giant.ts(618,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
tests/cases/compiler/giant.ts(621,26): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(621,29): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(623,24): error TS1111: A constructor implementation cannot be declared in an ambient context.
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(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.
tests/cases/compiler/giant.ts(676,33): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(23,12): error TS2300: Duplicate identifier 'pgF'.
tests/cases/compiler/giant.ts(24,16): error TS2300: Duplicate identifier 'pgF'.
tests/cases/compiler/giant.ts(24,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
@ -239,7 +174,7 @@ tests/cases/compiler/giant.ts(602,9): error TS2386: Overload signatures must all
tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all be optional or required.
==== tests/cases/compiler/giant.ts (239 errors) ====
==== tests/cases/compiler/giant.ts (174 errors) ====
/*
Prefixes
@ -482,8 +417,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
export module eM { };
export declare var eaV;
export declare function eaF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
export declare class eaC { };
export declare module eaM { };
}
@ -607,54 +540,36 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
export module eM { };
export declare var eaV;
export declare function eaF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
export declare class eaC { };
export declare module eaM { };
}
export declare var eaV;
export declare function eaF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
export declare class eaC {
constructor () { }
~
!!! error TS1111: A constructor implementation cannot be declared in an ambient context.
public pV;
private rV;
public pF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
private rF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
public pgF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'pgF'.
public get pgF()
~~~
!!! error TS2300: Duplicate identifier 'pgF'.
public psF(param:any) { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'psF'.
public set psF(param:any)
~~~
!!! error TS2300: Duplicate identifier 'psF'.
private rgF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'rgF'.
private get rgF()
~~~
!!! error TS2300: Duplicate identifier 'rgF'.
private rsF(param:any) { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'rsF'.
private set rsF(param:any)
@ -662,19 +577,13 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'rsF'.
static tV;
static tF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
static tsF(param:any) { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'tsF'.
static set tsF(param:any)
~~~
!!! error TS2300: Duplicate identifier 'tsF'.
static tgF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'tgF'.
static get tgF()
@ -684,19 +593,11 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
export declare module eaM {
var V;
function F() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
class C { }
interface I { }
module M { }
export var eV;
export function eF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
export class eC { }
export interface eI { }
export module eM { }
@ -930,8 +831,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
export module eM { };
export declare var eaV;
export declare function eaF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
export declare class eaC { };
export declare module eaM { };
}
@ -1055,54 +954,36 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
export module eM { };
export declare var eaV;
export declare function eaF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
export declare class eaC { };
export declare module eaM { };
}
export declare var eaV;
export declare function eaF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
export declare class eaC {
constructor () { }
~
!!! error TS1111: A constructor implementation cannot be declared in an ambient context.
public pV;
private rV;
public pF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
private rF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
public pgF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'pgF'.
public get pgF()
~~~
!!! error TS2300: Duplicate identifier 'pgF'.
public psF(param:any) { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'psF'.
public set psF(param:any)
~~~
!!! error TS2300: Duplicate identifier 'psF'.
private rgF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'rgF'.
private get rgF()
~~~
!!! error TS2300: Duplicate identifier 'rgF'.
private rsF(param:any) { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'rsF'.
private set rsF(param:any)
@ -1110,19 +991,13 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'rsF'.
static tV;
static tF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
static tsF(param:any) { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'tsF'.
static set tsF(param:any)
~~~
!!! error TS2300: Duplicate identifier 'tsF'.
static tgF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'tgF'.
static get tgF()
@ -1132,19 +1007,11 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
export declare module eaM {
var V;
function F() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
class C { }
interface I { }
module M { }
export var eV;
export function eF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
export class eC { }
export interface eI { }
export module eM { }
@ -1152,47 +1019,31 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
}
export declare var eaV;
export declare function eaF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
export declare class eaC {
constructor () { }
~
!!! error TS1111: A constructor implementation cannot be declared in an ambient context.
public pV;
private rV;
public pF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
private rF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
public pgF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'pgF'.
public get pgF()
~~~
!!! error TS2300: Duplicate identifier 'pgF'.
public psF(param:any) { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'psF'.
public set psF(param:any)
~~~
!!! error TS2300: Duplicate identifier 'psF'.
private rgF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'rgF'.
private get rgF()
~~~
!!! error TS2300: Duplicate identifier 'rgF'.
private rsF(param:any) { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'rsF'.
private set rsF(param:any)
@ -1200,19 +1051,13 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'rsF'.
static tV;
static tF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
static tsF(param:any) { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'tsF'.
static set tsF(param:any)
~~~
!!! error TS2300: Duplicate identifier 'tsF'.
static tgF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~
!!! error TS2300: Duplicate identifier 'tgF'.
static get tgF()
@ -1222,23 +1067,13 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
export declare module eaM {
var V;
function F() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
class C {
constructor () { }
~
!!! error TS1111: A constructor implementation cannot be declared in an ambient context.
public pV;
private rV;
public pF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
static tV;
static tF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
}
interface I {
//Call Signature
@ -1284,19 +1119,11 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
module M {
var V;
function F() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
class C { }
interface I { }
module M { }
export var eV;
export function eF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
export class eC { }
export interface eI { }
export module eM { }
@ -1306,10 +1133,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
export declare function eaF() { };
~~~~~~~
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
export declare class eaC { }
~~~~~~~
!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context.
@ -1319,23 +1142,13 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
}
export var eV;
export function eF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
export class eC {
constructor () { }
~
!!! error TS1111: A constructor implementation cannot be declared in an ambient context.
public pV;
private rV;
public pF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
static tV
static tF() { }
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
}
export interface eI {
//Call Signature
@ -1382,18 +1195,10 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
export module eM {
var V;
function F() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
class C { }
module M { }
export var eV;
export function eF() { };
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~
!!! error TS1036: Statements are not allowed in ambient contexts.
export class eC { }
export interface eI { }
export module eM { }

View File

@ -1,10 +1,8 @@
tests/cases/conformance/externalModules/initializersInDeclarations.ts(5,7): error TS1039: Initializers are not allowed in ambient contexts.
tests/cases/conformance/externalModules/initializersInDeclarations.ts(6,14): error TS1039: Initializers are not allowed in ambient contexts.
tests/cases/conformance/externalModules/initializersInDeclarations.ts(7,16): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/conformance/externalModules/initializersInDeclarations.ts(16,2): error TS1036: Statements are not allowed in ambient contexts.
==== tests/cases/conformance/externalModules/initializersInDeclarations.ts (4 errors) ====
==== tests/cases/conformance/externalModules/initializersInDeclarations.ts (2 errors) ====
// Errors: Initializers & statements in declaration file
@ -16,8 +14,6 @@ tests/cases/conformance/externalModules/initializersInDeclarations.ts(16,2): err
~
!!! error TS1039: Initializers are not allowed in ambient contexts.
fn(): boolean {
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
return false;
}
}
@ -27,8 +23,6 @@ tests/cases/conformance/externalModules/initializersInDeclarations.ts(16,2): err
declare module M1 {
while(true);
~~~~~
!!! error TS1036: Statements are not allowed in ambient contexts.
export var v1 = () => false;
}

View File

@ -0,0 +1,13 @@
tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/methodInAmbientClass1.ts(2,12): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
==== tests/cases/compiler/methodInAmbientClass1.ts (2 errors) ====
declare class Foo {
fn(): boolean {
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
~~~~~~~
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
}
}

View File

@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors5.ts(2,7): error TS1086: An accessor cannot be declared in an ambient context.
tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors5.ts(2,15): error TS1036: Statements are not allowed in ambient contexts.
==== tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors5.ts (1 errors) ====
declare class C {
get foo() { return 0; }
~~~
!!! error TS1086: An accessor cannot be declared in an ambient context.
~~~~~~
!!! error TS1036: Statements are not allowed in ambient contexts.
}

View File

@ -39,22 +39,22 @@ tests/cases/compiler/parserConstructorDeclaration12.ts(9,3): error TS2392: Multi
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2392: Multiple constructor implementations are not allowed.
constructor< >() { }
~~
~~~
!!! error TS1098: Type parameter list cannot be empty.
~~~~~~~~~~~~~~~~~~~~
!!! error TS2392: Multiple constructor implementations are not allowed.
constructor< > () { }
~~
~~~
!!! error TS1098: Type parameter list cannot be empty.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2392: Multiple constructor implementations are not allowed.
constructor < >() { }
~~
~~~
!!! error TS1098: Type parameter list cannot be empty.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2392: Multiple constructor implementations are not allowed.
constructor < > () { }
~~
~~~
!!! error TS1098: Type parameter list cannot be empty.
~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2392: Multiple constructor implementations are not allowed.

View File

@ -1,10 +1,10 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause4.ts(1,19): error TS1097: 'implements' list cannot be empty.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause4.ts(1,29): error TS1097: 'implements' list cannot be empty.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause4.ts(1,17): error TS2304: Cannot find name 'A'.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause4.ts (2 errors) ====
class C extends A implements {
~~~~~~~~~~
!!! error TS1097: 'implements' list cannot be empty.
~
!!! error TS2304: Cannot find name 'A'.

View File

@ -1,7 +1,7 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause6.ts(1,13): error TS1097: 'extends' list cannot be empty.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause6.ts(1,20): error TS1097: 'extends' list cannot be empty.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause6.ts (1 errors) ====
interface I extends { }
~~~~~~~
!!! error TS1097: 'extends' list cannot be empty.

View File

@ -1,11 +1,8 @@
tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file.
tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts(1,14): error TS1037: A function implementation cannot be declared in an ambient context.
==== tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts (1 errors) ====
function F() {
~~~~~~~~
!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file.
~
!!! error TS1037: A function implementation cannot be declared in an ambient context.
}

View File

@ -1,15 +1,7 @@
tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(9,5): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(10,5): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(21,13): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(25,13): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(26,13): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(28,13): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(28,22): error TS1108: A 'return' statement can only be used within a function body.
tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(29,13): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(29,22): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
==== tests/cases/compiler/switchStatementsWithMultipleDefaults.ts (9 errors) ====
==== tests/cases/compiler/switchStatementsWithMultipleDefaults.ts (1 errors) ====
var x = 10;
@ -19,11 +11,7 @@ tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(29,22): error TS111
default: // No issues.
break;
default: // Error; second 'default' clause.
~~~~~~~~
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
default: // Error; third 'default' clause.
~~~~~~~~
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
case 3:
x *= x;
}
@ -35,27 +23,15 @@ tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(29,22): error TS111
switch (x * x) {
default: // No issues.
default: // Error; second 'default' clause.
~~~~~~~~
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
break;
case 10000:
x /= x;
default: // Error, third 'default' clause
~~~~~~~~
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
def\u0061ult: // Error, fourth 'default' clause.
~~~~~~~~~~~~~
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
// Errors on fifth-seventh
default: return;
~~~~~~~~
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
~~~~~~
!!! error TS1108: A 'return' statement can only be used within a function body.
default: default:
~~~~~~~~
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
~~~~~~~~
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
}
}

View File

@ -0,0 +1,21 @@
tests/cases/compiler/switchStatementsWithMultipleDefaults1.ts(8,9): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
tests/cases/compiler/switchStatementsWithMultipleDefaults1.ts(9,9): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
==== tests/cases/compiler/switchStatementsWithMultipleDefaults1.ts (2 errors) ====
var x = 10;
switch (x) {
case 1:
case 2:
default: // No issues.
break;
default: // Error; second 'default' clause.
~~~~~~~~
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
default: // Error; third 'default' clause.
~~~~~~~~
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
case 3:
x *= x;
}

View File

@ -0,0 +1,5 @@
declare module M1 {
while(true);
export var v1 = () => false;
}

View File

@ -0,0 +1,4 @@
declare class Foo {
fn(): boolean {
}
}

View File

@ -0,0 +1,12 @@
var x = 10;
switch (x) {
case 1:
case 2:
default: // No issues.
break;
default: // Error; second 'default' clause.
default: // Error; third 'default' clause.
case 3:
x *= x;
}