message: Pass typeChecker instance to createVisitor()
diff: @@ -18,19 +18,11 @@ async function destructureObject(editor: Editor) {
  }
  function updateCode(code: Code, selection: Selection): t.Transformed {
  - const typeChecker = new TypeChecker(code, new ConsoleLogger());
  - const keys = typeChecker.getKeys(selection.start);
  -
  - if (keys.length === 0) {
  - return {
  - code,
  - hasCodeChanged: false
  - };
  - }
  -
  return t.transformAST(
  t.parse(code),
  - createVisitor(selection, (path) => {
  + createVisitor(
  + selection,
  + (path, keys) => {
  // Replace references of the Identifier
  const referencePaths =
  path.scope.getBinding(path.node.name)?.referencePaths ?? [];
  @@ -51,19 +43,25 @@ function updateCode(code: Code, selection: Selection): t.Transformed {
  path.replaceWith(node);
  path.stop();
  - })
  + },
  + new TypeChecker(code, new ConsoleLogger())
  + )
  );
  }
  function createVisitor(
  selection: Selection,
  - onMatch: (path: t.NodePath<t.Identifier>) => void
  + onMatch: (path: t.NodePath<t.Identifier>, keys: string[]) => void,
  + typeChecker: TypeChecker
  ): t.Visitor {
  + const keys = typeChecker.getKeys(selection.start);
  +
  return {
  Identifier(path) {
  if (!selection.isInsidePath(path)) return;
  + if (keys.length === 0) return;
  - onMatch(path);
  + onMatch(path, keys);
  }
  };
  }
  