mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
24 lines
632 B
JavaScript
24 lines
632 B
JavaScript
import * as ts from "./built/local/typescript.js";
|
|
|
|
const sourceFile = ts.createSourceFile(
|
|
"test.ts",
|
|
`const { c, f }: keyof = { c: 0, f };`,
|
|
ts.ScriptTarget.Latest,
|
|
true
|
|
);
|
|
|
|
function printNode(node, indent = 0) {
|
|
const prefix = " ".repeat(indent);
|
|
let info = `${prefix}${ts.SyntaxKind[node.kind]}`;
|
|
if (ts.isTypeOperatorNode(node)) {
|
|
info += ` (operator: ${ts.SyntaxKind[node.operator]})`;
|
|
}
|
|
if (ts.isIdentifier(node)) {
|
|
info += ` (text: "${node.text}")`;
|
|
}
|
|
console.log(info);
|
|
ts.forEachChild(node, child => printNode(child, indent + 1));
|
|
}
|
|
|
|
printNode(sourceFile);
|