Skip to content

Instantly share code, notes, and snippets.

@jcmoore
Last active September 11, 2017 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcmoore/eec296d43c32a9435c512a97b36f124c to your computer and use it in GitHub Desktop.
Save jcmoore/eec296d43c32a9435c512a97b36f124c to your computer and use it in GitHub Desktop.
travasti -- AST traversal
// https://raw.githubusercontent.com/mozilla/source-map/182f4459415de309667845af2b05716fcf9c59ad/dist/source-map.js
var sourceMap;
// https://raw.githubusercontent.com/Microsoft/TypeScript/1a579d929f1d0ee4d45de7cee505970a24a40cc7/lib/typescript.js
var ts;
var tv = {
$: {
handle: Symbol("tv.$.handle"),
},
vehicle: function ({
handle = function (node) {
return node ? tv.visit(this, node) : node;
},
} = {}, outfit = {}) {
if (outfit[tv.$.handle] !== void 0) throw new Error("travasti vehicle handle field collision");
outfit[tv.$.handle] = typeof handle === "function" ? handle : void 0;
return outfit;
},
writer: function (options, handlers, lib = ts) {
return lib.createPrinter(options, handlers);
},
emit: function (node = tv.parse(), writer = null, lib = ts) {
var sourceFile = tv.parse("", "", null, lib);
if (Array.isArray(node)) sourceFile.statements.push.apply(sourceFile.statements, node);
else if (sourceFile.kind !== node.kind) sourceFile.statements.push(node);
else sourceFile.statements.push.apply(sourceFile.statements, node.statements);
return (writer || tv.writer(void 0, void 0, lib)).printFile(sourceFile);
},
nav: function (raw = tv.compile([tv.parse("let x : number = 1", "_.ts")]).files["_.map.js"], util = sourceMap) {
return new util.SourceMapConsumer(raw);
},
mapper: function () {
},
builtins: function (path = "", target = null, lib = ts) {
return tv.parse([
"",
"interface IArguments {}",
"interface Object {}",
"interface Function {}",
"interface String {}",
"interface Boolean {}",
"interface Number {}",
"interface RegExp {}",
"interface Array<T> {}",
"",
].join("\n"), path, target, lib);
},
compile: function (files = [
tv.parse("let $ : number = 0", "./a.ts"),
tv.parse("/** @type {number} */\nvar _ = 0;", "./z.js"),
], options = {}, builtins = tv.builtins(), util = sourceMap, lib = ts) {
var prefix = "";
var stdlib = prefix+".ts";
var names = (files.map(function (node) {
return prefix + node.fileName;
}));
var settings = Object.assign({
module: lib.ModuleKind.ES2015,
outDir: "/",
allowJs: true,
checkJs: true,
sourceMap: true,
jsx: "preserve",
}, options || {});
var dir = settings.outDir || "";
var maps = !settings.sourceMap ? [] : files.map(function (node) {
return node.fileName.replace(/\.[jt]sx?$/i, ".js.map");
});
var emissions = {};
var host = {
fileExists: function (path) {
return -1 < names.indexOf(path) || path === stdlib;
},
//readFile: function (path) {
//},
getSourceFile: function (path, target, report) {
var index = names.indexOf(path);
if (index > -1) return files[index];
else if (path === stdlib) return builtins;
else return tv.parse(report("Failed to resolve path: "+path) ? "" : "");
},
getDefaultLibFileName: function () {
return prefix;
},
getCurrentDirectory: function () {
return "";
},
getDirectories: function (path) {
return []; // [""]
},
getCanonicalFileName: function (path) {
return path;
},
useCaseSensitiveFileNames: function () {
return false;
},
getNewLine: function () {
return "\n";
},
writeFile: function (path, code, writeByteOrderMark, report, nodes) {
emissions[path.slice(dir.length)] = code;
},
};
var program = lib.createProgram(names, settings, host);
var result = program.emit();
return {
notes: lib.getPreEmitDiagnostics(program).concat(result.diagnostics),
files: emissions,
maps: maps.reduce(function (value, path) {
value[path] = tv.nav(JSON.parse(emissions[path]), util);
return value;
}, {}),
};
},
parse: function (code = "let a : number = 0", path = "_.ts", target = null, lib = ts) {
var index = path.lastIndexOf(".");
var extension = index < 0 ? "" : path.slice(index);
var kind = ".ts" === extension ?
lib.ScriptKind.TS : ".js" === extension ?
lib.ScriptKind.JS : ".jsx" === extension ?
lib.ScriptKind.JSX : ".tsx" === extension ?
lib.ScriptKind.TSX : lib.ScriptKind.External;
var output = target === null ?
lib.ScriptTarget.ES2017 : "string" === typeof target ?
lib.ScriptTarget[target] : 0|target;
return lib.createSourceFile(path, code, output, false, kind);
},
visit: function (vehicle, node = tv.parse(), lib = ts) {
var kind = node.kind === (0|node.kind) ? lib.SyntaxKind[node.kind] : node.kind;
if (kind in tv.ast) return tv.ast[kind].visit(vehicle, node, lib);
else return node;
},
stay: function (vehicle, node, parent, key, lib = ts) {
var result = vehicle[tv.$.handle](node, lib, parent, key, -1, void 0, tv) || void 0;
return !Array.isArray(result) ?
result : result.length ?
result[0] : void 0;
},
tour: function (vehicle, nodes, parent, key, lib = ts) {
var result = vehicle[tv.$.handle](void 0, lib, parent, key, -2, nodes, tv) || void 0;
var count = nodes ? nodes.length : 0;
var index = 0;
var swap = parent || void 0;
if (!Array.isArray(result)) {
result = void 0;
for (index; index < count; index++) {
swap = vehicle[tv.$.handle](nodes[index], lib, parent, key, index, nodes, tv) || void 0;
if (result === void 0 && swap !== nodes[index]) {
result = lib.createNodeArray(nodes.slice(0, index));
}
if (result === void 0) continue;
else if (Array.isArray(swap)) result.push.apply(result, swap);
else if (swap === parent) break;
else if (swap) result.push(swap);
}
result = result ?
result : index < count ?
lib.createNodeArray(nodes.slice(0, index)) : nodes;
}
return result || nodes;
},
factory: function (cache = new WeakMap()) {
return function (texts) {
var labels = Array.call.apply(Array, arguments);
var data = cache.get(texts) || {
code: texts.join(""),
offsets: labels.map(function (skip, index) {
return this[index].length;
}, texts).reduce(function (offsets, size, index) {
offsets.push(index ? offsets[index - 1] + size : size);
return offsets;
}, []),
json: "",
resolvers: new Map(),
};
if (!data.json) {
data.json = JSON.stringify(tv.parse(data.code));
cache.set(texts, data);
}
return build(data, labels);
};
function build (data, labels) {
return function (srcback, querymods) {
var root = JSON.parse(data.json);
var keys = querymods ? Object.keys(querymods) : [];
var count = keys.length;
var index = 0;
var getters = [];
var tuple = {};
var field = "";
var start = -1;
var end = -1;
for (index = 0; index < count; index++) {
if (field = keys[index] || "") {
if (querymods[field] && "object" === typeof querymods[field]) {
start = labels.indexOf(querymods[field].start, 0);
end = labels.indexOf(querymods[field].end, start + 1);
} else {
start = labels.indexOf(field, 0);
end = labels.indexOf(field, start + 1);
}
if (start > -1 && end > -1) {
getters.push({
field: field,
start: start,
end: end,
resolver: resolver(root, start, end, data),
});
}
}
}
getters = getters.sort(comparator);
count = getters.length;
for (index = 0; index < count; index++) {
field = getters[index].field;
if (!querymods[field]) {
tuple[field] = getters[index].resolver.call(this, root, identity);
} else if ("function" === typeof querymods[field]) {
tuple[field] = getters[index].resolver.call(this, root, querymods[field]);
} else {
tuple[field] = getters[index].resolver.call(this, root, querymods[field].mod || null);
}
}
return srcback.call(this, root, tuple);
};
}
function comparator (a, b) {
if (b.start === a.start) return b.end - a.end;
else b.start - a.start;
}
function identity (node) {
return node;
}
function resolver (root, begin, finish, data) {
var start = data.offsets[begin];
var end = data.offsets[finish];
var values = data.resolvers.get(begin) || data.resolvers;
if (values === data.resolvers) data.resolvers.set(begin, value = new Map());
if (!values.has(finish)) values.set(finish, analyze(root, start, end));
return values.get(finish);
}
function analyze (root, start, end) {
var vehicle = tv.vehicle({
handle: handle,
}, {
start: start,
end: end,
path: [],
key: "",
index: -2,
lib: null,
utils: null,
});
tv.visit(vehicle, root);
return extractor(vehicle.path, vehicle.key, vehicle.index, vehicle.lib, vehicle.utils);
}
function handle (one, lib, parent, key, index, many, utils) {
var found = false;
if (one) {
if (one.pos > this.start) found = one.end <= this.end ? true : false;
else if (one.end < this.end) found = one.pos >= this.start ? true : false;
else if (one.pos >= this.start && one.end <= this.end) found = true;
else {
this.path.push(key, index);
utils.visit(this, one);
}
}
if (found) {
this.key = key;
this.index = index;
this.lib = lib;
this.utils = utils;
}
return one;
}
function extractor (steps, key, at, lib, utils) {
return at < -1 ? function () {
return null;
} : function (root, mod) {
var distance = steps ? steps.length : 0;
var index = 0;
var child = root;
var parent = root;
var node;
for (index; index < distance; index+= 2) {
if (0 > steps[index + 1]) parent = parent[steps[index]];
else parent = parent[steps[index]][steps[index + 1]];
}
if (0 > at) child = parent[key];
else child = parent[key][at];
if ("function" !== typeof mod) node = child;
else {
node = mod.call(this, child, lib, parent, key, at, 0 > at ? null : parent[key], utils);
node = node === void 0 ? child : node;
}
if (node === child) child = node;
else if (0 > at) parent[key] = node;
else if (!Array.isArray(node)) parent[key][at] = node;
else parent[key].splice.apply(parent[key], [at, 1].concat(node));
return node;
};
}
},
};
Object.assign(tv, {
index: (function iife () {
function Record (db, parent, node, key, index, lib) {
this.depth = parent ? 1 + parent.depth : 0;
this.label = lib.SyntaxKind[node.kind];
this.key = key || "";
this.index = 0|index;
this.node = node;
this.parent = parent || null;
this.db = db;
// consider tracking whether a node is in an statement, an expression, or a type (and maybe track scope)
var tuple = (db.numeric.get(node.kind) || db.numeric.set(node.kind, {
list: [],
kvps: new Map(),
}).get(node.kind));
var data = {
record: this,
};
tuple.kvps.set(node, data);
tuple.list.push(data);
}
Record.prototype[tv.$.handle] = function (node, lib, parent, key, index) {
if (node) tv.visit(new Record(this.db, this, node, key, index, lib), node, lib);
return node;
};
Record.prototype.toArray = function () {
var record = this;
var list = [record];
while (record = record.parent) list.push(record);
return list.reverse();
};
return function index (root, lib = ts) {
var kinds = Object.keys(lib.SyntaxKind);
var count = kinds.length;
var at = 0;
var db = {
numeric: new Map(),
textual: new Map(),
};
tv.visit(new Record(db, null, root, root.fileName, -1, lib), root, lib);
for (at; at < count; at++) {
if (isNaN(Number(kinds[at])) && db.numeric.has(lib.SyntaxKind[kinds[at]])) {
db.textual.set(kinds[at], db.numeric.get(lib.SyntaxKind[kinds[at]]));
}
}
return db;
};
}()),
incremental: {
},
ast: {
Identifier: {
visit: function (vehicle, node, lib = ts) {
var _typeArguments = tv.tour(vehicle
, node.typeArguments, node, "typeArguments", lib) || void 0;
return node;
// return lib.updateIdentifier(node
// , _typeArguments);
},
},
QualifiedName: {
visit: function (vehicle, node, lib = ts) {
var _left = tv.stay(vehicle
, node.left, node, "left", lib);
var _right = tv.stay(vehicle
, node.right, node, "right", lib);
return node;
// return lib.updateQualifiedName(node
// , _left, _right);
},
},
ComputedPropertyName: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateComputedPropertyName(node
// , _expression);
},
},
TypeParameter: {
visit: function (vehicle, node, lib = ts) {
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _constraint = tv.stay(vehicle
, node.constraint, node, "constraint", lib);
var _default = tv.stay(vehicle
, node.default, node, "default", lib);
return node;
// return lib.updateTypeParameterDeclaration(node
// , _name, _constraint, _default);
},
},
Parameter: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _dotDotDotToken = tv.stay(vehicle
, node.dotDotDotToken, node, "dotDotDotToken", lib);
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _questionToken = tv.stay(vehicle
, node.questionToken, node, "questionToken", lib);
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
return node;
// return lib.updateParameter(node
// , _decorators, _modifiers, _dotDotDotToken, _name, _questionToken
// , _type, _initializer);
},
},
Decorator: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateDecorator(node
// , _expression);
},
},
PropertySignature: {
visit: function (vehicle, node, lib = ts) {
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _questionToken = tv.stay(vehicle
, node.questionToken, node, "questionToken", lib);
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
return node;
// return lib.updatePropertySignature(node
// , _modifiers, _name, _questionToken, _type, _initializer);
},
},
PropertyDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
return node;
// return lib.updateProperty(node
// , _decorators, _modifiers, _name, _type, _initializer);
},
},
MethodSignature: {
visit: function (vehicle, node, lib = ts) {
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _questionToken = tv.stay(vehicle
, node.questionToken, node, "questionToken", lib);
return node;
// return lib.updateMethodSignature(node
// , _typeParameters, _parameters, _type, _name, _questionToken);
},
},
MethodDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _asteriskToken = tv.stay(vehicle
, node.asteriskToken, node, "asteriskToken", lib);
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _questionToken = tv.stay(vehicle
, node.questionToken, node, "questionToken", lib);
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _body = tv.stay(vehicle
, node.body, node, "body", lib);
return node;
// return lib.updateMethod(node
// , _decorators, _modifiers, _asteriskToken, _name, _questionToken
// , _typeParameters, _parameters, _type, _body);
},
},
Constructor: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _body = tv.stay(vehicle
, node.body, node, "body", lib);
return node;
// return lib.updateConstructor(node
// , _decorators, _modifiers, _parameters, _body);
},
},
GetAccessor: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _body = tv.stay(vehicle
, node.body, node, "body", lib);
return node;
// return lib.updateGetAccessor(node
// , _decorators, _modifiers, _name, _parameters, _type
// , _body);
},
},
SetAccessor: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _body = tv.stay(vehicle
, node.body, node, "body", lib);
return node;
// return lib.updateSetAccessor(node
// , _decorators, _modifiers, _name, _parameters, _body);
},
},
CallSignature: {
visit: function (vehicle, node, lib = ts) {
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateCallSignature(node
// , _typeParameters, _parameters, _type);
},
},
ConstructSignature: {
visit: function (vehicle, node, lib = ts) {
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateConstructSignature(node
// , _typeParameters, _parameters, _type);
},
},
IndexSignature: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateIndexSignature(node
// , _decorators, _modifiers, _parameters, _type);
},
},
TypePredicate: {
visit: function (vehicle, node, lib = ts) {
var _parameterName = tv.stay(vehicle
, node.parameterName, node, "parameterName", lib);
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateTypePredicateNode(node
// , _parameterName, _type);
},
},
TypeReference: {
visit: function (vehicle, node, lib = ts) {
var _typeName = tv.stay(vehicle
, node.typeName, node, "typeName", lib);
var _typeArguments = tv.tour(vehicle
, node.typeArguments, node, "typeArguments", lib) || void 0;
return node;
// return lib.updateTypeReferenceNode(node
// , _typeName, _typeArguments);
},
},
FunctionType: {
visit: function (vehicle, node, lib = ts) {
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateFunctionTypeNode(node
// , _typeParameters, _parameters, _type);
},
},
ConstructorType: {
visit: function (vehicle, node, lib = ts) {
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateConstructorTypeNode(node
// , _typeParameters, _parameters, _type);
},
},
TypeQuery: {
visit: function (vehicle, node, lib = ts) {
var _exprName = tv.stay(vehicle
, node.exprName, node, "exprName", lib);
return node;
// return lib.updateTypeQueryNode(node
// , _exprName);
},
},
TypeLiteral: {
visit: function (vehicle, node, lib = ts) {
var _members = tv.tour(vehicle
, node.members, node, "members", lib) || void 0;
return node;
// return lib.updateTypeLiteralNode(node
// , _members);
},
},
ArrayType: {
visit: function (vehicle, node, lib = ts) {
var _elementType = tv.stay(vehicle
, node.elementType, node, "elementType", lib);
return node;
// return lib.updateArrayTypeNode(node
// , _elementType);
},
},
TupleType: {
visit: function (vehicle, node, lib = ts) {
var _elementTypes = tv.tour(vehicle
, node.elementTypes, node, "elementTypes", lib) || void 0;
return node;
// return lib.updateTypleTypeNode(node
// , _elementTypes);
},
},
UnionType: {
visit: function (vehicle, node, lib = ts) {
var _types = tv.tour(vehicle
, node.types, node, "types", lib) || void 0;
return node;
// return lib.updateUnionTypeNode(node
// , _types);
},
},
IntersectionType: {
visit: function (vehicle, node, lib = ts) {
var _types = tv.tour(vehicle
, node.types, node, "types", lib) || void 0;
return node;
// return lib.updateIntersectionTypeNode(node
// , _types);
},
},
ParenthesizedType: {
visit: function (vehicle, node, lib = ts) {
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateParenthesizedType(node
// , _type);
},
},
TypeOperator: {
visit: function (vehicle, node, lib = ts) {
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateTypeOperatorNode(node
// , _type);
},
},
IndexedAccessType: {
visit: function (vehicle, node, lib = ts) {
var _objectType = tv.stay(vehicle
, node.objectType, node, "objectType", lib);
var _indexType = tv.stay(vehicle
, node.indexType, node, "indexType", lib);
return node;
// return lib.updateIndexedAccessTypeNode(node
// , _objectType, _indexType);
},
},
MappedType: {
visit: function (vehicle, node, lib = ts) {
var _readonlyToken = tv.stay(vehicle
, node.readonlyToken, node, "readonlyToken", lib);
var _typeParameter = tv.stay(vehicle
, node.typeParameter, node, "typeParameter", lib);
var _questionToken = tv.stay(vehicle
, node.questionToken, node, "questionToken", lib);
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateMappedTypeNode(node
// , _readonlyToken, _typeParameter, _questionToken, _type);
},
},
LiteralType: {
visit: function (vehicle, node, lib = ts) {
var _literal = tv.stay(vehicle
, node.literal, node, "literal", lib);
return node;
// return lib.updateLiteralTypeNode(node
// , _literal);
},
},
ObjectBindingPattern: {
visit: function (vehicle, node, lib = ts) {
var _elements = tv.tour(vehicle
, node.elements, node, "elements", lib) || void 0;
return node;
// return lib.updateObjectBindingPattern(node
// , _elements);
},
},
ArrayBindingPattern: {
visit: function (vehicle, node, lib = ts) {
var _elements = tv.tour(vehicle
, node.elements, node, "elements", lib) || void 0;
return node;
// return lib.updateArrayBindingPattern(node
// , _elements);
},
},
BindingElement: {
visit: function (vehicle, node, lib = ts) {
var _dotDotDotToken = tv.stay(vehicle
, node.dotDotDotToken, node, "dotDotDotToken", lib);
var _propertyName = tv.stay(vehicle
, node.propertyName, node, "propertyName", lib);
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
return node;
// return lib.updateBindingElement(node
// , _dotDotDotToken, _propertyName, _name, _initializer);
},
},
ArrayLiteralExpression: {
visit: function (vehicle, node, lib = ts) {
var _elements = tv.tour(vehicle
, node.elements, node, "elements", lib) || void 0;
return node;
// return lib.updateArrayLiteral(node
// , _elements);
},
},
ObjectLiteralExpression: {
visit: function (vehicle, node, lib = ts) {
var _properties = tv.tour(vehicle
, node.properties, node, "properties", lib) || void 0;
return node;
// return lib.updateObjectLiteral(node
// , _properties);
},
},
PropertyAccessExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
return node;
// return lib.updatePropertyAccess(node
// , _expression, _name);
},
},
ElementAccessExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _argumentExpression = tv.stay(vehicle
, node.argumentExpression, node, "argumentExpression", lib);
return node;
// return lib.updateElementAccess(node
// , _expression, _argumentExpression);
},
},
CallExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _typeArguments = tv.tour(vehicle
, node.typeArguments, node, "typeArguments", lib) || void 0;
var _arguments = tv.tour(vehicle
, node.arguments, node, "arguments", lib) || void 0;
return node;
// return lib.updateCall(node
// , _expression, _typeArguments, _arguments);
},
},
NewExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _typeArguments = tv.tour(vehicle
, node.typeArguments, node, "typeArguments", lib) || void 0;
var _arguments = tv.tour(vehicle
, node.arguments, node, "arguments", lib) || void 0;
return node;
// return lib.updateNew(node
// , _expression, _typeArguments, _arguments);
},
},
TaggedTemplateExpression: {
visit: function (vehicle, node, lib = ts) {
var _tag = tv.stay(vehicle
, node.tag, node, "tag", lib);
var _template = tv.stay(vehicle
, node.template, node, "template", lib);
return node;
// return lib.updateTaggedTemplate(node
// , _tag, _template);
},
},
TypeAssertionExpression: {
visit: function (vehicle, node, lib = ts) {
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateTypeAssertion(node
// , _type, _expression);
},
},
ParenthesizedExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateParen(node
// , _expression);
},
},
FunctionExpression: {
visit: function (vehicle, node, lib = ts) {
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _asteriskToken = tv.stay(vehicle
, node.asteriskToken, node, "asteriskToken", lib);
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _body = tv.stay(vehicle
, node.body, node, "body", lib);
return node;
// return lib.updateFunctionExpression(node
// , _modifiers, _asteriskToken, _name, _typeParameters, _parameters
// , _type, _body);
},
},
ArrowFunction: {
visit: function (vehicle, node, lib = ts) {
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _body = tv.stay(vehicle
, node.body, node, "body", lib);
return node;
// return lib.updateArrowFunction(node
// , _modifiers, _typeParameters, _parameters, _type, _body);
},
},
DeleteExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateDelete(node
// , _expression);
},
},
TypeOfExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateTypeOf(node
// , _expression);
},
},
VoidExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateVoid(node
// , _expression);
},
},
AwaitExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateAwait(node
// , _expression);
},
},
PrefixUnaryExpression: {
visit: function (vehicle, node, lib = ts) {
var _operand = tv.stay(vehicle
, node.operand, node, "operand", lib);
return node;
// return lib.updatePrefix(node
// , _operand);
},
},
PostfixUnaryExpression: {
visit: function (vehicle, node, lib = ts) {
var _operand = tv.stay(vehicle
, node.operand, node, "operand", lib);
return node;
// return lib.updatePostfix(node
// , _operand);
},
},
BinaryExpression: {
visit: function (vehicle, node, lib = ts) {
var _left = tv.stay(vehicle
, node.left, node, "left", lib);
var _right = tv.stay(vehicle
, node.right, node, "right", lib);
var _operatorToken = tv.stay(vehicle
, node.operatorToken, node, "operatorToken", lib);
return node;
// return lib.updateBinary(node
// , _left, _right, _operatorToken);
},
},
ConditionalExpression: {
visit: function (vehicle, node, lib = ts) {
var _condition = tv.stay(vehicle
, node.condition, node, "condition", lib);
var _whenTrue = tv.stay(vehicle
, node.whenTrue, node, "whenTrue", lib);
var _whenFalse = tv.stay(vehicle
, node.whenFalse, node, "whenFalse", lib);
return node;
// return lib.updateConditional(node
// , _condition, _whenTrue, _whenFalse);
},
},
TemplateExpression: {
visit: function (vehicle, node, lib = ts) {
var _head = tv.stay(vehicle
, node.head, node, "head", lib);
var _templateSpans = tv.tour(vehicle
, node.templateSpans, node, "templateSpans", lib) || void 0;
return node;
// return lib.updateTemplateExpression(node
// , _head, _templateSpans);
},
},
YieldExpression: {
visit: function (vehicle, node, lib = ts) {
var _asteriskToken = tv.stay(vehicle
, node.asteriskToken, node, "asteriskToken", lib);
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateYield(node
// , _asteriskToken, _expression);
},
},
SpreadElement: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateSpread(node
// , _expression);
},
},
ClassExpression: {
visit: function (vehicle, node, lib = ts) {
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _heritageClauses = tv.tour(vehicle
, node.heritageClauses, node, "heritageClauses", lib) || void 0;
var _members = tv.tour(vehicle
, node.members, node, "members", lib) || void 0;
return node;
// return lib.updateClassExpression(node
// , _modifiers, _name, _typeParameters, _heritageClauses, _members);
},
},
ExpressionWithTypeArguments: {
visit: function (vehicle, node, lib = ts) {
var _typeArguments = tv.tour(vehicle
, node.typeArguments, node, "typeArguments", lib) || void 0;
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateExpressionWithTypeArguments(node
// , _typeArguments, _expression);
},
},
AsExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateAsExpression(node
// , _expression, _type);
},
},
NonNullExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateNonNullExpression(node
// , _expression);
},
},
MetaProperty: {
visit: function (vehicle, node, lib = ts) {
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
return node;
// return lib.updateMetaProperty(node
// , _name);
},
},
TemplateSpan: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _literal = tv.stay(vehicle
, node.literal, node, "literal", lib);
return node;
// return lib.updateTemplateSpan(node
// , _expression, _literal);
},
},
Block: {
visit: function (vehicle, node, lib = ts) {
var _statements = tv.tour(vehicle
, node.statements, node, "statements", lib) || void 0;
return node;
// return lib.updateBlock(node
// , _statements);
},
},
VariableStatement: {
visit: function (vehicle, node, lib = ts) {
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _declarationList = tv.stay(vehicle
, node.declarationList, node, "declarationList", lib);
return node;
// return lib.updateVariableStatement(node
// , _modifiers, _declarationList);
},
},
ExpressionStatement: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateStatement(node
// , _expression);
},
},
IfStatement: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _thenStatement = tv.stay(vehicle
, node.thenStatement, node, "thenStatement", lib);
var _elseStatement = tv.stay(vehicle
, node.elseStatement, node, "elseStatement", lib);
return node;
// return lib.updateIf(node
// , _expression, _thenStatement, _elseStatement);
},
},
DoStatement: {
visit: function (vehicle, node, lib = ts) {
var _statement = tv.stay(vehicle
, node.statement, node, "statement", lib);
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateDo(node
// , _statement, _expression);
},
},
WhileStatement: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _statement = tv.stay(vehicle
, node.statement, node, "statement", lib);
return node;
// return lib.updateWhile(node
// , _expression, _statement);
},
},
ForStatement: {
visit: function (vehicle, node, lib = ts) {
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
var _condition = tv.stay(vehicle
, node.condition, node, "condition", lib);
var _incrementor = tv.stay(vehicle
, node.incrementor, node, "incrementor", lib);
var _statement = tv.stay(vehicle
, node.statement, node, "statement", lib);
return node;
// return lib.updateFor(node
// , _initializer, _condition, _incrementor, _statement);
},
},
ForInStatement: {
visit: function (vehicle, node, lib = ts) {
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _statement = tv.stay(vehicle
, node.statement, node, "statement", lib);
return node;
// return lib.updateForIn(node
// , _initializer, _expression, _statement);
},
},
ForOfStatement: {
visit: function (vehicle, node, lib = ts) {
var _awaitModifier = tv.stay(vehicle
, node.awaitModifier, node, "awaitModifier", lib);
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _statement = tv.stay(vehicle
, node.statement, node, "statement", lib);
return node;
// return lib.updateForOf(node
// , _awaitModifier, _initializer, _expression, _statement);
},
},
ContinueStatement: {
visit: function (vehicle, node, lib = ts) {
var _label = tv.stay(vehicle
, node.label, node, "label", lib);
return node;
// return lib.updateContinue(node
// , _label);
},
},
BreakStatement: {
visit: function (vehicle, node, lib = ts) {
var _label = tv.stay(vehicle
, node.label, node, "label", lib);
return node;
// return lib.updateBreak(node
// , _label);
},
},
ReturnStatement: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateReturn(node
// , _expression);
},
},
WithStatement: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _statement = tv.stay(vehicle
, node.statement, node, "statement", lib);
return node;
// return lib.updateWith(node
// , _expression, _statement);
},
},
SwitchStatement: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _caseBlock = tv.stay(vehicle
, node.caseBlock, node, "caseBlock", lib);
return node;
// return lib.updateSwitch(node
// , _expression, _caseBlock);
},
},
LabeledStatement: {
visit: function (vehicle, node, lib = ts) {
var _label = tv.stay(vehicle
, node.label, node, "label", lib);
var _statement = tv.stay(vehicle
, node.statement, node, "statement", lib);
return node;
// return lib.updateLabel(node
// , _label, _statement);
},
},
ThrowStatement: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateThrow(node
// , _expression);
},
},
TryStatement: {
visit: function (vehicle, node, lib = ts) {
var _tryBlock = tv.stay(vehicle
, node.tryBlock, node, "tryBlock", lib);
var _catchClause = tv.stay(vehicle
, node.catchClause, node, "catchClause", lib);
var _finallyBlock = tv.stay(vehicle
, node.finallyBlock, node, "finallyBlock", lib);
return node;
// return lib.updateTry(node
// , _tryBlock, _catchClause, _finallyBlock);
},
},
VariableDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
return node;
// return lib.updateVariableDeclaration(node
// , _name, _type, _initializer);
},
},
VariableDeclarationList: {
visit: function (vehicle, node, lib = ts) {
var _declarations = tv.tour(vehicle
, node.declarations, node, "declarations", lib) || void 0;
return node;
// return lib.updateVariableDeclarationList(node
// , _declarations);
},
},
FunctionDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _asteriskToken = tv.stay(vehicle
, node.asteriskToken, node, "asteriskToken", lib);
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _parameters = tv.tour(vehicle
, node.parameters, node, "parameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
var _body = tv.stay(vehicle
, node.body, node, "body", lib);
return node;
// return lib.updateFunctionDeclaration(node
// , _decorators, _modifiers, _asteriskToken, _name, _typeParameters
// , _parameters, _type, _body);
},
},
ClassDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _heritageClauses = tv.tour(vehicle
, node.heritageClauses, node, "heritageClauses", lib) || void 0;
var _members = tv.tour(vehicle
, node.members, node, "members", lib) || void 0;
return node;
// return lib.updateClassDeclaration(node
// , _decorators, _modifiers, _name, _typeParameters, _heritageClauses
// , _members);
},
},
InterfaceDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _heritageClauses = tv.tour(vehicle
, node.heritageClauses, node, "heritageClauses", lib) || void 0;
var _members = tv.tour(vehicle
, node.members, node, "members", lib) || void 0;
return node;
// return lib.updateInterfaceDeclaration(node
// , _decorators, _modifiers, _name, _typeParameters, _heritageClauses
// , _members);
},
},
TypeAliasDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _typeParameters = tv.tour(vehicle
, node.typeParameters, node, "typeParameters", lib) || void 0;
var _type = tv.stay(vehicle
, node.type, node, "type", lib);
return node;
// return lib.updateTypeAliasDeclaration(node
// , _decorators, _modifiers, _name, _typeParameters, _type);
},
},
EnumDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _members = tv.tour(vehicle
, node.members, node, "members", lib) || void 0;
return node;
// return lib.updateEnumDeclaration(node
// , _decorators, _modifiers, _name, _members);
},
},
ModuleDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _body = tv.stay(vehicle
, node.body, node, "body", lib);
return node;
// return lib.updateModuleDeclaration(node
// , _decorators, _modifiers, _name, _body);
},
},
ModuleBlock: {
visit: function (vehicle, node, lib = ts) {
var _statements = tv.tour(vehicle
, node.statements, node, "statements", lib) || void 0;
return node;
// return lib.updateModuleBlock(node
// , _statements);
},
},
CaseBlock: {
visit: function (vehicle, node, lib = ts) {
var _clauses = tv.tour(vehicle
, node.clauses, node, "clauses", lib) || void 0;
return node;
// return lib.updateCaseBlock(node
// , _clauses);
},
},
NamespaceExportDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
return node;
// return lib.updateNamespaceExportDeclaration(node
// , _name);
},
},
ImportEqualsDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _moduleReference = tv.stay(vehicle
, node.moduleReference, node, "moduleReference", lib);
return node;
// return lib.updateImportEqualsDeclaration(node
// , _decorators, _modifiers, _name, _moduleReference);
},
},
ImportDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _importClause = tv.stay(vehicle
, node.importClause, node, "importClause", lib);
var _moduleSpecifier = tv.stay(vehicle
, node.moduleSpecifier, node, "moduleSpecifier", lib);
return node;
// return lib.updateImportDeclaration(node
// , _decorators, _modifiers, _importClause, _moduleSpecifier);
},
},
ImportClause: {
visit: function (vehicle, node, lib = ts) {
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _namedBindings = tv.stay(vehicle
, node.namedBindings, node, "namedBindings", lib);
return node;
// return lib.updateImportClause(node
// , _name, _namedBindings);
},
},
NamespaceImport: {
visit: function (vehicle, node, lib = ts) {
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
return node;
// return lib.updateNamespaceImport(node
// , _name);
},
},
NamedImports: {
visit: function (vehicle, node, lib = ts) {
var _elements = tv.tour(vehicle
, node.elements, node, "elements", lib) || void 0;
return node;
// return lib.updateNamedImports(node
// , _elements);
},
},
ImportSpecifier: {
visit: function (vehicle, node, lib = ts) {
var _propertyName = tv.stay(vehicle
, node.propertyName, node, "propertyName", lib);
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
return node;
// return lib.updateImportSpecifier(node
// , _propertyName, _name);
},
},
ExportAssignment: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateExportAssignment(node
// , _decorators, _modifiers, _expression);
},
},
ExportDeclaration: {
visit: function (vehicle, node, lib = ts) {
var _decorators = tv.tour(vehicle
, node.decorators, node, "decorators", lib) || void 0;
var _modifiers = tv.tour(vehicle
, node.modifiers, node, "modifiers", lib) || void 0;
var _exportClause = tv.stay(vehicle
, node.exportClause, node, "exportClause", lib);
var _moduleSpecifier = tv.stay(vehicle
, node.moduleSpecifier, node, "moduleSpecifier", lib);
return node;
// return lib.updateExportDeclaration(node
// , _decorators, _modifiers, _exportClause, _moduleSpecifier);
},
},
NamedExports: {
visit: function (vehicle, node, lib = ts) {
var _elements = tv.tour(vehicle
, node.elements, node, "elements", lib) || void 0;
return node;
// return lib.updateNamedExports(node
// , _elements);
},
},
ExportSpecifier: {
visit: function (vehicle, node, lib = ts) {
var _propertyName = tv.stay(vehicle
, node.propertyName, node, "propertyName", lib);
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
return node;
// return lib.updateExportSpecifier(node
// , _propertyName, _name);
},
},
ExternalModuleReference: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateExternalModuleReference(node
// , _expression);
},
},
JsxElement: {
visit: function (vehicle, node, lib = ts) {
var _openingElement = tv.stay(vehicle
, node.openingElement, node, "openingElement", lib);
var _children = tv.tour(vehicle
, node.children, node, "children", lib) || void 0;
var _closingElement = tv.stay(vehicle
, node.closingElement, node, "closingElement", lib);
return node;
// return lib.updateJsxElement(node
// , _openingElement, _children, _closingElement);
},
},
JsxSelfClosingElement: {
visit: function (vehicle, node, lib = ts) {
var _tagName = tv.stay(vehicle
, node.tagName, node, "tagName", lib);
var _attributes = tv.stay(vehicle
, node.attributes, node, "attributes", lib);
return node;
// return lib.updateJsxSelfClosingElement(node
// , _tagName, _attributes);
},
},
JsxOpeningElement: {
visit: function (vehicle, node, lib = ts) {
var _tagName = tv.stay(vehicle
, node.tagName, node, "tagName", lib);
var _attributes = tv.stay(vehicle
, node.attributes, node, "attributes", lib);
return node;
// return lib.updateJsxOpeningElement(node
// , _tagName, _attributes);
},
},
JsxClosingElement: {
visit: function (vehicle, node, lib = ts) {
var _tagName = tv.stay(vehicle
, node.tagName, node, "tagName", lib);
return node;
// return lib.updateJsxClosingElement(node
// , _tagName);
},
},
JsxAttribute: {
visit: function (vehicle, node, lib = ts) {
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
return node;
// return lib.updateJsxAttribute(node
// , _name, _initializer);
},
},
JsxAttributes: {
visit: function (vehicle, node, lib = ts) {
var _properties = tv.tour(vehicle
, node.properties, node, "properties", lib) || void 0;
return node;
// return lib.updateJsxAttributes(node
// , _properties);
},
},
JsxSpreadAttribute: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateJsxSpreadAttribute(node
// , _expression);
},
},
JsxExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateJsxExpression(node
// , _expression);
},
},
CaseClause: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
var _statements = tv.tour(vehicle
, node.statements, node, "statements", lib) || void 0;
return node;
// return lib.updateCaseClause(node
// , _expression, _statements);
},
},
DefaultClause: {
visit: function (vehicle, node, lib = ts) {
var _statements = tv.tour(vehicle
, node.statements, node, "statements", lib) || void 0;
return node;
// return lib.updateDefaultClause(node
// , _statements);
},
},
HeritageClause: {
visit: function (vehicle, node, lib = ts) {
var _types = tv.tour(vehicle
, node.types, node, "types", lib) || void 0;
return node;
// return lib.updateHeritageClause(node
// , _types);
},
},
CatchClause: {
visit: function (vehicle, node, lib = ts) {
var _variableDeclaration = tv.stay(vehicle
, node.variableDeclaration, node, "variableDeclaration", lib);
var _block = tv.stay(vehicle
, node.block, node, "block", lib);
return node;
// return lib.updateCatchClause(node
// , _variableDeclaration, _block);
},
},
PropertyAssignment: {
visit: function (vehicle, node, lib = ts) {
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
return node;
// return lib.updatePropertyAssignment(node
// , _name, _initializer);
},
},
ShorthandPropertyAssignment: {
visit: function (vehicle, node, lib = ts) {
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _objectAssignmentInitializer = tv.stay(vehicle
, node.objectAssignmentInitializer, node, "objectAssignmentInitializer", lib);
return node;
// return lib.updateShorthandPropertyAssignment(node
// , _name, _objectAssignmentInitializer);
},
},
SpreadAssignment: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updateSpreadAssignment(node
// , _expression);
},
},
EnumMember: {
visit: function (vehicle, node, lib = ts) {
var _name = tv.stay(vehicle
, node.name, node, "name", lib);
var _initializer = tv.stay(vehicle
, node.initializer, node, "initializer", lib);
return node;
// return lib.updateEnumMember(node
// , _name, _initializer);
},
},
SourceFile: {
visit: function (vehicle, node, lib = ts) {
var _statements = tv.tour(vehicle
, node.statements, node, "statements", lib) || void 0;
return node;
// return lib.updateSourceFileNode(node
// , _statements);
},
},
PartiallyEmittedExpression: {
visit: function (vehicle, node, lib = ts) {
var _expression = tv.stay(vehicle
, node.expression, node, "expression", lib);
return node;
// return lib.updatePartiallyEmittedExpression(node
// , _expression);
},
},
CommaListExpression: {
visit: function (vehicle, node, lib = ts) {
var _elements = tv.tour(vehicle
, node.elements, node, "elements", lib) || void 0;
return node;
// return lib.updateCommaList(node
// , _elements);
},
},
},
/***
defs: {
TypeNode: [
"AnyKeyword",
"ThisKeyword",
"ThisType",
"FunctionType",
"ConstructorType",
"TypeReference",
"TypePredicate",
"TypeQuery",
"TypeLiteral",
"ArrayType",
"TupleType",
"UnionType",
"IntersectionType",
"ParenthesizedType",
"TypeOperator",
"IndexedAccessType",
"MappedType",
"LiteralType",
"NullKeyword",
"TrueKeyword",
"ExpressionWithTypeArguments",
"JSDocAllType",
"JSDocUnknownType",
"JSDocArrayType",
"JSDocUnionType",
"JSDocTupleType",
"JSDocNonNullableType",
"JSDocNullableType",
"JSDocRecordType",
"JSDocTypeReference",
"JSDocOptionalType",
"JSDocFunctionType",
"JSDocVariadicType",
"JSDocConstructorType",
"JSDocThisType",
"JSDocLiteralType",
"JSDocTypeLiteral",
],
Expression: [
"OmittedExpression",
"PrefixUnaryExpression",
"PostfixUnaryExpression",
"PartiallyEmittedExpression",
"Identifier",
"NullKeyword",
"TrueKeyword",
"ThisKeyword",
"SuperKeyword",
"FunctionExpression",
"StringLiteral",
"RegularExpressionLiteral",
"NoSubstitutionTemplateLiteral",
"NumericLiteral",
"TemplateExpression",
"ParenthesizedExpression",
"ArrayLiteralExpression",
"NewExpression",
"MetaProperty",
"JsxElement",
"JsxSelfClosingElement",
"ClassExpression",
"PropertyAccessExpression",
"ElementAccessExpression",
"TaggedTemplateExpression",
"CallExpression",
"NonNullExpression",
"DeleteExpression",
"TypeOfExpression",
"VoidExpression",
"AwaitExpression",
"TypeAssertionExpression",
"YieldExpression",
"BinaryExpression",
"ConditionalExpression",
"ArrowFunction",
"SpreadElement",
"AsExpression",
"JsxOpeningElement",
"JsxExpression",
"CommaListExpression",
],
Modifier: [
"AbstractKeyword",
"AsyncKeyword",
"ConstKeyword",
"DeclareKeyword",
"DefaultKeyword",
"ExportKeyword",
"PublicKeyword",
"PrivateKeyword",
"ProtectedKeyword",
"ReadonlyKeyword",
"StaticKeyword",
],
TypeElement: [
"CallSignature",
"ConstructSignature",
"PropertySignature",
"JSDocRecordMember",
"MethodSignature",
"IndexSignature",
"MissingDeclaration",
"JSDocPropertyTag",
],
ObjectLiteralElementLike: [
"PropertyAssignment",
"ShorthandPropertyAssignment",
"SpreadAssignment",
"MethodDeclaration",
"GetAccessor",
"SetAccessor",
],
LeftHandSideExpression: [
"PartiallyEmittedExpression",
"Identifier",
"NullKeyword",
"TrueKeyword",
"ThisKeyword",
"SuperKeyword",
"FunctionExpression",
"StringLiteral",
"RegularExpressionLiteral",
"NoSubstitutionTemplateLiteral",
"NumericLiteral",
"TemplateExpression",
"ParenthesizedExpression",
"ArrayLiteralExpression",
"NewExpression",
"MetaProperty",
"JsxElement",
"JsxSelfClosingElement",
"ClassExpression",
"PropertyAccessExpression",
"ElementAccessExpression",
"TaggedTemplateExpression",
"CallExpression",
"NonNullExpression",
],
UnaryExpression: [
"PrefixUnaryExpression",
"PostfixUnaryExpression",
"PartiallyEmittedExpression",
"Identifier",
"NullKeyword",
"TrueKeyword",
"ThisKeyword",
"SuperKeyword",
"FunctionExpression",
"StringLiteral",
"RegularExpressionLiteral",
"NoSubstitutionTemplateLiteral",
"NumericLiteral",
"TemplateExpression",
"ParenthesizedExpression",
"ArrayLiteralExpression",
"NewExpression",
"MetaProperty",
"JsxElement",
"JsxSelfClosingElement",
"ClassExpression",
"PropertyAccessExpression",
"ElementAccessExpression",
"TaggedTemplateExpression",
"CallExpression",
"NonNullExpression",
"DeleteExpression",
"TypeOfExpression",
"VoidExpression",
"AwaitExpression",
"TypeAssertionExpression",
],
BinaryOperator: [
"AsteriskAsteriskToken",
"AsteriskToken",
"SlashToken",
"PercentToken",
"PlusToken",
"MinusToken",
"LessThanLessThanToken",
"GreaterThanGreaterThanToken",
"GreaterThanGreaterThanGreaterThanToken",
"LessThanToken",
"LessThanEqualsToken",
"GreaterThanToken",
"GreaterThanEqualsToken",
"InstanceOfKeyword",
"InKeyword",
"EqualsEqualsToken",
"EqualsEqualsEqualsToken",
"ExclamationEqualsEqualsToken",
"ExclamationEqualsToken",
"AmpersandToken",
"BarToken",
"CaretToken",
"AmpersandAmpersandToken",
"BarBarToken",
"EqualsToken",
"PlusEqualsToken",
"MinusEqualsToken",
"AsteriskAsteriskEqualsToken",
"AsteriskEqualsToken",
"SlashEqualsToken",
"PercentEqualsToken",
"AmpersandEqualsToken",
"BarEqualsToken",
"CaretEqualsToken",
"LessThanLessThanEqualsToken",
"GreaterThanGreaterThanGreaterThanEqualsToken",
"GreaterThanGreaterThanEqualsToken",
"CommaToken",
],
Statement: [
"FunctionDeclaration",
"MissingDeclaration",
"ClassDeclaration",
"InterfaceDeclaration",
"TypeAliasDeclaration",
"EnumDeclaration",
"ModuleDeclaration",
"ImportEqualsDeclaration",
"NamespaceExportDeclaration",
"ExportDeclaration",
"ExportAssignment",
"NotEmittedStatement",
"EndOfDeclarationMarker",
"MergeDeclarationMarker",
"EmptyStatement",
"DebuggerStatement",
"Block",
"VariableStatement",
"ExpressionStatement",
"IfStatement",
"DoStatement",
"WhileStatement",
"ForStatement",
"ForInStatement",
"ForOfStatement",
"BreakStatement",
"ContinueStatement",
"ReturnStatement",
"WithStatement",
"SwitchStatement",
"LabeledStatement",
"ThrowStatement",
"TryStatement",
"ModuleBlock",
"ImportDeclaration",
],
ClassElement: [
"PropertyDeclaration",
"MethodDeclaration",
"Constructor",
"SemicolonClassElement",
"GetAccessor",
"SetAccessor",
"IndexSignature",
"MissingDeclaration",
],
PrimaryExpression: [
"Identifier",
"NullKeyword",
"TrueKeyword",
"ThisKeyword",
"SuperKeyword",
"FunctionExpression",
"StringLiteral",
"RegularExpressionLiteral",
"NoSubstitutionTemplateLiteral",
"NumericLiteral",
"TemplateExpression",
"ParenthesizedExpression",
"ArrayLiteralExpression",
"NewExpression",
"MetaProperty",
"JsxElement",
"JsxSelfClosingElement",
"ClassExpression",
],
JSDocType: [
"JSDocAllType",
"JSDocUnknownType",
"JSDocArrayType",
"JSDocUnionType",
"JSDocTupleType",
"JSDocNonNullableType",
"JSDocNullableType",
"JSDocRecordType",
"JSDocTypeReference",
"JSDocOptionalType",
"JSDocFunctionType",
"JSDocVariadicType",
"JSDocConstructorType",
"JSDocThisType",
"JSDocLiteralType",
"JSDocTypeLiteral",
],
JSDocTag: [
"JSDocTag",
"JSDocAugmentsTag",
"JSDocTemplateTag",
"JSDocReturnTag",
"JSDocTypeTag",
"JSDocTypedefTag",
"JSDocPropertyTag",
"JSDocParameterTag",
],
},
schema: {
QualifiedName: { tags: [], fields: {
left: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "QualifiedName", tags: [] },
]},
right: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
}},
TypeParameter: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
constraint: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
default: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
ShorthandPropertyAssignment: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
objectAssignmentInitializer: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
SpreadAssignment: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
Parameter: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "ObjectBindingPattern", tags: [] },
{ id: "ArrayBindingPattern", tags: [] },
]},
dotDotDotToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "DotDotDotToken", tags: [] },
]},
questionToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "QuestionToken", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
initializer: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
PropertyDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
{ id: "NumericLiteral", tags: [] },
{ id: "ComputedPropertyName", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
initializer: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
PropertySignature: { tags: [], fields: {
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
{ id: "NumericLiteral", tags: [] },
{ id: "ComputedPropertyName", tags: [] },
]},
questionToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "QuestionToken", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
initializer: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
PropertyAssignment: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
{ id: "NumericLiteral", tags: [] },
{ id: "ComputedPropertyName", tags: [] },
]},
initializer: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
VariableDeclaration: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "ObjectBindingPattern", tags: [] },
{ id: "ArrayBindingPattern", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
initializer: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
BindingElement: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "ObjectBindingPattern", tags: [] },
{ id: "ArrayBindingPattern", tags: [] },
]},
propertyName: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
{ id: "NumericLiteral", tags: [] },
{ id: "ComputedPropertyName", tags: [] },
]},
dotDotDotToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "DotDotDotToken", tags: [] },
]},
initializer: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
FunctionType: { tags: [], fields: {
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
ConstructorType: { tags: [], fields: {
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
CallSignature: { tags: [], fields: {
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
ConstructSignature: { tags: [], fields: {
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
IndexSignature: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
MethodDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
{ id: "NumericLiteral", tags: [] },
{ id: "ComputedPropertyName", tags: [] },
]},
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
asteriskToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "AsteriskToken", tags: [] },
]},
questionToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "QuestionToken", tags: [] },
]},
body: { optional: true, collective: false, tags: [], kinds: [
{ id: "Block", tags: [] },
]},
}},
MethodSignature: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
{ id: "NumericLiteral", tags: [] },
{ id: "ComputedPropertyName", tags: [] },
]},
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
questionToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "QuestionToken", tags: [] },
]},
}},
Constructor: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
body: { optional: true, collective: false, tags: [], kinds: [
{ id: "Block", tags: [] },
]},
}},
GetAccessor: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
{ id: "NumericLiteral", tags: [] },
{ id: "ComputedPropertyName", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
body: { optional: false, collective: false, tags: [], kinds: [
{ id: "Block", tags: [] },
]},
}},
SetAccessor: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
{ id: "NumericLiteral", tags: [] },
{ id: "ComputedPropertyName", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
body: { optional: false, collective: false, tags: [], kinds: [
{ id: "Block", tags: [] },
]},
}},
FunctionExpression: { tags: [], fields: {
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
asteriskToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "AsteriskToken", tags: [] },
]},
body: { optional: false, collective: false, tags: [], kinds: [
{ id: "Block", tags: [] },
]},
}},
FunctionDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
asteriskToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "AsteriskToken", tags: [] },
]},
body: { optional: true, collective: false, tags: [], kinds: [
{ id: "Block", tags: [] },
]},
}},
ArrowFunction: { tags: [], fields: {
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
body: { optional: false, collective: false, tags: [], kinds: [
{ id: "Block", tags: [] },
{ id: "Expression", tags: [] },
]},
}},
TypeReference: { tags: [], fields: {
typeName: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "QualifiedName", tags: [] },
]},
typeArguments: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
TypePredicate: { tags: [], fields: {
parameterName: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "ThisType", tags: [] },
]},
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
TypeQuery: { tags: [], fields: {
exprName: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "QualifiedName", tags: [] },
]},
}},
TypeLiteral: { tags: [], fields: {
members: { optional: false, collective: true, tags: [], kinds: [
{ id: "TypeElement", tags: [] },
]},
}},
ArrayType: { tags: [], fields: {
elementType: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
TupleType: { tags: [], fields: {
elementTypes: { optional: false, collective: true, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
UnionType: { tags: [], fields: {
types: { optional: false, collective: true, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
IntersectionType: { tags: [], fields: {
types: { optional: false, collective: true, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
ParenthesizedType: { tags: [], fields: {
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
TypeOperator: { tags: [], fields: {
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
IndexedAccessType: { tags: [], fields: {
objectType: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
indexType: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
MappedType: { tags: [], fields: {
readonlyToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "ReadonlyKeyword", tags: [] },
]},
typeParameter: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
questionToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "QuestionToken", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
LiteralType: { tags: [], fields: {
literal: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
ObjectBindingPattern: { tags: [], fields: {
elements: { optional: false, collective: true, tags: [], kinds: [
{ id: "BindingElement", tags: [] },
]},
}},
ArrayBindingPattern: { tags: [], fields: {
elements: { optional: false, collective: true, tags: [], kinds: [
{ id: "BindingElement", tags: [] },
{ id: "OmittedExpression", tags: [] },
]},
}},
ArrayLiteralExpression: { tags: [], fields: {
elements: { optional: false, collective: true, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
ObjectLiteralExpression: { tags: [], fields: {
properties: { optional: false, collective: true, tags: [], kinds: [
{ id: "ObjectLiteralElementLike", tags: [] },
]},
}},
PropertyAccessExpression: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "LeftHandSideExpression", tags: [] },
]},
}},
ElementAccessExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "LeftHandSideExpression", tags: [] },
]},
argumentExpression: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
CallExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "LeftHandSideExpression", tags: [] },
]},
typeArguments: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
arguments: { optional: false, collective: true, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
NewExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "LeftHandSideExpression", tags: [] },
]},
typeArguments: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
arguments: { optional: true, collective: true, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
TaggedTemplateExpression: { tags: [], fields: {
tag: { optional: false, collective: false, tags: [], kinds: [
{ id: "LeftHandSideExpression", tags: [] },
]},
template: { optional: false, collective: false, tags: [], kinds: [
{ id: "TemplateExpression", tags: [] },
{ id: "NoSubstitutionTemplateLiteral", tags: [] },
]},
}},
TypeAssertionExpression: { tags: [], fields: {
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "UnaryExpression", tags: [] },
]},
}},
ParenthesizedExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
DeleteExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "UnaryExpression", tags: [] },
]},
}},
TypeOfExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "UnaryExpression", tags: [] },
]},
}},
VoidExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "UnaryExpression", tags: [] },
]},
}},
PrefixUnaryExpression: { tags: [], fields: {
operand: { optional: false, collective: false, tags: [], kinds: [
{ id: "UnaryExpression", tags: [] },
]},
}},
YieldExpression: { tags: [], fields: {
asteriskToken: { optional: true, collective: false, tags: [], kinds: [
{ id: "AsteriskToken", tags: [] },
]},
expression: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
AwaitExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "UnaryExpression", tags: [] },
]},
}},
PostfixUnaryExpression: { tags: [], fields: {
operand: { optional: false, collective: false, tags: [], kinds: [
{ id: "LeftHandSideExpression", tags: [] },
]},
}},
BinaryExpression: { tags: [], fields: {
left: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
operatorToken: { optional: false, collective: false, tags: [], kinds: [
{ id: "BinaryOperator", tags: [] },
]},
right: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
AsExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
NonNullExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
MetaProperty: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
}},
ConditionalExpression: { tags: [], fields: {
condition: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
whenTrue: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
whenFalse: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
SpreadElement: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
Block: { tags: [], fields: {
statements: { optional: false, collective: true, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
}},
ModuleBlock: { tags: [], fields: {
statements: { optional: false, collective: true, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
}},
SourceFile: { tags: [], fields: {
statements: { optional: false, collective: true, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
}},
VariableStatement: { tags: [], fields: {
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
declarationList: { optional: false, collective: false, tags: [], kinds: [
{ id: "VariableDeclarationList", tags: [] },
]},
}},
VariableDeclarationList: { tags: [], fields: {
declarations: { optional: false, collective: true, tags: [], kinds: [
{ id: "VariableDeclaration", tags: [] },
]},
}},
ExpressionStatement: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
IfStatement: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
thenStatement: { optional: false, collective: false, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
elseStatement: { optional: true, collective: false, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
}},
DoStatement: { tags: [], fields: {
statement: { optional: false, collective: false, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
WhileStatement: { tags: [], fields: {
statement: { optional: false, collective: false, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
ForStatement: { tags: [], fields: {
statement: { optional: false, collective: false, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
initializer: { optional: true, collective: false, tags: [], kinds: [
{ id: "VariableDeclarationList", tags: [] },
{ id: "Expression", tags: [] },
]},
condition: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
incrementor: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
ForInStatement: { tags: [], fields: {
statement: { optional: false, collective: false, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
initializer: { optional: false, collective: false, tags: [], kinds: [
{ id: "VariableDeclarationList", tags: [] },
{ id: "Expression", tags: [] },
]},
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
ForOfStatement: { tags: [], fields: {
statement: { optional: false, collective: false, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
awaitModifier: { optional: true, collective: false, tags: [], kinds: [
{ id: "AwaitKeyword", tags: [] },
]},
initializer: { optional: false, collective: false, tags: [], kinds: [
{ id: "VariableDeclarationList", tags: [] },
{ id: "Expression", tags: [] },
]},
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
ContinueStatement: { tags: [], fields: {
label: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
}},
BreakStatement: { tags: [], fields: {
label: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
}},
ReturnStatement: { tags: [], fields: {
expression: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
WithStatement: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
statement: { optional: false, collective: false, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
}},
SwitchStatement: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
caseBlock: { optional: false, collective: false, tags: [], kinds: [
{ id: "CaseBlock", tags: [] },
]},
}},
CaseBlock: { tags: [], fields: {
clauses: { optional: false, collective: true, tags: [], kinds: [
{ id: "CaseClause", tags: [] },
{ id: "DefaultClause", tags: [] },
]},
}},
CaseClause: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
statements: { optional: false, collective: true, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
}},
DefaultClause: { tags: [], fields: {
statements: { optional: false, collective: true, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
}},
LabeledStatement: { tags: [], fields: {
label: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
statement: { optional: false, collective: false, tags: [], kinds: [
{ id: "Statement", tags: [] },
]},
}},
ThrowStatement: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
TryStatement: { tags: [], fields: {
tryBlock: { optional: false, collective: false, tags: [], kinds: [
{ id: "Block", tags: [] },
]},
catchClause: { optional: true, collective: false, tags: [], kinds: [
{ id: "CatchClause", tags: [] },
]},
finallyBlock: { optional: true, collective: false, tags: [], kinds: [
{ id: "Block", tags: [] },
]},
}},
CatchClause: { tags: [], fields: {
variableDeclaration: { optional: false, collective: false, tags: [], kinds: [
{ id: "VariableDeclaration", tags: [] },
]},
block: { optional: false, collective: false, tags: [], kinds: [
{ id: "Block", tags: [] },
]},
}},
Decorator: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "LeftHandSideExpression", tags: [] },
]},
}},
ClassDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
heritageClauses: { optional: true, collective: true, tags: [], kinds: [
{ id: "HeritageClause", tags: [] },
]},
members: { optional: false, collective: true, tags: [], kinds: [
{ id: "ClassElement", tags: [] },
]},
}},
ClassExpression: { tags: [], fields: {
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
heritageClauses: { optional: true, collective: true, tags: [], kinds: [
{ id: "HeritageClause", tags: [] },
]},
members: { optional: false, collective: true, tags: [], kinds: [
{ id: "ClassElement", tags: [] },
]},
}},
InterfaceDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
heritageClauses: { optional: true, collective: true, tags: [], kinds: [
{ id: "HeritageClause", tags: [] },
]},
members: { optional: false, collective: true, tags: [], kinds: [
{ id: "TypeElement", tags: [] },
]},
}},
TypeAliasDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
typeParameters: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
EnumDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
members: { optional: false, collective: true, tags: [], kinds: [
{ id: "EnumMember", tags: [] },
]},
}},
EnumMember: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
{ id: "NumericLiteral", tags: [] },
{ id: "ComputedPropertyName", tags: [] },
]},
initializer: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
ModuleDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
]},
body: { optional: true, collective: false, tags: [], kinds: [
{ id: "ModuleBlock", tags: [] },
{ id: "NamespaceDeclaration", tags: [] },
{ id: "Identifier", tags: [] },
{ id: "JSDocNamespaceDeclaration", tags: [] },
]},
}},
ImportEqualsDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
moduleReference: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "QualifiedName", tags: [] },
{ id: "ExternalModuleReference", tags: [] },
]},
}},
ImportDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
importClause: { optional: true, collective: false, tags: [], kinds: [
{ id: "ImportClause", tags: [] },
]},
moduleSpecifier: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
ImportClause: { tags: [], fields: {
name: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
namedBindings: { optional: true, collective: false, tags: [], kinds: [
{ id: "NamespaceImport", tags: [] },
{ id: "NamedImports", tags: [] },
]},
}},
NamespaceExportDeclaration: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
}},
NamespaceImport: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
}},
NamedImports: { tags: [], fields: {
elements: { optional: false, collective: true, tags: [], kinds: [
{ id: "ImportSpecifier", tags: [] },
]},
}},
NamedExports: { tags: [], fields: {
elements: { optional: false, collective: true, tags: [], kinds: [
{ id: "ExportSpecifier", tags: [] },
]},
}},
ExportDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
exportClause: { optional: true, collective: false, tags: [], kinds: [
{ id: "NamedExports", tags: [] },
]},
moduleSpecifier: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
ImportSpecifier: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
propertyName: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
}},
ExportSpecifier: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
propertyName: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
}},
ExportAssignment: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
modifiers: { optional: true, collective: true, tags: [], kinds: [
{ id: "Modifier", tags: [] },
]},
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
TemplateExpression: { tags: [], fields: {
head: { optional: false, collective: false, tags: [], kinds: [
{ id: "TemplateHead", tags: [] },
]},
templateSpans: { optional: false, collective: true, tags: [], kinds: [
{ id: "TemplateSpan", tags: [] },
]},
}},
TemplateSpan: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
literal: { optional: false, collective: false, tags: [], kinds: [
{ id: "TemplateMiddle", tags: [] },
{ id: "TemplateTail", tags: [] },
]},
}},
ComputedPropertyName: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
HeritageClause: { tags: [], fields: {
types: { optional: false, collective: true, tags: [], kinds: [
{ id: "ExpressionWithTypeArguments", tags: [] },
]},
}},
ExpressionWithTypeArguments: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "LeftHandSideExpression", tags: [] },
]},
typeArguments: { optional: true, collective: true, tags: [], kinds: [
{ id: "TypeNode", tags: [] },
]},
}},
ExternalModuleReference: { tags: [], fields: {
expression: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
MissingDeclaration: { tags: [], fields: {
decorators: { optional: true, collective: true, tags: [], kinds: [
{ id: "Decorator", tags: [] },
]},
}},
CommaListExpression: { tags: [], fields: {
elements: { optional: false, collective: true, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
JsxElement: { tags: [], fields: {
openingElement: { optional: false, collective: false, tags: [], kinds: [
{ id: "JsxOpeningElement", tags: [] },
]},
children: { optional: false, collective: true, tags: [], kinds: [
{ id: "JsxText", tags: [] },
{ id: "JsxExpression", tags: [] },
{ id: "JsxElement", tags: [] },
{ id: "JsxSelfClosingElement", tags: [] },
]},
closingElement: { optional: false, collective: false, tags: [], kinds: [
{ id: "JsxClosingElement", tags: [] },
]},
}},
JsxSelfClosingElement: { tags: [], fields: {
tagName: { optional: false, collective: false, tags: [], kinds: [
{ id: "PrimaryExpression", tags: [] },
{ id: "PropertyAccessExpression", tags: [] },
]},
attributes: { optional: false, collective: false, tags: [], kinds: [
{ id: "JsxAttributes", tags: [] },
]},
}},
JsxOpeningElement: { tags: [], fields: {
tagName: { optional: false, collective: false, tags: [], kinds: [
{ id: "PrimaryExpression", tags: [] },
{ id: "PropertyAccessExpression", tags: [] },
]},
attributes: { optional: false, collective: false, tags: [], kinds: [
{ id: "JsxAttributes", tags: [] },
]},
}},
JsxAttributes: { tags: [], fields: {
properties: { optional: false, collective: true, tags: [], kinds: [
{ id: "JsxAttribute", tags: [] },
{ id: "JsxSpreadAttribute", tags: [] },
]},
}},
JsxAttribute: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
initializer: { optional: true, collective: false, tags: [], kinds: [
{ id: "StringLiteral", tags: [] },
{ id: "JsxExpression", tags: [] },
]},
}},
JsxSpreadAttribute: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
JsxExpression: { tags: [], fields: {
expression: { optional: true, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
JsxClosingElement: { tags: [], fields: {
tagName: { optional: false, collective: false, tags: [], kinds: [
{ id: "PrimaryExpression", tags: [] },
{ id: "PropertyAccessExpression", tags: [] },
]},
}},
JSDocTypeExpression: { tags: [], fields: {
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocUnionType: { tags: [], fields: {
types: { optional: false, collective: true, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocTupleType: { tags: [], fields: {
types: { optional: false, collective: true, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocArrayType: { tags: [], fields: {
elementType: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocNonNullableType: { tags: [], fields: {
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocNullableType: { tags: [], fields: {
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocRecordType: { tags: [], fields: {
literal: { optional: false, collective: false, tags: [], kinds: [
{ id: "TypeLiteral", tags: [] },
]},
}},
JSDocTypeReference: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "QualifiedName", tags: [] },
]},
typeArguments: { optional: false, collective: true, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocOptionalType: { tags: [], fields: {
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocFunctionType: { tags: [], fields: {
parameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "Parameter", tags: [] },
]},
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocVariadicType: { tags: [], fields: {
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocConstructorType: { tags: [], fields: {
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocThisType: { tags: [], fields: {
type: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocRecordMember: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
{ id: "StringLiteral", tags: [] },
{ id: "NumericLiteral", tags: [] },
]},
type: { optional: true, collective: false, tags: [], kinds: [
{ id: "JSDocType", tags: [] },
]},
}},
JSDocComment: { tags: [], fields: {
tags: { optional: false, collective: true, tags: [], kinds: [
{ id: "JSDocTag", tags: [] },
{ id: "undefined", tags: [] },
]},
}},
JSDocParameterTag: { tags: [], fields: {
preParameterName: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
typeExpression: { optional: true, collective: false, tags: [], kinds: [
{ id: "JSDocTypeExpression", tags: [] },
]},
postParameterName: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
}},
JSDocReturnTag: { tags: [], fields: {
typeExpression: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocTypeExpression", tags: [] },
]},
}},
JSDocTypeTag: { tags: [], fields: {
typeExpression: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocTypeExpression", tags: [] },
]},
}},
JSDocAugmentsTag: { tags: [], fields: {
typeExpression: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocTypeExpression", tags: [] },
]},
}},
JSDocTemplateTag: { tags: [], fields: {
typeParameters: { optional: false, collective: true, tags: [], kinds: [
{ id: "TypeParameter", tags: [] },
]},
}},
JSDocTypedefTag: { tags: [], fields: {
name: { optional: true, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
fullName: { optional: true, collective: false, tags: [], kinds: [
{ id: "JSDocNamespaceDeclaration", tags: [] },
{ id: "Identifier", tags: [] },
]},
typeExpression: { optional: true, collective: false, tags: [], kinds: [
{ id: "JSDocTypeExpression", tags: [] },
]},
jsDocTypeLiteral: { optional: true, collective: false, tags: [], kinds: [
{ id: "JSDocTypeLiteral", tags: [] },
]},
}},
JSDocTypeLiteral: { tags: [], fields: {
jsDocPropertyTags: { optional: true, collective: true, tags: [], kinds: [
{ id: "JSDocPropertyTag", tags: [] },
]},
}},
JSDocPropertyTag: { tags: [], fields: {
name: { optional: false, collective: false, tags: [], kinds: [
{ id: "Identifier", tags: [] },
]},
typeExpression: { optional: false, collective: false, tags: [], kinds: [
{ id: "JSDocTypeExpression", tags: [] },
]},
}},
PartiallyEmittedExpression: { tags: [], fields: {
expression: { optional: false, collective: false, tags: [], kinds: [
{ id: "Expression", tags: [] },
]},
}},
JSDocLiteralType: { tags: [], fields: {
literal: { optional: false, collective: false, tags: [], kinds: [
{ id: "LiteralType", tags: [] },
]},
}},
},
untraversed: [
"MissingDeclaration",
"JSDocTypeExpression",
"JSDocUnionType",
"JSDocTupleType",
"JSDocArrayType",
"JSDocNonNullableType",
"JSDocNullableType",
"JSDocRecordType",
"JSDocTypeReference",
"JSDocOptionalType",
"JSDocFunctionType",
"JSDocVariadicType",
"JSDocConstructorType",
"JSDocThisType",
"JSDocRecordMember",
"JSDocComment",
"JSDocParameterTag",
"JSDocReturnTag",
"JSDocTypeTag",
"JSDocAugmentsTag",
"JSDocTemplateTag",
"JSDocTypedefTag",
"JSDocTypeLiteral",
"JSDocPropertyTag",
"JSDocLiteralType",
],
// ***/
/**
// https://www.gitbook.com/book/element-dong/typescript-spec/details
sample : {
QualifiedName: "q<z.z>",
TypeParameter: "Array<z extends k = never>",
ShorthandPropertyAssignment: "void { z } || { z = 123 }",
SpreadAssignment: "let q = { ...z }",
Parameter: "(@j readonly ...z?) => 123",
PropertyDeclaration: "class q { @j readonly z?: 123 }",
PropertySignature: "interface q { readonly [z]?: never }",
PropertyAssignment: "void { z: 123 }",
VariableDeclaration: "let z : k = 123",
BindingElement: "[ ({ ...z: z }) => 123, ({ z = 123 }) => 123 ]",
FunctionType: "interface q { j: <k>(z: k) => k }",
ConstructorType: "interface q { j: new <k>(z: k) => k }",
CallSignature: "interface q { <k>(z: k) => k }",
ConstructSignature: "interface q { new <k>(z: k) => k }",
IndexSignature: "interface q { readonly [z : any]: never }",
MethodDeclaration: "class q { @j public * z <k>() : k | void {} }",
MethodSignature: "interface q { z? <k>() => k }",
Constructor: "class q { @j public constructor (z) {} }",
GetAccessor: "class q { @j readonly get z : k | void () {} }",
SetAccessor: "class q { @j readonly set z (x) {} }",
FunctionExpression: "(async function * <k>(z) : k | void {})",
FunctionDeclaration: "@j export function * q <k>(z) : k | void {}",
ArrowFunction: "(async <k>(z) : k | void => z)",
TypeReference: "z<k>",
TypePredicate: "interface q { j: <k>() => z is k | this is k }",
TypeQuery: "q<typeof z.z>",
TypeLiteral: "q<{ z?: k }>",
ArrayType: "z<k>[]",
TupleType: "[z<k>, k]",
UnionType: "q<z | k>",
IntersectionType: "q<z & k>",
ParenthesizedType: "q<(z)>",
TypeOperator: "q<keyof z>",
IndexedAccessType: "q<z[k]>",
MappedType: "q<{ [z in \'field\' | \'name\']: k }>",
LiteralType: "q<\'z\'>",
ObjectBindingPattern: "let {q: z} = {}",
ArrayBindingPattern: "let [,z,] = []",
ArrayLiteralExpression: "void [z]",
ObjectLiteralExpression: "void { z: q }",
PropertyAccessExpression: "void z.z",
ElementAccessExpression: "void z[q]",
CallExpression: "void z<k>(q)",
NewExpression: "void new z<k>(q)",
TaggedTemplateExpression: "z\`\` || z\`\${q}\`",
TypeAssertionExpression: "void <z>q",
ParenthesizedExpression: "void (z)",
DeleteExpression: "delete z.z",
TypeOfExpression: "void typeof z",
VoidExpression: "void z",
PrefixUnaryExpression: "!z",
YieldExpression: "function * () { yield z || yield * z(); }",
AwaitExpression: "async function () { await z; }",
PostfixUnaryExpression: "z++",
BinaryExpression: "z === z",
AsExpression: "z as q<k>",
NonNullExpression: "z!",
MetaProperty: "new.target", // developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target
ConditionalExpression: "z ? z : z",
SpreadElement: "void [q, ...z]",
Block: "q: { z; z; z; }",
ModuleBlock: "namespace q { z; z; z; }",
SourceFile: "",
VariableStatement: "export const z = j, q = z",
VariableDeclarationList: "let z = j, q = z",
ExpressionStatement: "q: z;",
IfStatement: "if (z) z; else z;",
DoStatement: "do z while(q)",
WhileStatement: "while (z) q",
ForStatement: "for (z; z < z; z++) z",
ForInStatement: "for (z in q) z",
ForOfStatement: "for (z of q) z",
ContinueStatement: "continue z",
BreakStatement: "break z",
ReturnStatement: "return z",
WithStatement: "with (z) q",
SwitchStatement: "switch (z) {}",
CaseBlock: "switch (q) { let z }",
CaseClause: "switch (q) { case z: z }",
DefaultClause: "switch (q) { default: z }",
LabeledStatement: "z: let q",
ThrowStatement: "throw z",
TryStatement: "try { z } catch (q) { z } finally { z }",
CatchClause: "try { q } catch (z) { z }",
Decorator: "@z",
ClassDeclaration: "@q export class z<k> extends j { x }",
ClassExpression: "void abstract class z<k> extends j implements q { x }",
InterfaceDeclaration: "@q export interface z<k> implements j { x: k }",
TypeAliasDeclaration: "@q export type z<k> = j",
EnumDeclaration: "@q const enum z { z }",
EnumMember: "enum q { z = 1 }",
ModuleDeclaration: "@q export namespace z {}",
ImportEqualsDeclaration: "@q export import z = require(q)",
ImportDeclaration: "@q export import z, {k} from j",
ImportClause: "import z, {k as q} from j",
NamespaceExportDeclaration: "export as namespace z",
NamespaceImport: "import * as z from j",
NamedImports: "import { z } from j",
NamedExports: "export { z }",
ExportDeclaration: "@q declare export {}",
ImportSpecifier: "import { z as z } from j",
ExportSpecifier: "export { z as z }",
ExportAssignment: "@q declare export = z",
TemplateExpression: "\`z \${z} z \${z} z\`",
TemplateSpan: "\`q \${z} z \${q} q\` || \`q \${q} q \${z} z\`",
ComputedPropertyName: "void {[z]: j}",
HeritageClause: "void class q extends z {} || class q implements z {}",
ExpressionWithTypeArguments: "class q extends z<k> {}",
ExternalModuleReference: "import q = require(z)",
MissingDeclaration: "@q void j",
PartiallyEmittedExpression: null, // transform-only?
CommaListExpression: null, // unused?
JsxElement: "<z> z </z>",
JsxSelfClosingElement: "<z.z z=\'z\' zz=\'zz\'/>",
JsxOpeningElement: "<z.z z=\'z\' zz=\'zz\'>",
JsxAttributes: "<q z=\'z\' zz=\'zz\'/>",
JsxAttribute: "<q z=\'z\'/>",
JsxSpreadAttribute: "<q {...z}/>",
JsxExpression: "<q> {z} {...z} </q>",
JsxClosingElement: "</z.z>",
// Microsoft/TypeScript/wiki/JSDoc-support-in-JavaScript/a0af86db3b57bb1cddd136be08f9789f9a4e22ce
JSDocTypeExpression: "/** @type { z } *\/ var q",
JSDocUnionType: "/** @type {( z | k )} *\/ var q",
JSDocTupleType: "/** @type {[ z, z ]} *\/ var q",
JSDocArrayType: "/** @type { z[] } *\/ var q",
JSDocNonNullableType: "/** @type { !z } *\/ var q",
JSDocNullableType: "/** @type { ?z } *\/ var q",
JSDocRecordType: "/** @type {{ z, zz }} *\/ var q",
JSDocTypeReference: "/** @type { z<k> } *\/ var q",
JSDocOptionalType: "/** @type { z= } *\/ var q",
JSDocFunctionType: "/** @type { function (z): z } *\/ var q",
JSDocVariadicType: "/** @type { ...z } *\/ var q",
JSDocConstructorType: "/** @type { new:z } *\/ var q",
JSDocThisType: "/** @type { this:z } *\/ var q",
JSDocRecordMember: "/** @type {{ z: j }} *\/ var q",
JSDocComment: "/** *\/ var q",
JSDocParameterTag: "/** @param { k } z *\/ function q (z) {}",
JSDocReturnTag: "/** @return { k } *\/ function q () {}",
JSDocTypeTag: "/** @type { k } *\/ var q",
JSDocAugmentsTag: "/** @augments { z } *\/ class q extends z {}",
JSDocTemplateTag: "/** @template z @param { z } j *\/ function q (j) {}",
JSDocTypedefTag: "/** @typedef {{ j: k }} z.z *\/ var q",
JSDocTypeLiteral: "/** @typedef z * @prop { k } j * @property { k } x *\/ var q",
JSDocPropertyTag: "/** @typedef q * @prop { k } z * @property { k } zz *\/ var q",
JSDocLiteralType: "/** @type { 'z' } *\/ var q",
},
**/
/****
// Microsoft/TypeScript/blob/d5993bafeab5120f88f40db7d12da9c2dcb50538/src/compiler/visitor.ts#L221-L894
// Microsoft/TypeScript/blob/5fb77a09011facdac31bd9cf5fb84f734026adac/src/compiler/parser.ts#L62-L448
// Microsoft/TypeScript/blob/f6fbe617188ac28648aef55a20e18345e6a8986f/src/compiler/types.ts#L1-L4342
_codegen: function _codegen (ts, visitorSwitchStatementCode, schemeSwitchStatementCode, typesTsCode) {
function eachSetKVP (value, key) {
if (!key) throw new Error("codegen needs review -- unexpected key-value pair");
this.set(key, value);
}
function like (kind, root) {
var node = arguments.length > 2 ? seek.call.apply(seek, arguments) : unfortunate(root);
return 0|(node ? node.kind === kind || node.kind === ts.SyntaxKind[kind] : false);
}
function seek (root) {
var node = unfortunate(root);
var count = arguments.length;
var index = 1;
for (index; node && index < count; index++) {
node = node ? node[arguments[index]] || null : null;
node = node ? unfortunate(node) || null : null;
}
return node;
}
function unfortunate (node) {
if (node.kind === ts.SyntaxKind.ParenthesizedExpression) {
return unfortunate(node.expression);
} else if (node.kind === ts.SyntaxKind.ParenthesizedType) {
return unfortunate(node.type);
} else {
return node;
}
}
function asBuiltinTypeKeyword (kind) {
switch (kind || "") {
default: return "";
case "AnyKeyword": return "any";
case "NumberKeyword": return "number";
case "ObjectKeyword": return "object";
case "BooleanKeyword": return "boolean";
case "StringKeyword": return "string";
case "SymbolKeyword": return "symbol";
case "ThisKeyword": return "this";
case "VoidKeyword": return "void";
case "UndefinedKeyword": return "undefined";
case "NullKeyword": return "null";
case "NeverKeyword": return "never";
}
}
var _extensionsOfName = new Map();
var _aliasesForName = new Map();
var _visitorByKind = new Map();
var _schemeByKind = new Map();
var _defGroupByName = new Map();
var _defGroupByKind = new Map();
function getExtendersOfName (name) {
return _extensionsOfName.get(name || "") || null;
}
function getAliasesOfName (name) {
return _aliasesForName.get(name || "") || null;
}
function getVisitorWithKind (kind) {
return _visitorByKind.get(kind || "") || null;
}
function getSchemeWithKind (kind) {
return _schemeByKind.get(kind || "") || null;
}
function getDefGroupWithName (name) {
return _defGroupByName.get(name || "") || null;
}
function getDefGroupWithKind (kind) {
return _defGroupByKind.get(kind || "") || null;
}
function TypeGroup ({ name, tparams, group }) {
this.name = name || ""; // ""
this.tparams = tparams || []; // ""[]
this.group = group || []; // TypeUse[]
if (!name || !group) throw new Error("codegen needs review");
}
TypeGroup.fromStatement = function (statement) {
var name = like("Identifier", statement, "name") ? seek(statement, "name").text || "" : "";
var params = (seek(statement, "typeParameters") || []).map(function (node) {
if (like("Identifier", node, "name")) return seek(node, "name").text;
else throw new Error("codegen needs review");
});
var group = like("UnionType", statement, "type") ?
seek(statement, "type", "types") || null : like("TypeReference", statement, "type") ?
[seek(statement, "type")] : [];
return TypeGroup.fromNameParamsAndGroup(name, params, group);
};
TypeGroup.fromNameParamsAndGroup = function (name, params, group) {
var list = group.map(function (node) {
if (asBuiltinTypeKeyword(ts.SyntaxKind[node.kind])) return TypeUse.fromBuiltinTypeKeyword(node);
else if (like("TypeReference", node)) return TypeUse.fromTypeReference(node);
else if (like("ArrayType", node)) return TypeUse.fromArrayType(node);
else throw new Error("codegen needs review");
});
return new TypeGroup({
name: name || list.map(function (usage) {
return usage.id;
}).join("|"),
tparams: params || [],
group: list,
});
};
function TypeDef ({ name, tparams, supers, someSignatures }) {
if (!name) throw new Error("codegen needs review");
this.name = name || ""; // ""
this.tparams = tparams || []; // ""[]
this.supers = supers || []; // TypeUse[]
this.someSignatures = someSignatures || new Map(); // ["" :: TypedProperty]
this.allSignatures = new Map(); // ["" :: TypedProperty]
this.kind = ""; // ""
if (someSignatures &&
someSignatures.has("kind") &&
someSignatures.get("kind").someTypes.size) {
this.kind = someSignatures.get("kind").someTypes.keys().next().value;
switch (name) {
case "JsxAttributes":
throw new Error("codegen needs review");
}
} else switch (name) {
case "JsxAttributes":
this.kind = name;
}
}
TypeDef.fromStatement = function (statement) {
var name = like("Identifier", statement, "name") ? seek(statement, "name").text || "" : "";
var params = (seek(statement, "typeParameters") || []).map(function (node) { // ""[]
if (like("Identifier", node, "name")) return seek(node, "name").text;
else throw new Error("codegen needs review");
});
var clauses = seek(statement, "heritageClauses") || [];
var heritage = clauses.reduce(function (reduction, node) {
return node.token === ts.SyntaxKind.ExtendsKeyword ? reduction || node : reduction;
}, null);
var supers = heritage ? seek(heritage, "types") || [] : [];
var members = seek(statement, "members") || [];
return new TypeDef({
name: name,
tparams: params,
supers: supers.map(function (node) { // TypeUse[]
if (like("ExpressionWithTypeArguments", node)) return TypeUse.fromTypeExpression(node);
else throw new Error("codegen needs review");
}),
someSignatures: members.reduce(function (reduction, node) { // ["" :: TypedProperty]
if (like("PropertySignature", node)) {
reduction.set(seek(node, "name").text || "", TypedProperty.fromPropertySignature(seek(node)));
}
return reduction;
}, new Map()),
});
};
function TypeUse ({ id, namespace, targs }) {
this.id = id || ""; // ""
this.namespace = namespace || []; // ""[]
this.targs = targs || []; // TypeUse[]
this.specifics = null; // TypeUse[]?
this.someMembers = null; // ["" :: TypedProperty]?
this.allMembers = null; // ["" :: TypedProperty]?
}
TypeUse.prototype.specify = function (aliases) {
return new TypeUse({
id: aliases.get(this.id) || this.id,
namespace: this.namespace.slice(),
targs: this.targs.map(function (usage) {
return usage.specify(this);
}, aliases),
});
};
TypeUse.prototype.resolveInitial = function (scheme) {
var model = getDefGroupWithName(this.id) || null;
var aliases = new Map(!model.tparams ? [] : model.tparams.map(function (param, index) {
return [param, this[index].id];
}, this.targs));
this.specifics = (model.supers || model.group || []).map(function (usage) {
return usage.specify(this);
}, aliases);
this.specifics.forEach(function (usage) {
usage.resolveInitial(this);
}, scheme);
if (model.supers) [...model.someSignatures.values()].filter(function (prop) {
var count = this.length;
var index = 0;
for (index; index < count; index++) {
if (prop.field === this[index].field) return 0|true;
}
return 0|false;
}, scheme).map(function (prop) {
return prop.specify(this);
}, aliases).forEach(function (prop) {
this.set(prop.field, prop);
}, this.someMembers = new Map());
return this;
};
TypeUse.prototype.resolveFinal = function () {
var model = getDefGroupWithName(this.id) || null;
if (model.supers) {
this.allMembers = new Map();
this.specifics.forEach(function fn (usage) {
usage.specifics.forEach(fn, this);
usage.someMembers.forEach(eachSetKVP, this);
}, this.allMembers);
this.someMembers.forEach(eachSetKVP, this.allMembers);
}
return this;
};
TypeUse.fromTypeExpression = function (typeExpression) {
// why does ExpressionWithTypeArguments exist? (is TypeReference not sufficient -- and preferable?)
var args = seek(typeExpression, "typeArguments") || [];
var name = seek(typeExpression, "expression");
var space = [];
while (like("PropertyAccessExpression", name)) {
if (like("Identifier", name, "name")) space.push(seek(name, "name").text);
else throw new Error("codegen needs review");
name = seek(name, "expression");
}
if (like("Identifier", name)) space.push(seek(name).text);
else throw new Error("codegen needs review");
space = space.reverse();
return TypeUse.fromPathAndTypeArguments(space, args);
};
TypeUse.fromTypeReference = function (typeReference) {
var args = seek(typeReference, "typeArguments") || [];
var name = seek(typeReference, "typeName");
var space = [];
while (like("QualifiedName", name)) {
if (like("Identifier", name, "right")) space.push(seek(name, "right").text);
else throw new Error("codegen needs review");
name = seek(name, "left");
}
if (like("Identifier", name)) space.push(seek(name).text);
else throw new Error("codegen needs review");
space = space.reverse();
return TypeUse.fromPathAndTypeArguments(space, args);
};
TypeUse.fromPathAndTypeArguments = function (path, typeArguments) {
var id = path && path.length ? path[path.length - 1] || "" : "";
return new TypeUse({
id: id,
namespace: path ? path.slice(0, -1) : [],
targs: typeArguments.map(function (node) { // TypeUse[]
if (asBuiltinTypeKeyword(ts.SyntaxKind[node.kind])) return TypeUse.fromBuiltinTypeKeyword(node);
else if (like("TypeReference", node)) return TypeUse.fromTypeReference(node);
else if (like("ArrayType", node)) return TypeUse.fromArrayType(node);
else if (like("UnionType", node)) return TypeUse.fromUnionType(node);
else throw new Error("codegen needs review");
}),
});
};
TypeUse.fromBuiltinTypeKeyword = function (node) {
var id = asBuiltinTypeKeyword(ts.SyntaxKind[node.kind]) || "";
if (id) return new TypeUse({ id: id });
else throw new Error("codegen needs review");
};
TypeUse.fromArrayType = function (arrayType) {
return TypeUse.fromPathAndTypeArguments(["Array"], [seek(arrayType, "elementType")]);
};
TypeUse.fromUnionType = function (unionType) {
var group = TypeGroup.fromNameParamsAndGroup("", [], seek(unionType, "types"));
var id = group.name;
return TypeUse.fromPathAndTypeArguments([id], []);
};
TypeUse.fromLiteralType = function (literalType) {
if (like("StringLiteral", literalType, "literal")) {
return new TypeUse({ id: seek(literalType, "literal").text, namespace: ["string"]});
} else if (like("NumberLiteral", literalType, "literal")) {
return new TypeUse({ id: seek(literalType, "literal").text, namespace: ["number"]});
}
};
function TypedProperty ({ field, someTypes, optional }) {
this.field = field || "";
this.optional = optional || (0|false);
this.someTypes = someTypes || new Map(); // ["" :: TypeUse]
this.allTypes = null; // ["" :: TypeUse]?
}
TypedProperty.prototype.specify = function (aliases) {
var someTypes = new Map();
[...this.someTypes.values()].map(function (usage) {
return usage.specify(this);
}, aliases).forEach(function (usage) {
this.set(usage.id, usage);
}, someTypes);
return new TypedProperty({
field: this.field,
optional: this.optional,
someTypes: someTypes,
}).resolve();
};
TypedProperty.prototype.resolve = function () {
this.someTypes.forEach(function fn (usage) {
var model = getDefGroupWithName(usage.id) || null;
if (model && model.group) model.group.forEach(fn, this);
else this.set(usage.id, usage);
}, this.allTypes = new Map());
return this;
};
TypedProperty.fromPropertySignature = function (propertySignature) {
var field = like("Identifier", propertySignature, "name") ?
seek(propertySignature, "name").text || "" : "";
var parts = like("UnionType", propertySignature, "type") ?
seek(propertySignature, "type", "types") || null : like("TypeReference", propertySignature, "type") ?
[seek(propertySignature, "type")] : []; // null (ArrayType)
return new TypedProperty({
field: field,
optional: 0|!!seek(propertySignature).questionToken,
someTypes: parts.reduce(function (reduction, node) { // ["" :: TypeUse]
var usage;
if (asBuiltinTypeKeyword(ts.SyntaxKind[node.kind])) usage = TypeUse.fromBuiltinTypeKeyword(node);
else if (like("TypeReference", node)) usage = TypeUse.fromTypeReference(node);
else if (like("ArrayType", node)) usage = TypeUse.fromArrayType(node);
else if (like("LiteralType", node)) usage = TypeUse.fromLiteralType(node);
else throw new Error("codegen needs review");
return reduction.set(usage.id, usage);
}, new Map()),
});
};
function matchDefaultClause (clause) {
return 0|(like("DefaultClause", clause));
}
function matchClauseExpression (clause) {
if (like("DefaultClause", clause)) return "";
else if (!like("CaseClause", clause)) return "";
else if (!like("PropertyAccessExpression", clause, "expression")) return "";
else if (!like("Identifier", clause, "expression", "expression")) return "";
else if ("SyntaxKind" !== seek(clause, "expression", "expression").text) return "";
else if (!like("Identifier", clause, "expression", "name")) return "";
else return seek(clause, "expression", "name").text;
}
function matchClauseStatementScheme (statement) {
var value;
if (!like("ReturnStatement", statement)) return null;
else if (like("CallExpression", statement, "expression")) {
value = readSchemeCallTuple(seek(statement, "expression")) || null;
if (value) return [value];
else return null;
} else if (!like("BinaryExpression", statement, "expression")) return null;
else return matchBinaryCallExpressions(seek(statement, "expression"), []) || null;
}
function matchBinaryCallExpressions (binaryExpression, result) {
var left = seek(binaryExpression, "left");
var right = seek(binaryExpression, "right");
var value;
if (like("BinaryExpression", left)) matchBinaryCallExpressions(left, result);
else if (value = readSchemeCallTuple(left)) result.push(value);
else throw new Error("codegen needs review"); // return null;
if (value = readSchemeCallTuple(right)) return result.push(value) ? result : result;
else throw new Error("codegen needs review"); // return null;
}
function readSchemeCallTuple (expression) {
var node = seek(expression);
if (!like("CallExpression", node)) return null;
else if (!like("Identifier", node, "expression")) return null;
else if (node.arguments.length < 2) return null;
else return readSchemeTuple(node.arguments[1], seek(node, "expression").text);
}
function readSchemeTuple (expression, visitor) {
var node = seek(expression);
var collective = 0|false;
switch (visitor) {
default: throw new Error("unhandled visitor label: "+visitor);
case "visitNodes":
collective = 0|true;
case "visitNode":
}
if (!like("PropertyAccessExpression", node)) return null;
else if (!checkMethodArgument(seek(node, "expression"))) return null;
else if (!like("Identifier", node, "name")) return null;
else return {
visitor: visitor,
field: seek(node, "name").text,
collective: collective,
};
}
function checkMethodArgument (arg) {
if (like("Identifier", arg) && "node" === seek(arg).text) return 0|true;
else if (!like("TypeAssertionExpression", arg) && !like("AsExpression", arg)) return 0|false;
else if (!like("Identifier", arg, "expression")) return 0|false;
else if ("node" !== seek(arg, "expression").text) return 0|false;
else return 0|true;
}
function permitUpdateClauseSatement (statement) {
if (!like("ReturnStatement", statement)) return 0|false;
else if (!like("Identifier", statement, "expression")) return 0|false;
else if ("node" !== seek(statement, "expression").text) return 0|false;
else return 0|true;
}
function matchUpdateClauseStatement (statement) {
if (!like("ReturnStatement", statement)) return null;
else if (!like("CallExpression", statement, "expression")) return null;
else if (!like("Identifier", statement, "expression", "expression")) return null;
else if (2 > seek(statement, "expression").arguments.length) return null;
else if (!checkUpdateOriginal(seek(statement, "expression").arguments[0])) return null;
else return readUpdateDefinition(seek(statement, "expression")) || null;
}
function checkUpdateOriginal (arg) {
if (!like("TypeAssertionExpression", arg)) return 0|false;
else if (!like("Identifier", arg, "expression")) return 0|false;
else if ("node" !== seek(arg, "expression").text) return 0|false;
else return 0|true;
}
function readUpdateDefinition (callExpression) {
var node = seek(callExpression);
var updater = seek(node, "expression").text;
var args = node.arguments.slice(1);
var tuples = args.reduce(readUpdateArgTupleReducer, []);
return (tuples.length < args.length) ?
null : {
updater: updater,
tuples: tuples,
};
}
function readUpdateArgTupleReducer (reduction, arg) {
var tuple = readUpdateCallTuple(arg) || readUpdateTuple(arg, "") || null;
if (tuple) reduction.push(tuple);
return reduction;
}
function readUpdateCallTuple (expression) {
var node = seek(expression);
if (!like("CallExpression", node)) return null;
else if (!like("Identifier", node, "expression")) return null;
else if (node.arguments.length < 1) return null;
else return readUpdateTuple(node.arguments[0], seek(node, "expression").text);
}
function readUpdateTuple (expression, visitor) {
var node = seek(expression);
var collective = 0|false;
switch (visitor) {
default: throw new Error("unhandled visitor label: "+visitor);
case "visitLexicalEnvironment":
case "visitParameterList":
case "nodesVisitor":
collective = 0|true;
break
case "":
case "visitFunctionBody":
case "visitNode":
collective = 0|false;
break
}
if (!like("PropertyAccessExpression", node)) return null;
else if (!checkUpdateOriginal(seek(node, "expression"))) return null;
else if (!like("Identifier", node, "name")) return null;
else return {
visitor: visitor,
field: seek(node, "name").text,
collective: collective,
};
}
var _usages = [];
var _emissions = [];
var ALIAS_THRESHHOLD = 5;
var typesSourceFile = ts.createSourceFile(""
, typesTsCode, ts.ScriptTarget.ES5, false, ts.ScriptKind.TS);
var typesModuleBlockNode = typesSourceFile.statements[0].body;
var schemeSwitchSourceFile = ts.createSourceFile(""
, schemeSwitchStatementCode, ts.ScriptTarget.ES5, false, ts.ScriptKind.TS);
var schemeSwitchStatementNode = schemeSwitchSourceFile.statements[0];
var visitorSwitchSourceFile = ts.createSourceFile(""
, visitorSwitchStatementCode, ts.ScriptTarget.ES5, false, ts.ScriptKind.TS);
var visitorSwitchStatementNode = visitorSwitchSourceFile.statements[0];
var clauseKinds = [];
visitorSwitchStatementNode.caseBlock.clauses.reduce(function (reduction, clause) {
var visitor;
var kinds = clauseKinds;
var count = 0;
var index = 0;
var name = matchClauseExpression(clause) || "";
if (name) count = clauseKinds.push(name);
else if (matchDefaultClause(clause)) clauseKinds.push("$");
else throw new Error("codegen needs review");
if (clause.statements.length === 1) {
clauseKinds = [];
visitor = matchUpdateClauseStatement(clause.statements[0]) || null;
if (visitor) for (index; index < count; index++) reduction.set(kinds[index], visitor);
else if (!permitUpdateClauseSatement(clause.statements[0])) throw new Error("codegen needs review");
} else if (clause.statements.length > 1) {
throw new Error("codegen needs review");
}
return reduction;
}, _visitorByKind);
clauseKinds = [];
schemeSwitchStatementNode.caseBlock.clauses.reduce(function (reduction, clause) {
var scheme;
var kinds = clauseKinds;
var count = 0;
var index = 0;
var name = matchClauseExpression(clause) || "";
if (name) count = clauseKinds.push(name);
else throw new Error("codegen needs review");
if (clause.statements.length === 1) {
clauseKinds = [];
scheme = matchClauseStatementScheme(clause.statements[0]) || null;
if (scheme) for (index; index < count; index++) reduction.set(kinds[index], scheme);
else throw new Error("codegen needs review");
} else if (clause.statements.length > 1) {
throw new Error("codegen needs review");
}
return reduction;
}, _schemeByKind);
typesModuleBlockNode.statements.map(function (statement) {
if (like("InterfaceDeclaration", statement)) return TypeDef.fromStatement(statement);
else if (like("TypeAliasDeclaration", statement)) return TypeGroup.fromStatement(statement);
else return null;
}).map(function (model) {
var key = model ? model.name : "";
if (this.has(key)) throw new Error("codegen needs review");
else if (key) this.set(key, model);
return model;
}, _defGroupByName);
_defGroupByName.forEach(function (model, name) {
if (model.kind) this.set(model.kind, model);
}, _defGroupByKind);
_defGroupByName.forEach(function (model, name, collection) {
var kinds = model.kind ?
[model.kind] : !model.group ?
[] : model.group.map(function fn (usage) {
var data = this.get(usage.id) || null;
if (usage.namespace &&
usage.namespace.length === 1 &&
usage.namespace[0] === "SyntaxKind") {
return usage.id;
} else if (!data) return [];
else if (data.group) return data.group.map(fn, this);
else if (!data.tparams || data.tparams.indexOf(data.kind || "") < 0) return data.kind || [];
else return fn.call(this, usage.targs[data.tparams.indexOf(data.kind || "")]);
}, collection);
this.set(model.name, kinds);
}, _extensionsOfName);
_extensionsOfName.forEach(function (kinds, name, collection) {
var data = this.get(name);
var list = data.supers || null;
var count = list ? list.length : 0;
var index = 0;
var value = data;
if (data.tparams.length) switch(name) {
default: throw new Error("codegen needs review");
case "Token":
case "MapLike":
case "Map":
case "Iterator":
case "FileMap":
case "NodeArray":
case "AssignmentExpression":
case "ObjectLiteralExpressionBase":
case "TransformationResult":
case "TransformerFactory":
case "Transformer":
case "VisitResult":
} else for (index; index < count; index++) {
value = this.get(list[index].id) || data;
if (value !== data) {
if (collection.has(value.name)) collection.get(value.name).push(kinds);
else collection.set(value.name, [kinds]);
}
}
}, _defGroupByName);
_schemeByKind.forEach(function (scheme, kind) {
var model = getDefGroupWithKind(kind) || null;
if (!model || !scheme) throw new Error("codegen needs review");
else if (model.tparams && model.tparams.length) throw new Error("codegen needs review");
else this.push(new TypeUse({ id: model.name }).resolveInitial(scheme).resolveFinal());
}, _usages);
_usages.forEach(function (usage) {
usage.allMembers.forEach(function (prop) {
prop.allTypes.forEach(function routine (value) {
var data = getDefGroupWithName(value.id) || null;
var param = data && data.tparams ? data.tparams.indexOf(data.kind || "") : -1;
var instance = !value.targs || !value.targs.length ?
value : param < 0 ?
value.targs[0] : value.targs[param];
var kinds = (getExtendersOfName(instance.id) || []).reduce(function fn (reduction, part) {
if (Array.isArray(part)) return part.reduce(fn, reduction);
else return reduction.push(part) ? reduction : reduction;
}, []);
this.set(instance.id, kinds);
}, this);
}, this);
}, _aliasesForName);
_emissions.push("\n{", "\tast: {");
_visitorByKind.forEach(function (visitor, kind) {
var tuples = visitor.tuples;
var limit = tuples.length;
var at = 0;
var text = "";
var field = "";
var params = [];
var args = [];
for (at = 0; at < limit; at++) params.push("_"+tuples[at].field);
for (at = 0; at < limit; at += 5) args.push(params.slice(at, at + 5).join(", "));
this.push("\t\t"+kind+": {");
this.push("\t\t\tvisit: function (vehicle, node, lib = ts) {");
for (at = 0; at < limit; at++) {
field = tuples[at].field;
if (tuples[at].collective) {
this.push("\t\t\t\tvar _"+field+" = tv.tour(vehicle");
text = "\t\t\t\t\t, node."+field+", node, \""+field+"\", lib) || void 0;";
this.push(text);
} else {
this.push("\t\t\t\tvar _"+field+" = tv.stay(vehicle");
text = "\t\t\t\t\t, node."+field+", node, \""+field+"\", lib);";
this.push(text);
}
}
this.push("");
this.push("\t\t\treturn node; // update not guaranteed to exist...");
this.push("//\t\t\treturn lib."+visitor.updater+"(node");
at = 0;
do {
text = "//\t\t\t\t\t, "+args[at];
} while (++at < args.length && (this.push(text) || true))
this.push("//"+text+");");
this.push("\t\t\t},");
this.push("\t\t},");
}, _emissions);
_emissions.push("\t},", "/***", "\tdefs: {");
_aliasesForName.forEach(function (kinds, id) {
var count = kinds.length;
var index = 0;
if (count > ALIAS_THRESHHOLD) {
this.push("\t\t"+id+": [");
for (index; index < count; index++) this.push("\t\t\t\""+kinds[index]+"\",");
this.push("\t\t],");
}
}, _emissions);
_emissions.push("\t},", "\tschema: {");
_usages.forEach(function (usage) {
var model = getDefGroupWithName(usage.id);
if (model && model.kind) {
this.push("\t\t"+model.kind+": { tags: [], fields: {");
if (model.tparams && model.tparams.length) throw new Error("codegen needs review");
[...usage.allMembers.values()].filter(function (prop) {
var visitor = getVisitorWithKind(this.kind) || null;
return !visitor || !visitor.tuples.every(function (tuple) {
return tuple.field !== this.field;
}, prop);
}, model).forEach(function (prop) {
var list = [...prop.allTypes.values()];
var collective = list.reduce(function fn (reduction, value) {
var data = getDefGroupWithName(value.id) || null;
return reduction ?
true : value.id === "Array" ?
true : value.id === "NodeArray" ?
true : !data ?
false : data.group ?
data.group.reduce(fn, false) : data.supers ?
data.supers.reduce(fn, false) : false;
}, false);
var text = "optional: "+!!prop.optional+", collective: "+!!collective+", ";
this.push("\t\t\t"+prop.field+": { "+text+"tags: [], kinds: [");
list.forEach(function routine (value) {
var data = getDefGroupWithName(value.id) || null;
var param = data && data.tparams ? data.tparams.indexOf(data.kind || "") : -1;
var instance = !value.targs || !value.targs.length ?
value : param < 0 ?
value.targs[0] : value.targs[param];
var spec = instance !== value ? getDefGroupWithName(instance.id) || null : data || null;
var label = spec ? spec.kind || spec.name : instance.id;
var kinds = getAliasesOfName(instance.id) || null;
var count = kinds ? kinds.length : -1;
var index = 0;
if (value.targs && value.targs.length > 1) throw new Error("codegen needs review");
if (instance.namespace &&
instance.namespace.length === 1 &&
instance.namespace[0] === "SyntaxKind") {
this.push("\t\t\t\t{ id: \""+instance.id+"\", tags: [] },");
} else if (count > ALIAS_THRESHHOLD) this.push("\t\t\t\t{ id: \""+label+"\", tags: [] },");
else if (spec && spec.group) spec.group.forEach(routine, this);
else if (count < 1) this.push("\t\t\t\t{ id: \""+label+"\", tags: [] },");
else for (index; index < count; index++) {
this.push("\t\t\t\t{ id: \""+kinds[index]+"\", tags: [] },");
}
}, this);
this.push("\t\t\t]},");
}, this);
this.push("\t\t}},");
}
}, _emissions);
_emissions.push("\t},", "\tuntraversed: [");
[..._schemeByKind.keys()].filter(function (kind) {
return !this.has(kind);
}, _visitorByKind).forEach(function (kind) {
this.push("\t\t\""+kind+"\",");
}, _emissions);
_emissions.push("\t],", "// ***"+"/", "}\n");
return _emissions.join("\n");
},
// ****/
});
// JSDocNamespaceDeclaration
if (typeof module !== "undefined" && module.exports) {
module.exports = tv;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment