mirror of
https://github.com/bendtherules/ts-transformer-visualizer.git
synced 2026-08-18 13:51:48 +00:00
lib - Add node highlighting and consume in log-identifier
This commit is contained in:
+4
-2
@@ -4,7 +4,8 @@ import {
|
||||
ASTVisualizer,
|
||||
initSourceFile,
|
||||
updateSourceFile,
|
||||
clearSourceFile
|
||||
clearSourceFile,
|
||||
clearHighlightedNodes
|
||||
} from "ts-transformer-visualizer";
|
||||
import * as ts from "typescript";
|
||||
|
||||
@@ -14,7 +15,7 @@ import { moduleMap, ModuleNames } from "./transforms";
|
||||
|
||||
export default function App({
|
||||
moduleName,
|
||||
timeDelayMs = 3000
|
||||
timeDelayMs = 1000
|
||||
}: {
|
||||
moduleName: ModuleNames;
|
||||
timeDelayMs?: number;
|
||||
@@ -41,6 +42,7 @@ export default function App({
|
||||
// 3. Clean timeout and reset visualizer
|
||||
clearTimeout(timeoutID);
|
||||
clearSourceFile();
|
||||
clearHighlightedNodes();
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import * as ts from "typescript";
|
||||
import { highlightNode } from "ts-transformer-visualizer";
|
||||
|
||||
import { TransformModuleExport } from "../types";
|
||||
|
||||
const sourceCodeString = `\
|
||||
@@ -15,6 +17,7 @@ const transformer: ts.TransformerFactory<ts.SourceFile> = context => {
|
||||
return sourceFile => {
|
||||
const visitor = (node: ts.Node): ts.Node => {
|
||||
if (ts.isIdentifier(node)) {
|
||||
highlightNode(node);
|
||||
console.log(node.text);
|
||||
}
|
||||
return ts.visitEachChild(node, visitor, context);
|
||||
|
||||
Reference in New Issue
Block a user