mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Keep Disallowing return in ambient locations
This commit is contained in:
@@ -38913,7 +38913,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (!container) {
|
||||
if (!!getSourceFileOfNode(node).externalModuleIndicator) {
|
||||
if (!!getSourceFileOfNode(node).externalModuleIndicator || node.flags & NodeFlags.Ambient) {
|
||||
grammarErrorOnFirstToken(node, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
tests/cases/compiler/ambientWithStatements.ts(2,5): error TS1036: Statements are not allowed in ambient contexts.
|
||||
tests/cases/compiler/ambientWithStatements.ts(3,5): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement.
|
||||
tests/cases/compiler/ambientWithStatements.ts(11,5): error TS1108: A 'return' statement can only be used within a function body.
|
||||
tests/cases/compiler/ambientWithStatements.ts(25,5): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/ambientWithStatements.ts (3 errors) ====
|
||||
==== tests/cases/compiler/ambientWithStatements.ts (4 errors) ====
|
||||
declare module M {
|
||||
break;
|
||||
~~~~~
|
||||
@@ -19,6 +20,8 @@ tests/cases/compiler/ambientWithStatements.ts(25,5): error TS2410: The 'with' st
|
||||
1;
|
||||
L: var y;
|
||||
return;
|
||||
~~~~~~
|
||||
!!! error TS1108: A 'return' statement can only be used within a function body.
|
||||
switch (x) {
|
||||
case 1:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user