Merge pull request #30849 from cameron-martin/scope-push-options

[@babel/traverse]: Added types to argument of Scope#push.
This commit is contained in:
Mine Starks
2018-11-28 07:49:40 -08:00
committed by GitHub
2 changed files with 10 additions and 4 deletions
@@ -89,7 +89,8 @@ const v1: Visitor = {
const id = path.scope.generateUidIdentifierBasedOnNode(path.node.id!);
path.remove();
path.scope.parent.push({ id, init: path.node });
path.scope.parent.push({ id });
path.scope.parent.push({ id, init: t.stringLiteral('foo'), kind: "const" });
path.scope.rename("n", "x");
path.scope.rename("n");
@@ -104,7 +105,7 @@ const BindingKindTest: Visitor = {
kind === 'const';
kind === 'let';
kind === 'var';
// The following should fail when uncommented
// kind === 'anythingElse';
// $ExpectError
kind === 'anythingElse';
},
};
+6 -1
View File
@@ -90,7 +90,12 @@ export class Scope {
removeData(key: string): void;
push(opts: any): void;
push(opts: {
id: t.LVal,
init?: t.Expression,
unique?: boolean,
kind?: "var" | "let" | "const",
}): void;
getProgramParent(): Scope;