location

tcmts.core.extract.location · #stxwjdfw · term · runs anywhere

import type { Node as ts_Node } from "typescript/ast";

export function location(node: ts_Node): string {
  const sf = node.getSourceFile();
  const { line, character } = sf.getLineAndCharacterOfPosition(node.getStart(sf));
  return `${sf.fileName}:${line + 1}:${character + 1}`;
}

used by