Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint

This commit is contained in:
Alexander T
2019-08-16 12:13:57 +03:00
44 changed files with 1193 additions and 113 deletions

View File

@@ -5490,10 +5490,22 @@ namespace ts {
}
function parseDeclaration(): Statement {
const modifiers = lookAhead(() => (parseDecorators(), parseModifiers()));
// `parseListElement` attempted to get the reused node at this position,
// but the ambient context flag was not yet set, so the node appeared
// not reusable in that context.
const isAmbient = some(modifiers, isDeclareModifier);
if (isAmbient) {
const node = tryReuseAmbientDeclaration();
if (node) {
return node;
}
}
const node = <Statement>createNodeWithJSDoc(SyntaxKind.Unknown);
node.decorators = parseDecorators();
node.modifiers = parseModifiers();
if (some(node.modifiers, isDeclareModifier)) {
if (isAmbient) {
for (const m of node.modifiers!) {
m.flags |= NodeFlags.Ambient;
}
@@ -5504,6 +5516,15 @@ namespace ts {
}
}
function tryReuseAmbientDeclaration(): Statement | undefined {
return doInsideOfContext(NodeFlags.Ambient, () => {
const node = currentNode(parsingContext);
if (node) {
return consumeNode(node) as Statement;
}
});
}
function parseDeclarationWorker(node: Statement): Statement {
switch (token()) {
case SyntaxKind.VarKeyword: