Type check the expression of the 'with' statement
This commit is contained in:
parent
8cbe88b501
commit
f79cba2225
|
@ -5195,6 +5195,7 @@ module ts {
|
|||
}
|
||||
|
||||
function checkWithStatement(node: WithStatement) {
|
||||
checkExpression(node.expression);
|
||||
error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (8 errors) ====
|
||||
==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (10 errors) ====
|
||||
|
||||
// Arrow function used in with statement
|
||||
with (window) {
|
||||
~~~~~~
|
||||
!!! All symbols within a 'with' block will be resolved to 'any'.
|
||||
~~~~~~
|
||||
!!! Cannot find name 'window'.
|
||||
var p = () => this;
|
||||
}
|
||||
|
||||
|
@ -53,6 +55,8 @@
|
|||
with (window) {
|
||||
~~~~~~
|
||||
!!! All symbols within a 'with' block will be resolved to 'any'.
|
||||
~~~~~~
|
||||
!!! Cannot find name 'window'.
|
||||
var p = () => this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode14.ts (1 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode14.ts (2 errors) ====
|
||||
"use strict";
|
||||
with (a) {
|
||||
~
|
||||
!!! All symbols within a 'with' block will be resolved to 'any'.
|
||||
~
|
||||
!!! Cannot find name 'a'.
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement1.d.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement1.d.ts (3 errors) ====
|
||||
with (foo) {
|
||||
~~~~
|
||||
!!! Statements are not allowed in ambient contexts.
|
||||
~~~
|
||||
!!! All symbols within a 'with' block will be resolved to 'any'.
|
||||
~~~
|
||||
!!! Cannot find name 'foo'.
|
||||
}
|
Loading…
Reference in a new issue