Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-creator

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-creator - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

2728

dist/index.js

@@ -1,1391 +0,1387 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('typescript')) :
typeof define === 'function' && define.amd ? define(['exports', 'typescript'], factory) :
(global = global || self, factory(global['ts-creator'] = {}, global.ts));
}(this, function (exports, ts) { 'use strict';
'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Object.defineProperty(exports, '__esModule', { value: true });
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
var ts = require('typescript');
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
/** @internal */
function getEnumMembers(enumObject) {
var result = [];
for (var name_1 in enumObject) {
var value = enumObject[name_1];
if (typeof value === 'number') {
result.push([value, name_1]);
}
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return result.sort(function (a, b) { return a[0] - b[0]; });
}
/** @internal */
function formatFlags(value, enumObject) {
if (value === void 0) { value = 0; }
var members = getEnumMembers(enumObject);
if (value === 0) {
return members.length > 0 && members[0][0] === 0
? [members[0][1]]
: [];
}
var result = [];
var remainingFlags = value;
for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
var _a = members[i], enumValue = _a[0], enumName = _a[1];
if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
remainingFlags &= ~enumValue;
result.push(enumName);
}
}
return result;
}
return t;
};
return __assign.apply(this, arguments);
};
/** @internal */
function createTsAccess(id) {
return ts.createPropertyAccess(ts.createIdentifier('ts'), id);
}
/** @internal */
function createTsCall(id, args) {
return ts.createCall(createTsAccess(ts.createIdentifier(id)), undefined, args);
}
/** @internal */
function createLiteralCall(node, func) {
return createTsCall(func, [ts.createStringLiteral(node.text)]);
}
function connectBinary(op, nodes) {
if (nodes.length === 0) {
return ts.createIdentifier('undefined');
/** @internal */
function getEnumMembers(enumObject) {
var result = [];
for (var name_1 in enumObject) {
var value = enumObject[name_1];
if (typeof value === 'number') {
result.push([value, name_1]);
}
if (nodes.length === 1) {
return nodes[0];
}
return ts.createBinary(nodes[0], op, connectBinary(op, nodes.slice(1)));
}
/** @internal */
function createNodeFlags(flags) {
var formattedFlags = formatFlags(flags, ts.NodeFlags).map(function (f) {
return ts.createPropertyAccess(createTsAccess(ts.createIdentifier('NodeFlags')), ts.createIdentifier(f));
});
return connectBinary(ts.SyntaxKind.BarBarToken, formattedFlags);
return result.sort(function (a, b) { return a[0] - b[0]; });
}
/** @internal */
function formatFlags(value, enumObject) {
if (value === void 0) { value = 0; }
var members = getEnumMembers(enumObject);
if (value === 0) {
return members.length > 0 && members[0][0] === 0
? [members[0][1]]
: [];
}
/** @internal */
function createBooleanLiteral(bool) {
if (bool === undefined) {
return ts.createIdentifier('undefined');
var result = [];
var remainingFlags = value;
for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
var _a = members[i], enumValue = _a[0], enumName = _a[1];
if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
remainingFlags &= ~enumValue;
result.push(enumName);
}
return bool ? ts.createTrue() : ts.createFalse();
}
return result;
}
function createEnumMember(node) {
return createTsCall('createEnumMember', [
transformVisitor(node.name),
transformVisitor(node.initializer)
]);
/** @internal */
function createTsAccess(id) {
return ts.createPropertyAccess(ts.createIdentifier('ts'), id);
}
/** @internal */
function createTsCall(id, args) {
return ts.createCall(createTsAccess(ts.createIdentifier(id)), undefined, args);
}
/** @internal */
function createLiteralCall(node, func) {
return createTsCall(func, [ts.createStringLiteral(node.text)]);
}
function connectBinary(op, nodes) {
if (nodes.length === 0) {
return ts.createIdentifier('undefined');
}
function createSpreadAssignment(node) {
return createTsCall('createSpreadAssignment', [
transformVisitor(node.expression)
]);
if (nodes.length === 1) {
return nodes[0];
}
function createShorthandPropertyAssignment(node) {
return createTsCall('createShorthandPropertyAssignment', [
transformVisitor(node.name),
transformVisitor(node.objectAssignmentInitializer)
]);
return ts.createBinary(nodes[0], op, connectBinary(op, nodes.slice(1)));
}
/** @internal */
function createNodeFlags(flags) {
var formattedFlags = formatFlags(flags, ts.NodeFlags).map(function (f) {
return ts.createPropertyAccess(createTsAccess(ts.createIdentifier('NodeFlags')), ts.createIdentifier(f));
});
return connectBinary(ts.SyntaxKind.BarBarToken, formattedFlags);
}
/** @internal */
function createBooleanLiteral(bool) {
if (bool === undefined) {
return ts.createIdentifier('undefined');
}
function createPropertyAssignment(node) {
return createTsCall('createPropertyAssignment', [
transformVisitor(node.name),
transformVisitor(node.initializer)
]);
return bool ? ts.createTrue() : ts.createFalse();
}
function createEnumMember(node) {
return createTsCall('createEnumMember', [
transformVisitor(node.name),
transformVisitor(node.initializer)
]);
}
function createSpreadAssignment(node) {
return createTsCall('createSpreadAssignment', [
transformVisitor(node.expression)
]);
}
function createShorthandPropertyAssignment(node) {
return createTsCall('createShorthandPropertyAssignment', [
transformVisitor(node.name),
transformVisitor(node.objectAssignmentInitializer)
]);
}
function createPropertyAssignment(node) {
return createTsCall('createPropertyAssignment', [
transformVisitor(node.name),
transformVisitor(node.initializer)
]);
}
function createCatchClause(node) {
return createTsCall('createCatchClause', [
transformVisitor(node.variableDeclaration),
transformVisitor(node.block)
]);
}
function createHeritageClause(node) {
return createTsCall('createHeritageClause', [
transformSyntaxKind(node.token),
transformVisitors(node.types)
]);
}
function createDefaultClause(node) {
return createTsCall('createDefaultClause', [
transformVisitors(node.statements)
]);
}
function createCaseClause(node) {
return createTsCall('createCaseClause', [
transformVisitor(node.expression),
transformVisitors(node.statements)
]);
}
function createExternalModuleReference(node) {
return createTsCall('createExternalModuleReference', [
transformVisitor(node.expression)
]);
}
function createExportSpecifier(node) {
return createTsCall('createExportSpecifier', [
transformVisitor(node.propertyName),
transformVisitor(node.name)
]);
}
function createNamedExports(node) {
return createTsCall('createNamedExports', [transformVisitors(node.elements)]);
}
function createExportDeclaration(node) {
return createTsCall('createExportDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.exportClause),
transformVisitor(node.moduleSpecifier)
]);
}
function createExportAssignment(node) {
return createTsCall('createExportAssignment', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
createBooleanLiteral(node.isExportEquals),
transformVisitor(node.expression)
]);
}
function createImportSpecifier(node) {
return createTsCall('createImportSpecifier', [
transformVisitor(node.propertyName),
transformVisitor(node.name)
]);
}
function createNamedImports(node) {
return createTsCall('createNamedImports', [transformVisitors(node.elements)]);
}
function createNamespaceImport(node) {
return createTsCall('createNamespaceImport', [transformVisitor(node.name)]);
}
function createImportClause(node) {
return createTsCall('createImportClause', [
transformVisitor(node.name),
transformVisitor(node.namedBindings)
]);
}
function createImportDeclaration(node) {
return createTsCall('createImportDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.importClause),
transformVisitor(node.moduleSpecifier)
]);
}
function createImportEqualsDeclaration(node) {
return createTsCall('createImportEqualsDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitor(node.moduleReference)
]);
}
function createNamespaceExportDeclaration(node) {
return createTsCall('createNamespaceExportDeclaration', [
transformVisitor(node.name)
]);
}
function createCaseBlock(node) {
return createTsCall('createCaseBlock', [transformVisitors(node.clauses)]);
}
function createModuleBlock(node) {
return createTsCall('createModuleBlock', [transformVisitors(node.statements)]);
}
function createModuleDeclaration(node) {
return createTsCall('createModuleDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitor(node.body),
createNodeFlags(node.flags)
]);
}
function createEnumDeclaration(node) {
return createTsCall('createEnumDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.members)
]);
}
function createTypeAliasDeclaration(node) {
return createTsCall('createTypeAliasDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitor(node.type)
]);
}
function createInterfaceDeclaration(node) {
return createTsCall('createInterfaceDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitors(node.heritageClauses),
transformVisitors(node.members)
]);
}
function createClassDeclaration(node) {
return createTsCall('createClassDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitors(node.heritageClauses),
transformVisitors(node.members)
]);
}
function createFunctionDeclaration(node) {
return createTsCall('createFunctionDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.asteriskToken),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.body)
]);
}
function createVariableDeclarationList(node) {
return createTsCall('createVariableDeclarationList', [
transformVisitors(node.declarations),
createNodeFlags(node.flags)
]);
}
function createVariableDeclaration(node) {
return createTsCall('createVariableDeclaration', [
transformVisitor(node.name),
transformVisitor(node.type),
transformVisitor(node.initializer)
]);
}
function createDebuggerStatement(node) {
return createTsCall('createDebuggerStatement', []);
}
function createTryStatement(node) {
return createTsCall('createTry', [
transformVisitor(node.tryBlock),
transformVisitor(node.catchClause),
transformVisitor(node.finallyBlock)
]);
}
function createThrowStatement(node) {
return createTsCall('createThrow', [transformVisitor(node.expression)]);
}
function createLabeledStatement(node) {
return createTsCall('createLabel', [
transformVisitor(node.label),
transformVisitor(node.statement)
]);
}
function createSwitchStatement(node) {
return createTsCall('createSwitch', [
transformVisitor(node.expression),
transformVisitor(node.caseBlock)
]);
}
function createWithStatement(node) {
return createTsCall('createWith', [
transformVisitor(node.expression),
transformVisitor(node.statement)
]);
}
function createReturnStatement(node) {
return createTsCall('createReturn', [transformVisitor(node.expression)]);
}
function createBreakStatement(node) {
return createTsCall('createBreak', [transformVisitor(node.label)]);
}
function createContinueStatement(node) {
return createTsCall('createContinue', [transformVisitor(node.label)]);
}
function createForOfStatement(node) {
return createTsCall('createForOf', [
transformVisitor(node.awaitModifier),
transformVisitor(node.initializer),
transformVisitor(node.expression),
transformVisitor(node.statement)
]);
}
function createForInStatement(node) {
return createTsCall('createForIn', [
transformVisitor(node.initializer),
transformVisitor(node.expression),
transformVisitor(node.statement)
]);
}
function createForStatement(node) {
return createTsCall('createFor', [
transformVisitor(node.initializer),
transformVisitor(node.condition),
transformVisitor(node.incrementor),
transformVisitor(node.statement)
]);
}
function createWhileStatement(node) {
return createTsCall('createWhile', [
transformVisitor(node.expression),
transformVisitor(node.statement)
]);
}
function createDoStatement(node) {
return createTsCall('createDo', [
transformVisitor(node.statement),
transformVisitor(node.expression)
]);
}
function createIfStatement(node) {
return createTsCall('createIf', [
transformVisitor(node.expression),
transformVisitor(node.thenStatement),
transformVisitor(node.elseStatement)
]);
}
function createEmptyStatement(node) {
return createTsCall('createEmptyStatement', []);
}
function createVariableStatement(node) {
return createTsCall('createVariableStatement', [
transformVisitors(node.modifiers),
transformVisitor(node.declarationList)
]);
}
function createBlock(node) {
return createTsCall('createBlock', [
transformVisitors(node.statements),
createBooleanLiteral(true)
]);
}
function createSemicolonClassElement(node) {
return createTsCall('createSemicolonClassElement', []);
}
function createTemplateSpan(node) {
return createTsCall('createTemplateSpan', [
transformVisitor(node.expression),
transformVisitor(node.literal)
]);
}
function createMetaProperty(node) {
return createTsCall('createMetaProperty', [
transformSyntaxKind(node.keywordToken),
transformVisitor(node.name)
]);
}
function createNonNullExpression(node) {
return createTsCall('createNonNullExpression', [
transformVisitor(node.expression)
]);
}
function createAsExpression(node) {
return createTsCall('createAsExpression', [
transformVisitor(node.expression),
transformVisitor(node.type)
]);
}
function createExpressionWithTypeArguments(node) {
return createTsCall('createExpressionWithTypeArguments', [
transformVisitors(node.typeArguments),
transformVisitor(node.expression)
]);
}
function createClassExpression(node) {
return createTsCall('createClassExpression', [
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitors(node.heritageClauses),
transformVisitors(node.members)
]);
}
function createSpreadElement(node) {
return createTsCall('createSpread', [transformVisitor(node.expression)]);
}
function createYieldExpression(node) {
return createTsCall('createYield', [transformVisitor(node.expression)]);
}
function createTemplateExpression(node) {
return createTsCall('createTemplateExpression', [
transformVisitor(node.head),
transformVisitors(node.templateSpans)
]);
}
function createConditionalExpression(node) {
return createTsCall('createConditional', [
transformVisitor(node.condition),
transformVisitor(node.whenTrue),
transformVisitor(node.whenFalse)
]);
}
function createBinaryExpression(node) {
return createTsCall('createBinary', [
transformVisitor(node.left),
transformVisitor(node.operatorToken),
transformVisitor(node.right)
]);
}
function createAwaitExpression(node) {
return createTsCall('createAwait', [transformVisitor(node.expression)]);
}
function createVoidExpression(node) {
return createTsCall('createVoid', [transformVisitor(node.expression)]);
}
function createTypeOfExpression(node) {
return createTsCall('createTypeOf', [transformVisitor(node.expression)]);
}
function createDeleteExpression(node) {
return createTsCall('createDelete', [transformVisitor(node.expression)]);
}
function createArrowFunction(node) {
return createTsCall('createArrowFunction', [
transformVisitors(node.modifiers),
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.equalsGreaterThanToken),
transformVisitor(node.body)
]);
}
function createFunctionExpression(node) {
return createTsCall('createFunctionExpression', [
transformVisitors(node.modifiers),
transformVisitor(node.asteriskToken),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.body)
]);
}
function createParenthesizedExpression(node) {
return createTsCall('createParen', [transformVisitor(node.expression)]);
}
function createTypeAssertionExpression(node) {
return createTsCall('createTypeAssertion', [
transformVisitor(node.type),
transformVisitor(node.expression)
]);
}
function createTaggedTemplateExpression(node) {
return createTsCall('createTaggedTemplate', [
transformVisitor(node.tag),
transformVisitor(node.template)
]);
}
function createNewExpression(node) {
return createTsCall('createNew', [
transformVisitor(node.expression),
transformVisitors(node.typeArguments),
transformVisitors(node.arguments)
]);
}
function createCallExpression(node) {
return createTsCall('createCall', [
transformVisitor(node.expression),
transformVisitors(node.typeArguments),
transformVisitors(node.arguments)
]);
}
function createElementAccessExpression(node) {
return createTsCall('createElementAccess', [
transformVisitor(node.expression),
transformVisitor(node.argumentExpression)
]);
}
function createPropertyAccessExpression(node) {
return createTsCall('createPropertyAccess', [
transformVisitor(node.expression),
transformVisitor(node.name)
]);
}
function createObjectLiteralExpression(node) {
return createTsCall('createObjectLiteral', [
transformVisitors(node.properties),
createBooleanLiteral(false)
]);
}
function createArrayLiteralExpression(node) {
return createTsCall('createArrayLiteral', [
transformVisitors(node.elements),
createBooleanLiteral(false)
]);
}
function createBindingElement(node) {
return createTsCall('createBindingElement', [
transformVisitor(node.dotDotDotToken),
transformVisitor(node.propertyName),
transformVisitor(node.name),
transformVisitor(node.initializer)
]);
}
function createArrayBindingPattern(node) {
return createTsCall('createArrayBindingPattern', [
transformVisitors(node.elements)
]);
}
function createObjectBindingPattern(node) {
return createTsCall('createObjectBindingPattern', [
transformVisitors(node.elements)
]);
}
function createImportType(node) {
return createTsCall('createImportTypeNode', [
transformVisitor(node.argument),
transformVisitor(node.qualifier),
transformVisitors(node.typeArguments),
createBooleanLiteral(node.isTypeOf)
]);
}
function createLiteralType(node) {
return createTsCall('createLiteralTypeNode', [transformVisitor(node.literal)]);
}
function createMappedType(node) {
return createTsCall('createMappedTypeNode', [
transformVisitor(node.readonlyToken),
transformVisitor(node.typeParameter),
transformVisitor(node.questionToken),
transformVisitor(node.type)
]);
}
function createIndexedAccessType(node) {
return createTsCall('createIndexedAccessTypeNode', [
transformVisitor(node.objectType),
transformVisitor(node.indexType)
]);
}
function createTypeOperator(node) {
return createTsCall('createTypeOperatorNode', [
transformSyntaxKind(node.operator),
transformVisitor(node.type)
]);
}
function createThisType(node) {
return createTsCall('createThisTypeNode');
}
function createParenthesizedType(node) {
return createTsCall('createParenthesizedType', [transformVisitor(node.type)]);
}
function createInferType(node) {
return createTsCall('createInferTypeNode', [
transformVisitor(node.typeParameter)
]);
}
function createConditionalType(node) {
return createTsCall('createConditionalTypeNode', [
transformVisitor(node.checkType),
transformVisitor(node.extendsType),
transformVisitor(node.trueType),
transformVisitor(node.falseType)
]);
}
function createIntersectionType(node) {
return createTsCall('createIntersectionTypeNode', [
transformVisitors(node.types)
]);
}
function createUnionType(node) {
return createTsCall('createUnionTypeNode', [transformVisitors(node.types)]);
}
function createRestType(node) {
return createTsCall('createRestTypeNode', [transformVisitor(node.type)]);
}
function createOptionalType(node) {
return createTsCall('createOptionalTypeNode', [transformVisitor(node.type)]);
}
function createTypleType(node) {
return createTsCall('createTupleTypeNode', [
transformVisitors(node.elementTypes)
]);
}
function createArrayType(node) {
return createTsCall('createArrayTypeNode', [
transformVisitor(node.elementType)
]);
}
function createTypeLiteral(node) {
return createTsCall('createTypeLiteralNode', [
transformVisitors(node.members)
]);
}
function createTypeQuery(node) {
return createTsCall('createTypeQueryNode', [transformVisitor(node.exprName)]);
}
function createConstructorType(node) {
return createTsCall('createConstructorTypeNode', [
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type)
]);
}
function createFunctionType(node) {
return createTsCall('createFunctionTypeNode', [
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type)
]);
}
function createTypeReference(node) {
return createTsCall('createTypeReferenceNode', [
transformVisitor(node.typeName),
transformVisitors(node.typeArguments)
]);
}
function createTypePredicate(node) {
return createTsCall('createTypePredicateNode', [
transformVisitor(node.parameterName),
transformVisitor(node.type)
]);
}
function createIndexSignature(node) {
return createTsCall('createIndexSignature', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitors(node.parameters),
transformVisitor(node.type)
]);
}
function createConstructSignature(node) {
return createTsCall('createConstructSignature', [
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type)
]);
}
function createConstructor(node) {
return createTsCall('createConstructor', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitors(node.parameters),
transformVisitor(node.body)
]);
}
function createGetAccessor(node) {
return createTsCall('createGetAccessor', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.body)
]);
}
function createSetAccessor(node) {
return createTsCall('createSetAccessor', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.parameters),
transformVisitor(node.body)
]);
}
function createCallSignature(node) {
return createTsCall('createCallSignature', [
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type)
]);
}
function createMethodDeclaration(node) {
return createTsCall('createMethod', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.asteriskToken),
transformVisitor(node.name),
transformVisitor(node.questionToken),
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.body)
]);
}
function createMethodSignature(node) {
return createTsCall('createMethodSignature', [
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.name),
transformVisitor(node.questionToken)
]);
}
function createPropertyDeclaration(node) {
return createTsCall('createProperty', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitorQuestionOrExclamation(node),
transformVisitor(node.type),
transformVisitor(node.initializer)
]);
}
function createPropertySignature(node) {
return createTsCall('createPropertySignature', [
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitor(node.questionToken),
transformVisitor(node.type),
transformVisitor(node.initializer)
]);
}
function createDecorator(node) {
return createTsCall('createDecorator', [transformVisitor(node.expression)]);
}
function createParameter(node) {
return createTsCall('createParameter', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.dotDotDotToken),
transformVisitor(node.name),
transformVisitor(node.questionToken),
transformVisitor(node.type),
transformVisitor(node.initializer)
]);
}
function createToken(node) {
ts.createToken(node.kind);
return createTsCall('createToken', [transformSyntaxKind(node.kind)]);
}
function createTypeParameter(node) {
return createTsCall('createTypeParameterDeclaration', [
transformVisitor(node.name),
transformVisitor(node.constraint),
transformVisitor(node.default)
]);
}
function createComputedPropertyName(node) {
return createTsCall('createComputedPropertyName', [
transformVisitor(node.expression)
]);
}
function createNumericLiteral(node) {
return createLiteralCall(node, 'createNumericLiteral');
}
function BigIntLiteral(node) {
return createLiteralCall(node, 'createBigIntLiteral');
}
function createStringLiteral(node) {
return createLiteralCall(node, 'createStringLiteral');
}
function createRegularExpressionLiteral(node) {
return createLiteralCall(node, 'createRegularExpressionLiteral');
}
function createNoSubstitutionTemplateLiteral(node) {
return createLiteralCall(node, 'createNoSubstitutionTemplateLiteral');
}
function createTemplateHead(node) {
return createLiteralCall(node, 'createTemplateHead');
}
function createTemplateMiddle(node) {
return createLiteralCall(node, 'createTemplateMiddle');
}
function createTemplateTail(node) {
return createLiteralCall(node, 'createTemplateTail');
}
function createIdentifier(node) {
return createLiteralCall(node, 'createIdentifier');
}
function createQualifiedName(node) {
return createTsCall('createQualifiedName', [
transformVisitor(node.left),
transformVisitor(node.right)
]);
}
function createExpressionStatement(node) {
return createTsCall('createExpressionStatement', [
transformVisitor(node.expression)
]);
}
function createPrefixUnaryExpression(node) {
return createTsCall('createPrefix', [
transformSyntaxKind(node.operator),
transformVisitor(node.operand)
]);
}
function createPostfixUnaryExpression(node) {
return createTsCall('createPostfix', [
transformVisitor(node.operand),
transformSyntaxKind(node.operator)
]);
}
function createJsxExpression(node) {
return createTsCall('createJsxExpression', [
transformVisitor(node.dotDotDotToken),
transformVisitor(node.expression)
]);
}
function createJsxSpreadAttribute(node) {
return createTsCall('createJsxSpreadAttribute', [
transformVisitor(node.expression)
]);
}
function createJsxAttributes(node) {
return createTsCall('createJsxAttributes', [
transformVisitors(node.properties)
]);
}
function createJsxAttribute(node) {
return createTsCall('createJsxAttribute', [
transformVisitor(node.name),
transformVisitor(node.initializer)
]);
}
function createJsxClosingFragment(node) {
return transformRawNode(ts.SyntaxKind.JsxClosingFragment);
}
function createJsxOpeningFragment(node) {
return transformRawNode(ts.SyntaxKind.JsxOpeningElement);
}
function createJsxFragment(node) {
return createTsCall('createJsxFragment', [
transformVisitor(node.openingFragment),
transformVisitors(node.children),
transformVisitor(node.closingFragment)
]);
}
function createJsxClosingElement(node) {
return createTsCall('createJsxClosingElement', [
transformVisitor(node.tagName)
]);
}
function createJsxOpeningElement(node) {
return createTsCall('createJsxOpeningElement', [
transformVisitor(node.tagName),
transformVisitors(node.typeArguments),
transformVisitor(node.attributes)
]);
}
function createJsxSelfClosingElement(node) {
return createTsCall('createJsxSelfClosingElement', [
transformVisitor(node.tagName),
transformVisitors(node.typeArguments),
transformVisitor(node.attributes)
]);
}
function createJsxElement(node) {
return createTsCall('createJsxElement', [
transformVisitor(node.openingElement),
transformVisitors(node.children),
transformVisitor(node.closingElement)
]);
}
function createJsxText(node) {
return transformRawNode(ts.SyntaxKind.JsxText);
}
function createSourceFile(node) {
return createTsCall('updateSourceFileNode', [
createTsCall('createSourceFile', [
ts.createStringLiteral(node.fileName),
ts.createStringLiteral(''),
ts.createPropertyAccess(createTsAccess(ts.createIdentifier('ScriptTarget')), ts.createIdentifier(ts.ScriptTarget[node.languageVersion]))
]),
transformVisitors(node.statements)
]);
}
function transformSyntaxKind(kind) {
return ts.createPropertyAccess(createTsAccess(ts.createIdentifier('SyntaxKind')), ts.createIdentifier(ts.SyntaxKind[kind]));
}
function transformRawNode(kind) {
return ts.createParen(ts.createAsExpression(createTsCall('createNode', [transformSyntaxKind(kind)]), ts.createTypeReferenceNode(ts.createQualifiedName(ts.createQualifiedName(ts.createIdentifier('ts'), ts.createIdentifier('SyntaxKind')), ts.createIdentifier(ts.SyntaxKind[kind])), undefined)));
}
function transformKeyword(kind) {
switch (kind) {
case ts.SyntaxKind.TrueKeyword:
return createTsCall('createTrue', []);
case ts.SyntaxKind.FalseKeyword:
return createTsCall('createFalse', []);
case ts.SyntaxKind.NullKeyword:
return createTsCall('createNull', []);
case ts.SyntaxKind.SuperKeyword:
return createTsCall('createSuper', []);
case ts.SyntaxKind.ThisKeyword:
return createTsCall('createThis', []);
case ts.SyntaxKind.AnyKeyword:
case ts.SyntaxKind.UnknownKeyword:
case ts.SyntaxKind.NumberKeyword:
case ts.SyntaxKind.BigIntKeyword:
case ts.SyntaxKind.ObjectKeyword:
case ts.SyntaxKind.BooleanKeyword:
case ts.SyntaxKind.StringKeyword:
case ts.SyntaxKind.SymbolKeyword:
case ts.SyntaxKind.VoidKeyword:
case ts.SyntaxKind.UndefinedKeyword:
case ts.SyntaxKind.NeverKeyword:
return transformTypeKeyword(kind);
case ts.SyntaxKind.AbstractKeyword:
case ts.SyntaxKind.AsyncKeyword:
case ts.SyntaxKind.ConstKeyword:
case ts.SyntaxKind.DeclareKeyword:
case ts.SyntaxKind.DefaultKeyword:
case ts.SyntaxKind.ExportKeyword:
case ts.SyntaxKind.PublicKeyword:
case ts.SyntaxKind.PrivateKeyword:
case ts.SyntaxKind.ProtectedKeyword:
case ts.SyntaxKind.ReadonlyKeyword:
case ts.SyntaxKind.StaticKeyword:
return transformModifier(kind);
default:
return transformRawNode(kind);
}
function createCatchClause(node) {
return createTsCall('createCatchClause', [
transformVisitor(node.variableDeclaration),
transformVisitor(node.block)
]);
}
function transformTypeKeyword(kind) {
return createTsCall('createKeywordTypeNode', [transformSyntaxKind(kind)]);
}
function transformModifier(kind) {
return createTsCall('createModifier', [transformSyntaxKind(kind)]);
}
function transformVisitorQuestionOrExclamation(node) {
if (node.questionToken) {
return transformVisitor(node.questionToken);
}
function createHeritageClause(node) {
return createTsCall('createHeritageClause', [
transformSyntaxKind(node.token),
transformVisitors(node.types)
]);
else if (node.exclamationToken) {
return transformVisitor(node.exclamationToken);
}
function createDefaultClause(node) {
return createTsCall('createDefaultClause', [
transformVisitors(node.statements)
]);
else {
return ts.createIdentifier('undefined');
}
function createCaseClause(node) {
return createTsCall('createCaseClause', [
transformVisitor(node.expression),
transformVisitors(node.statements)
]);
}
function transformVisitors(nodes) {
if (!nodes) {
return ts.createIdentifier('undefined');
}
function createExternalModuleReference(node) {
return createTsCall('createExternalModuleReference', [
transformVisitor(node.expression)
]);
return ts.createArrayLiteral(nodes.map(transformVisitor));
}
function transformVisitor(node) {
if (!node) {
return ts.createIdentifier('undefined');
}
function createExportSpecifier(node) {
return createTsCall('createExportSpecifier', [
transformVisitor(node.propertyName),
transformVisitor(node.name)
]);
switch (node.kind) {
case ts.SyntaxKind.QuestionToken:
case ts.SyntaxKind.ExclamationToken:
case ts.SyntaxKind.AsteriskToken:
case ts.SyntaxKind.PlusToken:
case ts.SyntaxKind.MinusToken:
case ts.SyntaxKind.DotDotDotToken:
case ts.SyntaxKind.EqualsGreaterThanToken:
case ts.SyntaxKind.CommaToken:
case ts.SyntaxKind.AsteriskToken:
case ts.SyntaxKind.AsteriskAsteriskToken:
case ts.SyntaxKind.SlashToken:
case ts.SyntaxKind.PercentToken:
case ts.SyntaxKind.LessThanToken:
case ts.SyntaxKind.LessThanEqualsToken:
case ts.SyntaxKind.GreaterThanToken:
case ts.SyntaxKind.GreaterThanEqualsToken:
case ts.SyntaxKind.InstanceOfKeyword:
case ts.SyntaxKind.GreaterThanEqualsToken:
case ts.SyntaxKind.GreaterThanGreaterThanToken:
case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
case ts.SyntaxKind.GreaterThanGreaterThanToken:
case ts.SyntaxKind.EqualsEqualsToken:
case ts.SyntaxKind.EqualsEqualsEqualsToken:
case ts.SyntaxKind.ExclamationEqualsEqualsToken:
case ts.SyntaxKind.ExclamationEqualsToken:
case ts.SyntaxKind.AmpersandToken:
case ts.SyntaxKind.BarToken:
case ts.SyntaxKind.CaretToken:
case ts.SyntaxKind.AmpersandAmpersandToken:
case ts.SyntaxKind.BarBarToken:
case ts.SyntaxKind.PlusEqualsToken:
case ts.SyntaxKind.MinusEqualsToken:
case ts.SyntaxKind.AsteriskAsteriskEqualsToken:
case ts.SyntaxKind.AsteriskEqualsToken:
case ts.SyntaxKind.SlashEqualsToken:
case ts.SyntaxKind.PercentEqualsToken:
case ts.SyntaxKind.AmpersandEqualsToken:
case ts.SyntaxKind.BarEqualsToken:
case ts.SyntaxKind.CaretEqualsToken:
case ts.SyntaxKind.LessThanLessThanEqualsToken:
case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
case ts.SyntaxKind.GreaterThanGreaterThanEqualsToken:
case ts.SyntaxKind.CommaToken:
case ts.SyntaxKind.EqualsToken:
case ts.SyntaxKind.LessThanLessThanToken:
return createToken(node);
case ts.SyntaxKind.InKeyword:
case ts.SyntaxKind.TrueKeyword:
case ts.SyntaxKind.FalseKeyword:
case ts.SyntaxKind.NumberKeyword:
case ts.SyntaxKind.VoidKeyword:
case ts.SyntaxKind.BooleanKeyword:
case ts.SyntaxKind.AnyKeyword:
case ts.SyntaxKind.StringKeyword:
case ts.SyntaxKind.SymbolKeyword:
case ts.SyntaxKind.ObjectKeyword:
case ts.SyntaxKind.UndefinedKeyword:
case ts.SyntaxKind.UnknownKeyword:
case ts.SyntaxKind.BigIntKeyword:
case ts.SyntaxKind.VoidKeyword:
case ts.SyntaxKind.ConstKeyword:
case ts.SyntaxKind.DefaultKeyword:
case ts.SyntaxKind.DeleteKeyword:
case ts.SyntaxKind.AwaitKeyword:
case ts.SyntaxKind.ExtendsKeyword:
case ts.SyntaxKind.ImplementsKeyword:
case ts.SyntaxKind.ExportKeyword:
case ts.SyntaxKind.ThisKeyword:
case ts.SyntaxKind.NullKeyword:
case ts.SyntaxKind.NeverKeyword:
case ts.SyntaxKind.AbstractKeyword:
case ts.SyntaxKind.AsyncKeyword:
case ts.SyntaxKind.DeclareKeyword:
case ts.SyntaxKind.PublicKeyword:
case ts.SyntaxKind.PrivateKeyword:
case ts.SyntaxKind.ProtectedKeyword:
case ts.SyntaxKind.ReadonlyKeyword:
case ts.SyntaxKind.StaticKeyword:
return transformKeyword(node.kind);
case ts.SyntaxKind.NumericLiteral:
return createNumericLiteral(node);
case ts.SyntaxKind.BigIntLiteral:
return BigIntLiteral(node);
case ts.SyntaxKind.StringLiteral:
return createStringLiteral(node);
case ts.SyntaxKind.RegularExpressionLiteral:
return createRegularExpressionLiteral(node);
case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
return createNoSubstitutionTemplateLiteral(node);
case ts.SyntaxKind.TemplateHead:
return createTemplateHead(node);
case ts.SyntaxKind.TemplateMiddle:
return createTemplateMiddle(node);
case ts.SyntaxKind.TemplateTail:
return createTemplateTail(node);
case ts.SyntaxKind.Identifier:
return createIdentifier(node);
case ts.SyntaxKind.QualifiedName:
return createQualifiedName(node);
case ts.SyntaxKind.ComputedPropertyName:
return createComputedPropertyName(node);
case ts.SyntaxKind.TypeParameter:
return createTypeParameter(node);
case ts.SyntaxKind.Parameter:
return createParameter(node);
case ts.SyntaxKind.Decorator:
return createDecorator(node);
case ts.SyntaxKind.PropertySignature:
return createPropertySignature(node);
case ts.SyntaxKind.PropertyDeclaration:
return createPropertyDeclaration(node);
case ts.SyntaxKind.MethodSignature:
return createMethodSignature(node);
case ts.SyntaxKind.MethodDeclaration:
return createMethodDeclaration(node);
case ts.SyntaxKind.Constructor:
return createConstructor(node);
case ts.SyntaxKind.GetAccessor:
return createGetAccessor(node);
case ts.SyntaxKind.SetAccessor:
return createSetAccessor(node);
case ts.SyntaxKind.CallSignature:
return createCallSignature(node);
case ts.SyntaxKind.ConstructSignature:
return createConstructSignature(node);
case ts.SyntaxKind.IndexSignature:
return createIndexSignature(node);
case ts.SyntaxKind.TypePredicate:
return createTypePredicate(node);
case ts.SyntaxKind.TypeReference:
return createTypeReference(node);
case ts.SyntaxKind.FunctionType:
return createFunctionType(node);
case ts.SyntaxKind.ConstructorType:
return createConstructorType(node);
case ts.SyntaxKind.TypeQuery:
return createTypeQuery(node);
case ts.SyntaxKind.TypeLiteral:
return createTypeLiteral(node);
case ts.SyntaxKind.ArrayType:
return createArrayType(node);
case ts.SyntaxKind.TupleType:
return createTypleType(node);
case ts.SyntaxKind.OptionalType:
return createOptionalType(node);
case ts.SyntaxKind.RestType:
return createRestType(node);
case ts.SyntaxKind.UnionType:
return createUnionType(node);
case ts.SyntaxKind.IntersectionType:
return createIntersectionType(node);
case ts.SyntaxKind.ConditionalType:
return createConditionalType(node);
case ts.SyntaxKind.InferType:
return createInferType(node);
case ts.SyntaxKind.ParenthesizedType:
return createParenthesizedType(node);
case ts.SyntaxKind.ThisType:
return createThisType(node);
case ts.SyntaxKind.TypeOperator:
return createTypeOperator(node);
case ts.SyntaxKind.IndexedAccessType:
return createIndexedAccessType(node);
case ts.SyntaxKind.MappedType:
return createMappedType(node);
case ts.SyntaxKind.LiteralType:
return createLiteralType(node);
case ts.SyntaxKind.ImportType:
return createImportType(node);
case ts.SyntaxKind.ObjectBindingPattern:
return createObjectBindingPattern(node);
case ts.SyntaxKind.ArrayBindingPattern:
return createArrayBindingPattern(node);
case ts.SyntaxKind.BindingElement:
return createBindingElement(node);
case ts.SyntaxKind.ArrayLiteralExpression:
return createArrayLiteralExpression(node);
case ts.SyntaxKind.ObjectLiteralExpression:
return createObjectLiteralExpression(node);
case ts.SyntaxKind.PropertyAccessExpression:
return createPropertyAccessExpression(node);
case ts.SyntaxKind.ElementAccessExpression:
return createElementAccessExpression(node);
case ts.SyntaxKind.CallExpression:
return createCallExpression(node);
case ts.SyntaxKind.NewExpression:
return createNewExpression(node);
case ts.SyntaxKind.TaggedTemplateExpression:
return createTaggedTemplateExpression(node);
case ts.SyntaxKind.TypeAssertionExpression:
return createTypeAssertionExpression(node);
case ts.SyntaxKind.ParenthesizedExpression:
return createParenthesizedExpression(node);
case ts.SyntaxKind.FunctionExpression:
return createFunctionExpression(node);
case ts.SyntaxKind.ArrowFunction:
return createArrowFunction(node);
case ts.SyntaxKind.DeleteExpression:
return createDeleteExpression(node);
case ts.SyntaxKind.TypeOfExpression:
return createTypeOfExpression(node);
case ts.SyntaxKind.VoidExpression:
return createVoidExpression(node);
case ts.SyntaxKind.AwaitExpression:
return createAwaitExpression(node);
case ts.SyntaxKind.BinaryExpression:
return createBinaryExpression(node);
case ts.SyntaxKind.ConditionalExpression:
return createConditionalExpression(node);
case ts.SyntaxKind.TemplateExpression:
return createTemplateExpression(node);
case ts.SyntaxKind.YieldExpression:
return createYieldExpression(node);
case ts.SyntaxKind.SpreadElement:
return createSpreadElement(node);
case ts.SyntaxKind.ClassExpression:
return createClassExpression(node);
case ts.SyntaxKind.ExpressionWithTypeArguments:
return createExpressionWithTypeArguments(node);
case ts.SyntaxKind.AsExpression:
return createAsExpression(node);
case ts.SyntaxKind.NonNullExpression:
return createNonNullExpression(node);
case ts.SyntaxKind.MetaProperty:
return createMetaProperty(node);
case ts.SyntaxKind.TemplateSpan:
return createTemplateSpan(node);
case ts.SyntaxKind.SemicolonClassElement:
return createSemicolonClassElement(node);
case ts.SyntaxKind.Block:
return createBlock(node);
case ts.SyntaxKind.VariableStatement:
return createVariableStatement(node);
case ts.SyntaxKind.EmptyStatement:
return createEmptyStatement(node);
case ts.SyntaxKind.ExpressionStatement:
return createExpressionStatement(node);
case ts.SyntaxKind.IfStatement:
return createIfStatement(node);
case ts.SyntaxKind.DoStatement:
return createDoStatement(node);
case ts.SyntaxKind.WhileStatement:
return createWhileStatement(node);
case ts.SyntaxKind.ForStatement:
return createForStatement(node);
case ts.SyntaxKind.ForInStatement:
return createForInStatement(node);
case ts.SyntaxKind.ForOfStatement:
return createForOfStatement(node);
case ts.SyntaxKind.ContinueStatement:
return createContinueStatement(node);
case ts.SyntaxKind.BreakStatement:
return createBreakStatement(node);
case ts.SyntaxKind.ReturnStatement:
return createReturnStatement(node);
case ts.SyntaxKind.WithStatement:
return createWithStatement(node);
case ts.SyntaxKind.SwitchStatement:
return createSwitchStatement(node);
case ts.SyntaxKind.LabeledStatement:
return createLabeledStatement(node);
case ts.SyntaxKind.ThrowStatement:
return createThrowStatement(node);
case ts.SyntaxKind.TryStatement:
return createTryStatement(node);
case ts.SyntaxKind.DebuggerStatement:
return createDebuggerStatement(node);
case ts.SyntaxKind.VariableDeclaration:
return createVariableDeclaration(node);
case ts.SyntaxKind.VariableDeclarationList:
return createVariableDeclarationList(node);
case ts.SyntaxKind.FunctionDeclaration:
return createFunctionDeclaration(node);
case ts.SyntaxKind.ClassDeclaration:
return createClassDeclaration(node);
case ts.SyntaxKind.InterfaceDeclaration:
return createInterfaceDeclaration(node);
case ts.SyntaxKind.TypeAliasDeclaration:
return createTypeAliasDeclaration(node);
case ts.SyntaxKind.EnumDeclaration:
return createEnumDeclaration(node);
case ts.SyntaxKind.ModuleDeclaration:
return createModuleDeclaration(node);
case ts.SyntaxKind.ModuleBlock:
return createModuleBlock(node);
case ts.SyntaxKind.CaseBlock:
return createCaseBlock(node);
case ts.SyntaxKind.NamespaceExportDeclaration:
return createNamespaceExportDeclaration(node);
case ts.SyntaxKind.ImportEqualsDeclaration:
return createImportEqualsDeclaration(node);
case ts.SyntaxKind.ImportDeclaration:
return createImportDeclaration(node);
case ts.SyntaxKind.ImportClause:
return createImportClause(node);
case ts.SyntaxKind.NamespaceImport:
return createNamespaceImport(node);
case ts.SyntaxKind.NamedImports:
return createNamedImports(node);
case ts.SyntaxKind.ImportSpecifier:
return createImportSpecifier(node);
case ts.SyntaxKind.ExportAssignment:
return createExportAssignment(node);
case ts.SyntaxKind.ExportDeclaration:
return createExportDeclaration(node);
case ts.SyntaxKind.NamedExports:
return createNamedExports(node);
case ts.SyntaxKind.ExportSpecifier:
return createExportSpecifier(node);
case ts.SyntaxKind.ExternalModuleReference:
return createExternalModuleReference(node);
case ts.SyntaxKind.CaseClause:
return createCaseClause(node);
case ts.SyntaxKind.DefaultClause:
return createDefaultClause(node);
case ts.SyntaxKind.HeritageClause:
return createHeritageClause(node);
case ts.SyntaxKind.CatchClause:
return createCatchClause(node);
case ts.SyntaxKind.PropertyAssignment:
return createPropertyAssignment(node);
case ts.SyntaxKind.ShorthandPropertyAssignment:
return createShorthandPropertyAssignment(node);
case ts.SyntaxKind.SpreadAssignment:
return createSpreadAssignment(node);
case ts.SyntaxKind.EnumMember:
return createEnumMember(node);
case ts.SyntaxKind.PrefixUnaryExpression:
return createPrefixUnaryExpression(node);
case ts.SyntaxKind.PostfixUnaryExpression:
return createPostfixUnaryExpression(node);
case ts.SyntaxKind.SourceFile:
return createSourceFile(node);
case ts.SyntaxKind.JsxElement:
return createJsxElement(node);
case ts.SyntaxKind.JsxSelfClosingElement:
return createJsxSelfClosingElement(node);
case ts.SyntaxKind.JsxOpeningElement:
return createJsxOpeningElement(node);
case ts.SyntaxKind.JsxClosingElement:
return createJsxClosingElement(node);
case ts.SyntaxKind.JsxFragment:
return createJsxFragment(node);
case ts.SyntaxKind.JsxOpeningFragment:
return createJsxOpeningFragment(node);
case ts.SyntaxKind.JsxClosingFragment:
return createJsxClosingFragment(node);
case ts.SyntaxKind.JsxAttribute:
return createJsxAttribute(node);
case ts.SyntaxKind.JsxAttributes:
return createJsxAttributes(node);
case ts.SyntaxKind.JsxSpreadAttribute:
return createJsxSpreadAttribute(node);
case ts.SyntaxKind.JsxExpression:
return createJsxExpression(node);
case ts.SyntaxKind.JsxText:
return createJsxText(node);
case ts.SyntaxKind.MissingDeclaration:
case ts.SyntaxKind.SyntheticExpression:
case ts.SyntaxKind.OmittedExpression:
throw new Error('unknown syntax: ' + node.kind + ' ' + JSON.stringify(node));
default:
throw new Error('unsupported syntax: ' + node.kind);
}
function createNamedExports(node) {
return createTsCall('createNamedExports', [transformVisitors(node.elements)]);
}
function createExportDeclaration(node) {
return createTsCall('createExportDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.exportClause),
transformVisitor(node.moduleSpecifier)
]);
}
function createExportAssignment(node) {
return createTsCall('createExportAssignment', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
createBooleanLiteral(node.isExportEquals),
transformVisitor(node.expression)
]);
}
function createImportSpecifier(node) {
return createTsCall('createImportSpecifier', [
transformVisitor(node.propertyName),
transformVisitor(node.name)
]);
}
function createNamedImports(node) {
return createTsCall('createNamedImports', [transformVisitors(node.elements)]);
}
function createNamespaceImport(node) {
return createTsCall('createNamespaceImport', [transformVisitor(node.name)]);
}
function createImportClause(node) {
return createTsCall('createImportClause', [
transformVisitor(node.name),
transformVisitor(node.namedBindings)
]);
}
function createImportDeclaration(node) {
return createTsCall('createImportDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.importClause),
transformVisitor(node.moduleSpecifier)
]);
}
function createImportEqualsDeclaration(node) {
return createTsCall('createImportEqualsDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitor(node.moduleReference)
]);
}
function createNamespaceExportDeclaration(node) {
return createTsCall('createNamespaceExportDeclaration', [
transformVisitor(node.name)
]);
}
function createCaseBlock(node) {
return createTsCall('createCaseBlock', [transformVisitors(node.clauses)]);
}
function createModuleBlock(node) {
return createTsCall('createModuleBlock', [transformVisitors(node.statements)]);
}
function createModuleDeclaration(node) {
return createTsCall('createModuleDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitor(node.body),
createNodeFlags(node.flags)
]);
}
function createEnumDeclaration(node) {
return createTsCall('createEnumDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.members)
]);
}
function createTypeAliasDeclaration(node) {
return createTsCall('createTypeAliasDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitor(node.type)
]);
}
function createInterfaceDeclaration(node) {
return createTsCall('createInterfaceDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitors(node.heritageClauses),
transformVisitors(node.members)
]);
}
function createClassDeclaration(node) {
return createTsCall('createClassDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitors(node.heritageClauses),
transformVisitors(node.members)
]);
}
function createFunctionDeclaration(node) {
return createTsCall('createFunctionDeclaration', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.asteriskToken),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.body)
]);
}
function createVariableDeclarationList(node) {
return createTsCall('createVariableDeclarationList', [
transformVisitors(node.declarations),
createNodeFlags(node.flags)
]);
}
function createVariableDeclaration(node) {
return createTsCall('createVariableDeclaration', [
transformVisitor(node.name),
transformVisitor(node.type),
transformVisitor(node.initializer)
]);
}
function createDebuggerStatement(node) {
return createTsCall('createDebuggerStatement', []);
}
function createTryStatement(node) {
return createTsCall('createTry', [
transformVisitor(node.tryBlock),
transformVisitor(node.catchClause),
transformVisitor(node.finallyBlock)
]);
}
function createThrowStatement(node) {
return createTsCall('createThrow', [transformVisitor(node.expression)]);
}
function createLabeledStatement(node) {
return createTsCall('createLabel', [
transformVisitor(node.label),
transformVisitor(node.statement)
]);
}
function createSwitchStatement(node) {
return createTsCall('createSwitch', [
transformVisitor(node.expression),
transformVisitor(node.caseBlock)
]);
}
function createWithStatement(node) {
return createTsCall('createWith', [
transformVisitor(node.expression),
transformVisitor(node.statement)
]);
}
function createReturnStatement(node) {
return createTsCall('createReturn', [transformVisitor(node.expression)]);
}
function createBreakStatement(node) {
return createTsCall('createBreak', [transformVisitor(node.label)]);
}
function createContinueStatement(node) {
return createTsCall('createContinue', [transformVisitor(node.label)]);
}
function createForOfStatement(node) {
return createTsCall('createForOf', [
transformVisitor(node.awaitModifier),
transformVisitor(node.initializer),
transformVisitor(node.expression),
transformVisitor(node.statement)
]);
}
function createForInStatement(node) {
return createTsCall('createForIn', [
transformVisitor(node.initializer),
transformVisitor(node.expression),
transformVisitor(node.statement)
]);
}
function createForStatement(node) {
return createTsCall('createFor', [
transformVisitor(node.initializer),
transformVisitor(node.condition),
transformVisitor(node.incrementor),
transformVisitor(node.statement)
]);
}
function createWhileStatement(node) {
return createTsCall('createWhile', [
transformVisitor(node.expression),
transformVisitor(node.statement)
]);
}
function createDoStatement(node) {
return createTsCall('createDo', [
transformVisitor(node.statement),
transformVisitor(node.expression)
]);
}
function createIfStatement(node) {
return createTsCall('createIf', [
transformVisitor(node.expression),
transformVisitor(node.thenStatement),
transformVisitor(node.elseStatement)
]);
}
function createEmptyStatement(node) {
return createTsCall('createEmptyStatement', []);
}
function createVariableStatement(node) {
return createTsCall('createVariableStatement', [
transformVisitors(node.modifiers),
transformVisitor(node.declarationList)
]);
}
function createBlock(node) {
return createTsCall('createBlock', [
transformVisitors(node.statements),
createBooleanLiteral(true)
]);
}
function createSemicolonClassElement(node) {
return createTsCall('createSemicolonClassElement', []);
}
function createTemplateSpan(node) {
return createTsCall('createTemplateSpan', [
transformVisitor(node.expression),
transformVisitor(node.literal)
]);
}
function createMetaProperty(node) {
return createTsCall('createMetaProperty', [
transformSyntaxKind(node.keywordToken),
transformVisitor(node.name)
]);
}
function createNonNullExpression(node) {
return createTsCall('createNonNullExpression', [
transformVisitor(node.expression)
]);
}
function createAsExpression(node) {
return createTsCall('createAsExpression', [
transformVisitor(node.expression),
transformVisitor(node.type)
]);
}
function createExpressionWithTypeArguments(node) {
return createTsCall('createExpressionWithTypeArguments', [
transformVisitors(node.typeArguments),
transformVisitor(node.expression)
]);
}
function createClassExpression(node) {
return createTsCall('createClassExpression', [
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitors(node.heritageClauses),
transformVisitors(node.members)
]);
}
function createSpreadElement(node) {
return createTsCall('createSpread', [transformVisitor(node.expression)]);
}
function createYieldExpression(node) {
return createTsCall('createYield', [transformVisitor(node.expression)]);
}
function createTemplateExpression(node) {
return createTsCall('createTemplateExpression', [
transformVisitor(node.head),
transformVisitors(node.templateSpans)
]);
}
function createConditionalExpression(node) {
return createTsCall('createConditional', [
transformVisitor(node.condition),
transformVisitor(node.whenTrue),
transformVisitor(node.whenFalse)
]);
}
function createBinaryExpression(node) {
return createTsCall('createBinary', [
transformVisitor(node.left),
transformVisitor(node.operatorToken),
transformVisitor(node.right)
]);
}
function createAwaitExpression(node) {
return createTsCall('createAwait', [transformVisitor(node.expression)]);
}
function createVoidExpression(node) {
return createTsCall('createVoid', [transformVisitor(node.expression)]);
}
function createTypeOfExpression(node) {
return createTsCall('createTypeOf', [transformVisitor(node.expression)]);
}
function createDeleteExpression(node) {
return createTsCall('createDelete', [transformVisitor(node.expression)]);
}
function createArrowFunction(node) {
return createTsCall('createArrowFunction', [
transformVisitors(node.modifiers),
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.equalsGreaterThanToken),
transformVisitor(node.body)
]);
}
function createFunctionExpression(node) {
return createTsCall('createFunctionExpression', [
transformVisitors(node.modifiers),
transformVisitor(node.asteriskToken),
transformVisitor(node.name),
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.body)
]);
}
function createParenthesizedExpression(node) {
return createTsCall('createParen', [transformVisitor(node.expression)]);
}
function createTypeAssertionExpression(node) {
return createTsCall('createTypeAssertion', [
transformVisitor(node.type),
transformVisitor(node.expression)
]);
}
function createTaggedTemplateExpression(node) {
return createTsCall('createTaggedTemplate', [
transformVisitor(node.tag),
transformVisitor(node.template)
]);
}
function createNewExpression(node) {
return createTsCall('createNew', [
transformVisitor(node.expression),
transformVisitors(node.typeArguments),
transformVisitors(node.arguments)
]);
}
function createCallExpression(node) {
return createTsCall('createCall', [
transformVisitor(node.expression),
transformVisitors(node.typeArguments),
transformVisitors(node.arguments)
]);
}
function createElementAccessExpression(node) {
return createTsCall('createElementAccess', [
transformVisitor(node.expression),
transformVisitor(node.argumentExpression)
]);
}
function createPropertyAccessExpression(node) {
return createTsCall('createPropertyAccess', [
transformVisitor(node.expression),
transformVisitor(node.name)
]);
}
function createObjectLiteralExpression(node) {
return createTsCall('createObjectLiteral', [
transformVisitors(node.properties),
createBooleanLiteral(false)
]);
}
function createArrayLiteralExpression(node) {
return createTsCall('createArrayLiteral', [
transformVisitors(node.elements),
createBooleanLiteral(false)
]);
}
function createBindingElement(node) {
return createTsCall('createBindingElement', [
transformVisitor(node.dotDotDotToken),
transformVisitor(node.propertyName),
transformVisitor(node.name),
transformVisitor(node.initializer)
]);
}
function createArrayBindingPattern(node) {
return createTsCall('createArrayBindingPattern', [
transformVisitors(node.elements)
]);
}
function createObjectBindingPattern(node) {
return createTsCall('createObjectBindingPattern', [
transformVisitors(node.elements)
]);
}
function createImportType(node) {
return createTsCall('createImportTypeNode', [
transformVisitor(node.argument),
transformVisitor(node.qualifier),
transformVisitors(node.typeArguments),
createBooleanLiteral(node.isTypeOf)
]);
}
function createLiteralType(node) {
return createTsCall('createLiteralTypeNode', [transformVisitor(node.literal)]);
}
function createMappedType(node) {
return createTsCall('createMappedTypeNode', [
transformVisitor(node.readonlyToken),
transformVisitor(node.typeParameter),
transformVisitor(node.questionToken),
transformVisitor(node.type)
]);
}
function createIndexedAccessType(node) {
return createTsCall('createIndexedAccessTypeNode', [
transformVisitor(node.objectType),
transformVisitor(node.indexType)
]);
}
function createTypeOperator(node) {
return createTsCall('createTypeOperatorNode', [
transformSyntaxKind(node.operator),
transformVisitor(node.type)
]);
}
function createThisType(node) {
return createTsCall('createThisTypeNode');
}
function createParenthesizedType(node) {
return createTsCall('createParenthesizedType', [transformVisitor(node.type)]);
}
function createInferType(node) {
return createTsCall('createInferTypeNode', [
transformVisitor(node.typeParameter)
]);
}
function createConditionalType(node) {
return createTsCall('createConditionalTypeNode', [
transformVisitor(node.checkType),
transformVisitor(node.extendsType),
transformVisitor(node.trueType),
transformVisitor(node.falseType)
]);
}
function createIntersectionType(node) {
return createTsCall('createIntersectionTypeNode', [
transformVisitors(node.types)
]);
}
function createUnionType(node) {
return createTsCall('createUnionTypeNode', [transformVisitors(node.types)]);
}
function createRestType(node) {
return createTsCall('createRestTypeNode', [transformVisitor(node.type)]);
}
function createOptionalType(node) {
return createTsCall('createOptionalTypeNode', [transformVisitor(node.type)]);
}
function createTypleType(node) {
return createTsCall('createTupleTypeNode', [
transformVisitors(node.elementTypes)
]);
}
function createArrayType(node) {
return createTsCall('createArrayTypeNode', [
transformVisitor(node.elementType)
]);
}
function createTypeLiteral(node) {
return createTsCall('createTypeLiteralNode', [
transformVisitors(node.members)
]);
}
function createTypeQuery(node) {
return createTsCall('createTypeQueryNode', [transformVisitor(node.exprName)]);
}
function createConstructorType(node) {
return createTsCall('createConstructorTypeNode', [
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type)
]);
}
function createFunctionType(node) {
return createTsCall('createFunctionTypeNode', [
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type)
]);
}
function createTypeReference(node) {
return createTsCall('createTypeReferenceNode', [
transformVisitor(node.typeName),
transformVisitors(node.typeArguments)
]);
}
function createTypePredicate(node) {
return createTsCall('createTypePredicateNode', [
transformVisitor(node.parameterName),
transformVisitor(node.type)
]);
}
function createIndexSignature(node) {
return createTsCall('createIndexSignature', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitors(node.parameters),
transformVisitor(node.type)
]);
}
function createConstructSignature(node) {
return createTsCall('createConstructSignature', [
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type)
]);
}
function createConstructor(node) {
return createTsCall('createConstructor', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitors(node.parameters),
transformVisitor(node.body)
]);
}
function createGetAccessor(node) {
return createTsCall('createGetAccessor', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.body)
]);
}
function createSetAccessor(node) {
return createTsCall('createSetAccessor', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitors(node.parameters),
transformVisitor(node.body)
]);
}
function createCallSignature(node) {
return createTsCall('createCallSignature', [
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type)
]);
}
function createMethodDeclaration(node) {
return createTsCall('createMethod', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.asteriskToken),
transformVisitor(node.name),
transformVisitor(node.questionToken),
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.body)
]);
}
function createMethodSignature(node) {
return createTsCall('createMethodSignature', [
transformVisitors(node.typeParameters),
transformVisitors(node.parameters),
transformVisitor(node.type),
transformVisitor(node.name),
transformVisitor(node.questionToken)
]);
}
function createPropertyDeclaration(node) {
return createTsCall('createProperty', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitorQuestionOrExclamation(node),
transformVisitor(node.type),
transformVisitor(node.initializer)
]);
}
function createPropertySignature(node) {
return createTsCall('createPropertySignature', [
transformVisitors(node.modifiers),
transformVisitor(node.name),
transformVisitor(node.questionToken),
transformVisitor(node.type),
transformVisitor(node.initializer)
]);
}
function createDecorator(node) {
return createTsCall('createDecorator', [transformVisitor(node.expression)]);
}
function createParameter(node) {
return createTsCall('createParameter', [
transformVisitors(node.decorators),
transformVisitors(node.modifiers),
transformVisitor(node.dotDotDotToken),
transformVisitor(node.name),
transformVisitor(node.questionToken),
transformVisitor(node.type),
transformVisitor(node.initializer)
]);
}
function createToken(node) {
ts.createToken(node.kind);
return createTsCall('createToken', [transformSyntaxKind(node.kind)]);
}
function createTypeParameter(node) {
return createTsCall('createTypeParameterDeclaration', [
transformVisitor(node.name),
transformVisitor(node.constraint),
transformVisitor(node.default)
]);
}
function createComputedPropertyName(node) {
return createTsCall('createComputedPropertyName', [
transformVisitor(node.expression)
]);
}
function createNumericLiteral(node) {
return createLiteralCall(node, 'createNumericLiteral');
}
function BigIntLiteral(node) {
return createLiteralCall(node, 'createBigIntLiteral');
}
function createStringLiteral(node) {
return createLiteralCall(node, 'createStringLiteral');
}
function createRegularExpressionLiteral(node) {
return createLiteralCall(node, 'createRegularExpressionLiteral');
}
function createNoSubstitutionTemplateLiteral(node) {
return createLiteralCall(node, 'createNoSubstitutionTemplateLiteral');
}
function createTemplateHead(node) {
return createLiteralCall(node, 'createTemplateHead');
}
function createTemplateMiddle(node) {
return createLiteralCall(node, 'createTemplateMiddle');
}
function createTemplateTail(node) {
return createLiteralCall(node, 'createTemplateTail');
}
function createIdentifier(node) {
return createLiteralCall(node, 'createIdentifier');
}
function createQualifiedName(node) {
return createTsCall('createQualifiedName', [
transformVisitor(node.left),
transformVisitor(node.right)
]);
}
function createExpressionStatement(node) {
return createTsCall('createExpressionStatement', [
transformVisitor(node.expression)
]);
}
function createPrefixUnaryExpression(node) {
return createTsCall('createPrefix', [
transformSyntaxKind(node.operator),
transformVisitor(node.operand)
]);
}
function createPostfixUnaryExpression(node) {
return createTsCall('createPostfix', [
transformVisitor(node.operand),
transformSyntaxKind(node.operator)
]);
}
function createJsxExpression(node) {
return createTsCall('createJsxExpression', [
transformVisitor(node.dotDotDotToken),
transformVisitor(node.expression)
]);
}
function createJsxSpreadAttribute(node) {
return createTsCall('createJsxSpreadAttribute', [
transformVisitor(node.expression)
]);
}
function createJsxAttributes(node) {
return createTsCall('createJsxAttributes', [
transformVisitors(node.properties)
]);
}
function createJsxAttribute(node) {
return createTsCall('createJsxAttribute', [
transformVisitor(node.name),
transformVisitor(node.initializer)
]);
}
function createJsxClosingFragment(node) {
return transformRawNode(ts.SyntaxKind.JsxClosingFragment);
}
function createJsxOpeningFragment(node) {
return transformRawNode(ts.SyntaxKind.JsxOpeningElement);
}
function createJsxFragment(node) {
return createTsCall('createJsxFragment', [
transformVisitor(node.openingFragment),
transformVisitors(node.children),
transformVisitor(node.closingFragment)
]);
}
function createJsxClosingElement(node) {
return createTsCall('createJsxClosingElement', [
transformVisitor(node.tagName)
]);
}
function createJsxOpeningElement(node) {
return createTsCall('createJsxOpeningElement', [
transformVisitor(node.tagName),
transformVisitors(node.typeArguments),
transformVisitor(node.attributes)
]);
}
function createJsxSelfClosingElement(node) {
return createTsCall('createJsxSelfClosingElement', [
transformVisitor(node.tagName),
transformVisitors(node.typeArguments),
transformVisitor(node.attributes)
]);
}
function createJsxElement(node) {
return createTsCall('createJsxElement', [
transformVisitor(node.openingElement),
transformVisitors(node.children),
transformVisitor(node.closingElement)
]);
}
function createJsxText(node) {
return transformRawNode(ts.SyntaxKind.JsxText);
}
function createSourceFile(node) {
return createTsCall('updateSourceFileNode', [
createTsCall('createSourceFile', [
ts.createStringLiteral(node.fileName),
ts.createStringLiteral(''),
ts.createPropertyAccess(createTsAccess(ts.createIdentifier('ScriptTarget')), ts.createIdentifier(ts.ScriptTarget[node.languageVersion]))
]),
transformVisitors(node.statements)
]);
}
function transformSyntaxKind(kind) {
return ts.createPropertyAccess(createTsAccess(ts.createIdentifier('SyntaxKind')), ts.createIdentifier(ts.SyntaxKind[kind]));
}
function transformRawNode(kind) {
return ts.createParen(ts.createAsExpression(createTsCall('createNode', [transformSyntaxKind(kind)]), ts.createTypeReferenceNode(ts.createQualifiedName(ts.createQualifiedName(ts.createIdentifier('ts'), ts.createIdentifier('SyntaxKind')), ts.createIdentifier(ts.SyntaxKind[kind])), undefined)));
}
function transformKeyword(kind) {
switch (kind) {
case ts.SyntaxKind.TrueKeyword:
return createTsCall('createTrue', []);
case ts.SyntaxKind.FalseKeyword:
return createTsCall('createFalse', []);
case ts.SyntaxKind.NullKeyword:
return createTsCall('createNull', []);
case ts.SyntaxKind.SuperKeyword:
return createTsCall('createSuper', []);
case ts.SyntaxKind.ThisKeyword:
return createTsCall('createThis', []);
case ts.SyntaxKind.AnyKeyword:
case ts.SyntaxKind.UnknownKeyword:
case ts.SyntaxKind.NumberKeyword:
case ts.SyntaxKind.BigIntKeyword:
case ts.SyntaxKind.ObjectKeyword:
case ts.SyntaxKind.BooleanKeyword:
case ts.SyntaxKind.StringKeyword:
case ts.SyntaxKind.SymbolKeyword:
case ts.SyntaxKind.VoidKeyword:
case ts.SyntaxKind.UndefinedKeyword:
case ts.SyntaxKind.NeverKeyword:
return transformTypeKeyword(kind);
case ts.SyntaxKind.AbstractKeyword:
case ts.SyntaxKind.AsyncKeyword:
case ts.SyntaxKind.ConstKeyword:
case ts.SyntaxKind.DeclareKeyword:
case ts.SyntaxKind.DefaultKeyword:
case ts.SyntaxKind.ExportKeyword:
case ts.SyntaxKind.PublicKeyword:
case ts.SyntaxKind.PrivateKeyword:
case ts.SyntaxKind.ProtectedKeyword:
case ts.SyntaxKind.ReadonlyKeyword:
case ts.SyntaxKind.StaticKeyword:
return transformModifier(kind);
default:
return transformRawNode(kind);
}
}
function transformTypeKeyword(kind) {
return createTsCall('createKeywordTypeNode', [transformSyntaxKind(kind)]);
}
function transformModifier(kind) {
return createTsCall('createModifier', [transformSyntaxKind(kind)]);
}
function transformVisitorQuestionOrExclamation(node) {
if (node.questionToken) {
return transformVisitor(node.questionToken);
}
else if (node.exclamationToken) {
return transformVisitor(node.exclamationToken);
}
else {
return ts.createIdentifier('undefined');
}
}
function transformVisitors(nodes) {
if (!nodes) {
return ts.createIdentifier('undefined');
}
return ts.createArrayLiteral(nodes.map(transformVisitor));
}
function transformVisitor(node) {
if (!node) {
return ts.createIdentifier('undefined');
}
switch (node.kind) {
case ts.SyntaxKind.QuestionToken:
case ts.SyntaxKind.ExclamationToken:
case ts.SyntaxKind.AsteriskToken:
case ts.SyntaxKind.PlusToken:
case ts.SyntaxKind.MinusToken:
case ts.SyntaxKind.DotDotDotToken:
case ts.SyntaxKind.EqualsGreaterThanToken:
case ts.SyntaxKind.CommaToken:
case ts.SyntaxKind.AsteriskToken:
case ts.SyntaxKind.AsteriskAsteriskToken:
case ts.SyntaxKind.SlashToken:
case ts.SyntaxKind.PercentToken:
case ts.SyntaxKind.LessThanToken:
case ts.SyntaxKind.LessThanEqualsToken:
case ts.SyntaxKind.GreaterThanToken:
case ts.SyntaxKind.GreaterThanEqualsToken:
case ts.SyntaxKind.InstanceOfKeyword:
case ts.SyntaxKind.GreaterThanEqualsToken:
case ts.SyntaxKind.GreaterThanGreaterThanToken:
case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
case ts.SyntaxKind.GreaterThanGreaterThanToken:
case ts.SyntaxKind.EqualsEqualsToken:
case ts.SyntaxKind.EqualsEqualsEqualsToken:
case ts.SyntaxKind.ExclamationEqualsEqualsToken:
case ts.SyntaxKind.ExclamationEqualsToken:
case ts.SyntaxKind.AmpersandToken:
case ts.SyntaxKind.BarToken:
case ts.SyntaxKind.CaretToken:
case ts.SyntaxKind.AmpersandAmpersandToken:
case ts.SyntaxKind.BarBarToken:
case ts.SyntaxKind.PlusEqualsToken:
case ts.SyntaxKind.MinusEqualsToken:
case ts.SyntaxKind.AsteriskAsteriskEqualsToken:
case ts.SyntaxKind.AsteriskEqualsToken:
case ts.SyntaxKind.SlashEqualsToken:
case ts.SyntaxKind.PercentEqualsToken:
case ts.SyntaxKind.AmpersandEqualsToken:
case ts.SyntaxKind.BarEqualsToken:
case ts.SyntaxKind.CaretEqualsToken:
case ts.SyntaxKind.LessThanLessThanEqualsToken:
case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
case ts.SyntaxKind.GreaterThanGreaterThanEqualsToken:
case ts.SyntaxKind.CommaToken:
case ts.SyntaxKind.EqualsToken:
case ts.SyntaxKind.LessThanLessThanToken:
return createToken(node);
case ts.SyntaxKind.InKeyword:
case ts.SyntaxKind.TrueKeyword:
case ts.SyntaxKind.FalseKeyword:
case ts.SyntaxKind.NumberKeyword:
case ts.SyntaxKind.VoidKeyword:
case ts.SyntaxKind.BooleanKeyword:
case ts.SyntaxKind.AnyKeyword:
case ts.SyntaxKind.StringKeyword:
case ts.SyntaxKind.SymbolKeyword:
case ts.SyntaxKind.ObjectKeyword:
case ts.SyntaxKind.UndefinedKeyword:
case ts.SyntaxKind.UnknownKeyword:
case ts.SyntaxKind.BigIntKeyword:
case ts.SyntaxKind.VoidKeyword:
case ts.SyntaxKind.ConstKeyword:
case ts.SyntaxKind.DefaultKeyword:
case ts.SyntaxKind.DeleteKeyword:
case ts.SyntaxKind.AwaitKeyword:
case ts.SyntaxKind.ExtendsKeyword:
case ts.SyntaxKind.ImplementsKeyword:
case ts.SyntaxKind.ExportKeyword:
case ts.SyntaxKind.ThisKeyword:
case ts.SyntaxKind.NullKeyword:
case ts.SyntaxKind.NeverKeyword:
case ts.SyntaxKind.AbstractKeyword:
case ts.SyntaxKind.AsyncKeyword:
case ts.SyntaxKind.DeclareKeyword:
case ts.SyntaxKind.PublicKeyword:
case ts.SyntaxKind.PrivateKeyword:
case ts.SyntaxKind.ProtectedKeyword:
case ts.SyntaxKind.ReadonlyKeyword:
case ts.SyntaxKind.StaticKeyword:
return transformKeyword(node.kind);
case ts.SyntaxKind.NumericLiteral:
return createNumericLiteral(node);
case ts.SyntaxKind.BigIntLiteral:
return BigIntLiteral(node);
case ts.SyntaxKind.StringLiteral:
return createStringLiteral(node);
case ts.SyntaxKind.RegularExpressionLiteral:
return createRegularExpressionLiteral(node);
case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
return createNoSubstitutionTemplateLiteral(node);
case ts.SyntaxKind.TemplateHead:
return createTemplateHead(node);
case ts.SyntaxKind.TemplateMiddle:
return createTemplateMiddle(node);
case ts.SyntaxKind.TemplateTail:
return createTemplateTail(node);
case ts.SyntaxKind.Identifier:
return createIdentifier(node);
case ts.SyntaxKind.QualifiedName:
return createQualifiedName(node);
case ts.SyntaxKind.ComputedPropertyName:
return createComputedPropertyName(node);
case ts.SyntaxKind.TypeParameter:
return createTypeParameter(node);
case ts.SyntaxKind.Parameter:
return createParameter(node);
case ts.SyntaxKind.Decorator:
return createDecorator(node);
case ts.SyntaxKind.PropertySignature:
return createPropertySignature(node);
case ts.SyntaxKind.PropertyDeclaration:
return createPropertyDeclaration(node);
case ts.SyntaxKind.MethodSignature:
return createMethodSignature(node);
case ts.SyntaxKind.MethodDeclaration:
return createMethodDeclaration(node);
case ts.SyntaxKind.Constructor:
return createConstructor(node);
case ts.SyntaxKind.GetAccessor:
return createGetAccessor(node);
case ts.SyntaxKind.SetAccessor:
return createSetAccessor(node);
case ts.SyntaxKind.CallSignature:
return createCallSignature(node);
case ts.SyntaxKind.ConstructSignature:
return createConstructSignature(node);
case ts.SyntaxKind.IndexSignature:
return createIndexSignature(node);
case ts.SyntaxKind.TypePredicate:
return createTypePredicate(node);
case ts.SyntaxKind.TypeReference:
return createTypeReference(node);
case ts.SyntaxKind.FunctionType:
return createFunctionType(node);
case ts.SyntaxKind.ConstructorType:
return createConstructorType(node);
case ts.SyntaxKind.TypeQuery:
return createTypeQuery(node);
case ts.SyntaxKind.TypeLiteral:
return createTypeLiteral(node);
case ts.SyntaxKind.ArrayType:
return createArrayType(node);
case ts.SyntaxKind.TupleType:
return createTypleType(node);
case ts.SyntaxKind.OptionalType:
return createOptionalType(node);
case ts.SyntaxKind.RestType:
return createRestType(node);
case ts.SyntaxKind.UnionType:
return createUnionType(node);
case ts.SyntaxKind.IntersectionType:
return createIntersectionType(node);
case ts.SyntaxKind.ConditionalType:
return createConditionalType(node);
case ts.SyntaxKind.InferType:
return createInferType(node);
case ts.SyntaxKind.ParenthesizedType:
return createParenthesizedType(node);
case ts.SyntaxKind.ThisType:
return createThisType(node);
case ts.SyntaxKind.TypeOperator:
return createTypeOperator(node);
case ts.SyntaxKind.IndexedAccessType:
return createIndexedAccessType(node);
case ts.SyntaxKind.MappedType:
return createMappedType(node);
case ts.SyntaxKind.LiteralType:
return createLiteralType(node);
case ts.SyntaxKind.ImportType:
return createImportType(node);
case ts.SyntaxKind.ObjectBindingPattern:
return createObjectBindingPattern(node);
case ts.SyntaxKind.ArrayBindingPattern:
return createArrayBindingPattern(node);
case ts.SyntaxKind.BindingElement:
return createBindingElement(node);
case ts.SyntaxKind.ArrayLiteralExpression:
return createArrayLiteralExpression(node);
case ts.SyntaxKind.ObjectLiteralExpression:
return createObjectLiteralExpression(node);
case ts.SyntaxKind.PropertyAccessExpression:
return createPropertyAccessExpression(node);
case ts.SyntaxKind.ElementAccessExpression:
return createElementAccessExpression(node);
case ts.SyntaxKind.CallExpression:
return createCallExpression(node);
case ts.SyntaxKind.NewExpression:
return createNewExpression(node);
case ts.SyntaxKind.TaggedTemplateExpression:
return createTaggedTemplateExpression(node);
case ts.SyntaxKind.TypeAssertionExpression:
return createTypeAssertionExpression(node);
case ts.SyntaxKind.ParenthesizedExpression:
return createParenthesizedExpression(node);
case ts.SyntaxKind.FunctionExpression:
return createFunctionExpression(node);
case ts.SyntaxKind.ArrowFunction:
return createArrowFunction(node);
case ts.SyntaxKind.DeleteExpression:
return createDeleteExpression(node);
case ts.SyntaxKind.TypeOfExpression:
return createTypeOfExpression(node);
case ts.SyntaxKind.VoidExpression:
return createVoidExpression(node);
case ts.SyntaxKind.AwaitExpression:
return createAwaitExpression(node);
case ts.SyntaxKind.BinaryExpression:
return createBinaryExpression(node);
case ts.SyntaxKind.ConditionalExpression:
return createConditionalExpression(node);
case ts.SyntaxKind.TemplateExpression:
return createTemplateExpression(node);
case ts.SyntaxKind.YieldExpression:
return createYieldExpression(node);
case ts.SyntaxKind.SpreadElement:
return createSpreadElement(node);
case ts.SyntaxKind.ClassExpression:
return createClassExpression(node);
case ts.SyntaxKind.ExpressionWithTypeArguments:
return createExpressionWithTypeArguments(node);
case ts.SyntaxKind.AsExpression:
return createAsExpression(node);
case ts.SyntaxKind.NonNullExpression:
return createNonNullExpression(node);
case ts.SyntaxKind.MetaProperty:
return createMetaProperty(node);
case ts.SyntaxKind.TemplateSpan:
return createTemplateSpan(node);
case ts.SyntaxKind.SemicolonClassElement:
return createSemicolonClassElement(node);
case ts.SyntaxKind.Block:
return createBlock(node);
case ts.SyntaxKind.VariableStatement:
return createVariableStatement(node);
case ts.SyntaxKind.EmptyStatement:
return createEmptyStatement(node);
case ts.SyntaxKind.ExpressionStatement:
return createExpressionStatement(node);
case ts.SyntaxKind.IfStatement:
return createIfStatement(node);
case ts.SyntaxKind.DoStatement:
return createDoStatement(node);
case ts.SyntaxKind.WhileStatement:
return createWhileStatement(node);
case ts.SyntaxKind.ForStatement:
return createForStatement(node);
case ts.SyntaxKind.ForInStatement:
return createForInStatement(node);
case ts.SyntaxKind.ForOfStatement:
return createForOfStatement(node);
case ts.SyntaxKind.ContinueStatement:
return createContinueStatement(node);
case ts.SyntaxKind.BreakStatement:
return createBreakStatement(node);
case ts.SyntaxKind.ReturnStatement:
return createReturnStatement(node);
case ts.SyntaxKind.WithStatement:
return createWithStatement(node);
case ts.SyntaxKind.SwitchStatement:
return createSwitchStatement(node);
case ts.SyntaxKind.LabeledStatement:
return createLabeledStatement(node);
case ts.SyntaxKind.ThrowStatement:
return createThrowStatement(node);
case ts.SyntaxKind.TryStatement:
return createTryStatement(node);
case ts.SyntaxKind.DebuggerStatement:
return createDebuggerStatement(node);
case ts.SyntaxKind.VariableDeclaration:
return createVariableDeclaration(node);
case ts.SyntaxKind.VariableDeclarationList:
return createVariableDeclarationList(node);
case ts.SyntaxKind.FunctionDeclaration:
return createFunctionDeclaration(node);
case ts.SyntaxKind.ClassDeclaration:
return createClassDeclaration(node);
case ts.SyntaxKind.InterfaceDeclaration:
return createInterfaceDeclaration(node);
case ts.SyntaxKind.TypeAliasDeclaration:
return createTypeAliasDeclaration(node);
case ts.SyntaxKind.EnumDeclaration:
return createEnumDeclaration(node);
case ts.SyntaxKind.ModuleDeclaration:
return createModuleDeclaration(node);
case ts.SyntaxKind.ModuleBlock:
return createModuleBlock(node);
case ts.SyntaxKind.CaseBlock:
return createCaseBlock(node);
case ts.SyntaxKind.NamespaceExportDeclaration:
return createNamespaceExportDeclaration(node);
case ts.SyntaxKind.ImportEqualsDeclaration:
return createImportEqualsDeclaration(node);
case ts.SyntaxKind.ImportDeclaration:
return createImportDeclaration(node);
case ts.SyntaxKind.ImportClause:
return createImportClause(node);
case ts.SyntaxKind.NamespaceImport:
return createNamespaceImport(node);
case ts.SyntaxKind.NamedImports:
return createNamedImports(node);
case ts.SyntaxKind.ImportSpecifier:
return createImportSpecifier(node);
case ts.SyntaxKind.ExportAssignment:
return createExportAssignment(node);
case ts.SyntaxKind.ExportDeclaration:
return createExportDeclaration(node);
case ts.SyntaxKind.NamedExports:
return createNamedExports(node);
case ts.SyntaxKind.ExportSpecifier:
return createExportSpecifier(node);
case ts.SyntaxKind.ExternalModuleReference:
return createExternalModuleReference(node);
case ts.SyntaxKind.CaseClause:
return createCaseClause(node);
case ts.SyntaxKind.DefaultClause:
return createDefaultClause(node);
case ts.SyntaxKind.HeritageClause:
return createHeritageClause(node);
case ts.SyntaxKind.CatchClause:
return createCatchClause(node);
case ts.SyntaxKind.PropertyAssignment:
return createPropertyAssignment(node);
case ts.SyntaxKind.ShorthandPropertyAssignment:
return createShorthandPropertyAssignment(node);
case ts.SyntaxKind.SpreadAssignment:
return createSpreadAssignment(node);
case ts.SyntaxKind.EnumMember:
return createEnumMember(node);
case ts.SyntaxKind.PrefixUnaryExpression:
return createPrefixUnaryExpression(node);
case ts.SyntaxKind.PostfixUnaryExpression:
return createPostfixUnaryExpression(node);
case ts.SyntaxKind.SourceFile:
return createSourceFile(node);
case ts.SyntaxKind.JsxElement:
return createJsxElement(node);
case ts.SyntaxKind.JsxSelfClosingElement:
return createJsxSelfClosingElement(node);
case ts.SyntaxKind.JsxOpeningElement:
return createJsxOpeningElement(node);
case ts.SyntaxKind.JsxClosingElement:
return createJsxClosingElement(node);
case ts.SyntaxKind.JsxFragment:
return createJsxFragment(node);
case ts.SyntaxKind.JsxOpeningFragment:
return createJsxOpeningFragment(node);
case ts.SyntaxKind.JsxClosingFragment:
return createJsxClosingFragment(node);
case ts.SyntaxKind.JsxAttribute:
return createJsxAttribute(node);
case ts.SyntaxKind.JsxAttributes:
return createJsxAttributes(node);
case ts.SyntaxKind.JsxSpreadAttribute:
return createJsxSpreadAttribute(node);
case ts.SyntaxKind.JsxExpression:
return createJsxExpression(node);
case ts.SyntaxKind.JsxText:
return createJsxText(node);
case ts.SyntaxKind.MissingDeclaration:
case ts.SyntaxKind.SyntheticExpression:
case ts.SyntaxKind.OmittedExpression:
throw new Error('unknown syntax: ' + node.kind + ' ' + JSON.stringify(node));
default:
throw new Error('unsupported syntax: ' + node.kind);
}
}
function transformNode(node) {
return transformVisitor(node);
}
function transformSourceFile(sourceFile) {
return ts.updateSourceFileNode(sourceFile, [
ts.createExpressionStatement(transformVisitor(sourceFile))
]);
}
}
function transformNode(node) {
return transformVisitor(node);
}
function transformSourceFile(sourceFile) {
return ts.updateSourceFileNode(sourceFile, [
ts.createExpressionStatement(transformVisitor(sourceFile))
]);
}
var prettier = require('prettier/standalone');
var prettierTS = require('prettier/parser-typescript');
var defaultPrettierOptions = {
parser: 'typescript',
plugins: [prettierTS],
semi: false,
singleQuote: true,
jsxSingleQuote: false,
bracketSpacing: true,
tabWidth: 2,
useTabs: false,
trailingComma: 'none',
proseWrap: 'preserve'
};
function create(code, options) {
if (options === void 0) { options = {}; }
var printer = ts.createPrinter();
var file = ts.createSourceFile('templory.ts', code, ts.ScriptTarget.Latest);
var factoryFile = transformSourceFile(file);
var factoryCode = printer.printFile(factoryFile);
var prettierOptions = __assign({}, defaultPrettierOptions, options.prettierOptions);
return prettier.format(factoryCode, prettierOptions);
}
var prettier = require('prettier/standalone');
var prettierTS = require('prettier/parser-typescript');
var defaultPrettierOptions = {
parser: 'typescript',
plugins: [prettierTS],
semi: false,
singleQuote: true,
jsxSingleQuote: false,
bracketSpacing: true,
tabWidth: 2,
useTabs: false,
trailingComma: 'none',
proseWrap: 'preserve'
};
function create(code, options) {
if (options === void 0) { options = {}; }
var printer = ts.createPrinter();
var file = ts.createSourceFile('templory.ts', code, ts.ScriptTarget.Latest);
var factoryFile = transformSourceFile(file);
var factoryCode = printer.printFile(factoryFile);
var prettierOptions = __assign({}, defaultPrettierOptions, options.prettierOptions);
return prettier.format(factoryCode, prettierOptions);
}
exports.default = create;
exports.transformNode = transformNode;
exports.transformSourceFile = transformSourceFile;
Object.defineProperty(exports, '__esModule', { value: true });
}));
exports.default = create;
exports.transformNode = transformNode;
exports.transformSourceFile = transformSourceFile;
{
"name": "ts-creator",
"version": "1.1.4",
"version": "1.1.5",
"description": "A code generator to generate TypeScript code generator from TypeScript code",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc