fix(compiler): Report references to non-exported symbols.

Includes fixes to places now reported as errors.

Part of #8310
This commit is contained in:
Chuck Jazdzewski
2016-08-02 14:38:31 -07:00
parent 6195a45ae2
commit 9925aa89dc
6 changed files with 57 additions and 5 deletions

View File

@ -297,13 +297,19 @@ export class MetadataCollector {
} else {
varValue = errorSym('Variable not initialized', nameNode);
}
let exported = false;
if (variableStatement.flags & ts.NodeFlags.Export ||
variableDeclaration.flags & ts.NodeFlags.Export) {
if (!metadata) metadata = {};
metadata[nameNode.text] = varValue;
exported = true;
}
if (isPrimitive(varValue)) {
locals.define(nameNode.text, varValue);
} else if (!exported) {
locals.define(
nameNode.text,
errorSym('Reference to a local symbol', nameNode, {name: nameNode.text}));
}
} else {
// Destructuring (or binding) declarations are not supported,