mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user