Merge pull request #2569 from Microsoft/revertModuleImportFix
revert fix for #2456 'Import namespace exports should be immutable'
This commit is contained in:
commit
adad7c18d5
4 changed files with 16 additions and 114 deletions
|
@ -7387,23 +7387,6 @@ module ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isImportedNameFromExternalModule(n: Node): boolean {
|
|
||||||
switch (n.kind) {
|
|
||||||
case SyntaxKind.ElementAccessExpression:
|
|
||||||
case SyntaxKind.PropertyAccessExpression: {
|
|
||||||
// all bindings for external module should be immutable
|
|
||||||
// so attempt to use a.b or a[b] as lhs will always fail
|
|
||||||
// no matter what b is
|
|
||||||
let symbol = findSymbol((<PropertyAccessExpression | ElementAccessExpression>n).expression);
|
|
||||||
return symbol && symbol.flags & SymbolFlags.Alias && isExternalModuleSymbol(resolveAlias(symbol));
|
|
||||||
}
|
|
||||||
case SyntaxKind.ParenthesizedExpression:
|
|
||||||
return isImportedNameFromExternalModule((<ParenthesizedExpression>n).expression);
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isReferenceOrErrorExpression(n)) {
|
if (!isReferenceOrErrorExpression(n)) {
|
||||||
error(n, invalidReferenceMessage);
|
error(n, invalidReferenceMessage);
|
||||||
return false;
|
return false;
|
||||||
|
@ -7414,10 +7397,6 @@ module ts {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isImportedNameFromExternalModule(n)) {
|
|
||||||
error(n, invalidReferenceMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,164 +1,82 @@
|
||||||
tests/cases/compiler/f2.ts(5,1): error TS2364: Invalid left-hand side of assignment expression.
|
tests/cases/compiler/f2.ts(9,7): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
tests/cases/compiler/f2.ts(6,1): error TS2364: Invalid left-hand side of assignment expression.
|
tests/cases/compiler/f2.ts(19,8): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
tests/cases/compiler/f2.ts(7,1): error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
tests/cases/compiler/f2.ts(7,7): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
|
||||||
tests/cases/compiler/f2.ts(8,1): error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
tests/cases/compiler/f2.ts(10,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
tests/cases/compiler/f2.ts(11,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
tests/cases/compiler/f2.ts(12,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
tests/cases/compiler/f2.ts(13,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
tests/cases/compiler/f2.ts(15,1): error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
tests/cases/compiler/f2.ts(16,1): error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
tests/cases/compiler/f2.ts(17,1): error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
tests/cases/compiler/f2.ts(17,8): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
|
||||||
tests/cases/compiler/f2.ts(18,1): error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
tests/cases/compiler/f2.ts(20,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
tests/cases/compiler/f2.ts(21,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
tests/cases/compiler/f2.ts(22,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
tests/cases/compiler/f2.ts(23,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
tests/cases/compiler/f2.ts(25,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
|
||||||
tests/cases/compiler/f2.ts(26,6): error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
tests/cases/compiler/f2.ts(27,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
tests/cases/compiler/f2.ts(27,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||||
tests/cases/compiler/f2.ts(28,6): error TS2487: Invalid left-hand side in 'for...of' statement.
|
tests/cases/compiler/f2.ts(29,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||||
tests/cases/compiler/f2.ts(29,6): error TS2406: Invalid left-hand side in 'for...in' statement.
|
tests/cases/compiler/f2.ts(31,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
tests/cases/compiler/f2.ts(29,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
tests/cases/compiler/f2.ts(32,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
tests/cases/compiler/f2.ts(30,6): error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
tests/cases/compiler/f2.ts(30,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
|
||||||
tests/cases/compiler/f2.ts(31,6): error TS2406: Invalid left-hand side in 'for...in' statement.
|
|
||||||
tests/cases/compiler/f2.ts(32,6): error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
tests/cases/compiler/f2.ts(34,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
|
||||||
tests/cases/compiler/f2.ts(35,6): error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
tests/cases/compiler/f2.ts(36,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
tests/cases/compiler/f2.ts(36,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||||
tests/cases/compiler/f2.ts(37,6): error TS2487: Invalid left-hand side in 'for...of' statement.
|
tests/cases/compiler/f2.ts(38,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||||
tests/cases/compiler/f2.ts(38,6): error TS2406: Invalid left-hand side in 'for...in' statement.
|
tests/cases/compiler/f2.ts(40,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
tests/cases/compiler/f2.ts(38,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
tests/cases/compiler/f2.ts(39,6): error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
tests/cases/compiler/f2.ts(39,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
|
||||||
tests/cases/compiler/f2.ts(40,6): error TS2406: Invalid left-hand side in 'for...in' statement.
|
|
||||||
tests/cases/compiler/f2.ts(41,6): error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/f1.ts (0 errors) ====
|
==== tests/cases/compiler/f1.ts (0 errors) ====
|
||||||
export var x = 1;
|
export var x = 1;
|
||||||
|
|
||||||
==== tests/cases/compiler/f2.ts (38 errors) ====
|
==== tests/cases/compiler/f2.ts (10 errors) ====
|
||||||
|
|
||||||
|
// all mutations below are illegal and should be fixed
|
||||||
import * as stuff from 'f1';
|
import * as stuff from 'f1';
|
||||||
|
|
||||||
var n = 'baz';
|
var n = 'baz';
|
||||||
|
|
||||||
stuff.x = 0;
|
stuff.x = 0;
|
||||||
~~~~~~~
|
|
||||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
stuff['x'] = 1;
|
stuff['x'] = 1;
|
||||||
~~~~~~~~~~
|
|
||||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
stuff.blah = 2;
|
stuff.blah = 2;
|
||||||
~~~~~~~~~~
|
|
||||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
~~~~
|
~~~~
|
||||||
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
stuff[n] = 3;
|
stuff[n] = 3;
|
||||||
~~~~~~~~
|
|
||||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
|
|
||||||
stuff.x++;
|
stuff.x++;
|
||||||
~~~~~~~
|
|
||||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
stuff['x']++;
|
stuff['x']++;
|
||||||
~~~~~~~~~~
|
|
||||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
stuff['blah']++;
|
stuff['blah']++;
|
||||||
~~~~~~~~~~~~~
|
|
||||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
stuff[n]++;
|
stuff[n]++;
|
||||||
~~~~~~~~
|
|
||||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
|
|
||||||
(stuff.x) = 0;
|
(stuff.x) = 0;
|
||||||
~~~~~~~~~
|
|
||||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
(stuff['x']) = 1;
|
(stuff['x']) = 1;
|
||||||
~~~~~~~~~~~~
|
|
||||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
(stuff.blah) = 2;
|
(stuff.blah) = 2;
|
||||||
~~~~~~~~~~~~
|
|
||||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
~~~~
|
~~~~
|
||||||
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
(stuff[n]) = 3;
|
(stuff[n]) = 3;
|
||||||
~~~~~~~~~~
|
|
||||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
|
||||||
|
|
||||||
(stuff.x)++;
|
(stuff.x)++;
|
||||||
~~~~~~~~~
|
|
||||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
(stuff['x'])++;
|
(stuff['x'])++;
|
||||||
~~~~~~~~~~~~
|
|
||||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
(stuff['blah'])++;
|
(stuff['blah'])++;
|
||||||
~~~~~~~~~~~~~~~
|
|
||||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
(stuff[n])++;
|
(stuff[n])++;
|
||||||
~~~~~~~~~~
|
|
||||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
|
||||||
|
|
||||||
for (stuff.x in []) {}
|
for (stuff.x in []) {}
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||||
for (stuff.x of []) {}
|
for (stuff.x of []) {}
|
||||||
~~~~~~~
|
|
||||||
!!! error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
for (stuff['x'] in []) {}
|
for (stuff['x'] in []) {}
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||||
for (stuff['x'] of []) {}
|
for (stuff['x'] of []) {}
|
||||||
~~~~~~~~~~
|
|
||||||
!!! error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
for (stuff.blah in []) {}
|
for (stuff.blah in []) {}
|
||||||
~~~~~~~~~~
|
|
||||||
!!! error TS2406: Invalid left-hand side in 'for...in' statement.
|
|
||||||
~~~~
|
~~~~
|
||||||
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
for (stuff.blah of []) {}
|
for (stuff.blah of []) {}
|
||||||
~~~~~~~~~~
|
|
||||||
!!! error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
~~~~
|
~~~~
|
||||||
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
for (stuff[n] in []) {}
|
for (stuff[n] in []) {}
|
||||||
~~~~~~~~
|
|
||||||
!!! error TS2406: Invalid left-hand side in 'for...in' statement.
|
|
||||||
for (stuff[n] of []) {}
|
for (stuff[n] of []) {}
|
||||||
~~~~~~~~
|
|
||||||
!!! error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
|
|
||||||
for ((stuff.x) in []) {}
|
for ((stuff.x) in []) {}
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||||
for ((stuff.x) of []) {}
|
for ((stuff.x) of []) {}
|
||||||
~~~~~~~~~
|
|
||||||
!!! error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
for ((stuff['x']) in []) {}
|
for ((stuff['x']) in []) {}
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||||
for ((stuff['x']) of []) {}
|
for ((stuff['x']) of []) {}
|
||||||
~~~~~~~~~~~~
|
|
||||||
!!! error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
for ((stuff.blah) in []) {}
|
for ((stuff.blah) in []) {}
|
||||||
~~~~~~~~~~~~
|
|
||||||
!!! error TS2406: Invalid left-hand side in 'for...in' statement.
|
|
||||||
~~~~
|
~~~~
|
||||||
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
for ((stuff.blah) of []) {}
|
for ((stuff.blah) of []) {}
|
||||||
~~~~~~~~~~~~
|
|
||||||
!!! error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
~~~~
|
~~~~
|
||||||
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||||
for ((stuff[n]) in []) {}
|
for ((stuff[n]) in []) {}
|
||||||
~~~~~~~~~~
|
|
||||||
!!! error TS2406: Invalid left-hand side in 'for...in' statement.
|
|
||||||
for ((stuff[n]) of []) {}
|
for ((stuff[n]) of []) {}
|
||||||
~~~~~~~~~~
|
|
||||||
!!! error TS2487: Invalid left-hand side in 'for...of' statement.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
export var x = 1;
|
export var x = 1;
|
||||||
|
|
||||||
//// [f2.ts]
|
//// [f2.ts]
|
||||||
|
|
||||||
|
// all mutations below are illegal and should be fixed
|
||||||
import * as stuff from 'f1';
|
import * as stuff from 'f1';
|
||||||
|
|
||||||
var n = 'baz';
|
var n = 'baz';
|
||||||
|
@ -52,6 +54,7 @@ for ((stuff[n]) of []) {}
|
||||||
//// [f1.js]
|
//// [f1.js]
|
||||||
exports.x = 1;
|
exports.x = 1;
|
||||||
//// [f2.js]
|
//// [f2.js]
|
||||||
|
// all mutations below are illegal and should be fixed
|
||||||
var stuff = require('f1');
|
var stuff = require('f1');
|
||||||
var n = 'baz';
|
var n = 'baz';
|
||||||
stuff.x = 0;
|
stuff.x = 0;
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
export var x = 1;
|
export var x = 1;
|
||||||
|
|
||||||
// @Filename: f2.ts
|
// @Filename: f2.ts
|
||||||
|
|
||||||
|
// all mutations below are illegal and should be fixed
|
||||||
import * as stuff from 'f1';
|
import * as stuff from 'f1';
|
||||||
|
|
||||||
var n = 'baz';
|
var n = 'baz';
|
||||||
|
|
Loading…
Reference in a new issue