code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); return container && container.kind !== 248 /* SourceFile */; }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
isNamespaceExportReference
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here // we manually emit the identifier to avoid rewriting. writeTextOfNode(currentText, node.name); // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, // we emit a normal property assignment. For example: // module m { // export let y; // } // module m { // let obj = { y }; // } // Here we need to emit obj = { y : m.y } regardless of the output target. if (modulekind !== 5 /* ES6 */ || isNamespaceExportReference(node.name)) { // Emit identifier as an identifier write(": "); emit(node.name); } if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) { write(" = "); emit(node.objectAssignmentInitializer); } }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitShorthandPropertyAssignment
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function tryEmitConstantValue(node) { var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { var propertyName = node.kind === 166 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
tryEmitConstantValue
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function tryGetConstEnumValue(node) { if (compilerOptions.isolatedModules) { return undefined; } return node.kind === 166 /* PropertyAccessExpression */ || node.kind === 167 /* ElementAccessExpression */ ? resolver.getConstantValue(node) : undefined; }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
tryGetConstEnumValue
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitPropertyAccess(node) { if (tryEmitConstantValue(node)) { return; } emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal var shouldEmitSpace = false; if (!indentedBeforeDot) { if (node.expression.kind === 8 /* NumericLiteral */) { // check if numeric literal was originally written with a dot var text = ts.getTextOfNodeFromSourceText(currentText, node.expression); shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; } else { // check if constant enum value is integer var constantValue = tryGetConstEnumValue(node.expression); // isFinite handles cases when constantValue is undefined shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; } } if (shouldEmitSpace) { write(" ."); } else { write("."); } var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitPropertyAccess
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitQualifiedName(node) { emit(node.left); write("."); emit(node.right); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitQualifiedName
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitQualifiedNameAsExpression(node, useFallback) { if (node.left.kind === 69 /* Identifier */) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { var temp = createAndRecordTempVariable(0 /* Auto */); write("("); emitNodeWithoutSourceMap(temp); write(" = "); emitEntityNameAsExpression(node.left, /*useFallback*/ true); write(") && "); emitNodeWithoutSourceMap(temp); } else { emitEntityNameAsExpression(node.left, /*useFallback*/ false); } write("."); emit(node.right); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitQualifiedNameAsExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 69 /* Identifier */: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); write(" !== 'undefined' && "); } emitExpressionIdentifier(node); break; case 135 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitEntityNameAsExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitIndexedAccess(node) { if (tryEmitConstantValue(node)) { return; } emit(node.expression); write("["); emit(node.argumentExpression); write("]"); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitIndexedAccess
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function hasSpreadElement(elements) { return ts.forEach(elements, function (e) { return e.kind === 185 /* SpreadElementExpression */; }); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
hasSpreadElement
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function skipParentheses(node) { while (node.kind === 172 /* ParenthesizedExpression */ || node.kind === 171 /* TypeAssertionExpression */ || node.kind === 189 /* AsExpression */) { node = node.expression; } return node; }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
skipParentheses
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitCallTarget(node) { if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || node.kind === 95 /* SuperKeyword */) { emit(node); return node; } var temp = createAndRecordTempVariable(0 /* Auto */); write("("); emit(temp); write(" = "); emit(node); write(")"); return temp; }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitCallTarget
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); if (expr.kind === 166 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } else if (expr.kind === 167 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } else if (expr.kind === 95 /* SuperKeyword */) { target = expr; write("_super"); } else { emit(node.expression); } write(".apply("); if (target) { if (target.kind === 95 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } else { // Calls of form obj.foo(...) emit(target); } } else { // Calls of form foo(...) write("void 0"); } write(", "); emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); write(")"); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitCallWithSpread
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitCallExpression(node) { if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { emitCallWithSpread(node); return; } var superCall = false; if (node.expression.kind === 95 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); superCall = node.expression.kind === 166 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); emitThis(node.expression); if (node.arguments.length) { write(", "); emitCommaList(node.arguments); } write(")"); } else { write("("); emitCommaList(node.arguments); write(")"); } }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitCallExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitNewExpression(node) { write("new "); // Spread operator logic is supported in new expressions in ES5 using a combination // of Function.prototype.bind() and Function.prototype.apply(). // // Example: // // var args = [1, 2, 3, 4, 5]; // new Array(...args); // // is compiled into the following ES5: // // var args = [1, 2, 3, 4, 5]; // new (Array.bind.apply(Array, [void 0].concat(args))); // // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', // Thus, we set it to undefined ('void 0'). if (languageVersion === 1 /* ES5 */ && node.arguments && hasSpreadElement(node.arguments)) { write("("); var target = emitCallTarget(node.expression); write(".bind.apply("); emit(target); write(", [void 0].concat("); emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); write(")))"); write("()"); } else { emit(node.expression); if (node.arguments) { write("("); emitCommaList(node.arguments); write(")"); } } }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitNewExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitTaggedTemplateExpression(node) { if (languageVersion >= 2 /* ES6 */) { emit(node.tag); write(" "); emit(node.template); } else { emitDownlevelTaggedTemplate(node); } }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitTaggedTemplateExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitParenExpression(node) { // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174 /* ArrowFunction */) { if (node.expression.kind === 171 /* TypeAssertionExpression */ || node.expression.kind === 189 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (<any><number><any>-A).x; while (operand.kind === 171 /* TypeAssertionExpression */ || operand.kind === 189 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (<Type>SubExpr) // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. // Omitting the parentheses, however, could cause change in the semantics of the generated // code if the casted expression has a lower precedence than the rest of the expression, e.g.: // (<any>new A).foo should be emitted as (new A).foo and not new A.foo // (<any>typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (<any>A()) should be emitted as new (A()) and not new A() // (<any>function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () if (operand.kind !== 179 /* PrefixUnaryExpression */ && operand.kind !== 177 /* VoidExpression */ && operand.kind !== 176 /* TypeOfExpression */ && operand.kind !== 175 /* DeleteExpression */ && operand.kind !== 180 /* PostfixUnaryExpression */ && operand.kind !== 169 /* NewExpression */ && !(operand.kind === 168 /* CallExpression */ && node.parent.kind === 169 /* NewExpression */) && !(operand.kind === 173 /* FunctionExpression */ && node.parent.kind === 168 /* CallExpression */) && !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 166 /* PropertyAccessExpression */)) { emit(operand); return; } } } write("("); emit(node.expression); write(")"); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitParenExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitDeleteExpression(node) { write(ts.tokenToString(78 /* DeleteKeyword */)); write(" "); emit(node.expression); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitDeleteExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitVoidExpression(node) { write(ts.tokenToString(103 /* VoidKeyword */)); write(" "); emit(node.expression); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitVoidExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitTypeOfExpression(node) { write(ts.tokenToString(101 /* TypeOfKeyword */)); write(" "); emit(node.expression); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitTypeOfExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 /* VariableDeclaration */ || node.parent.kind === 163 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
isNameOfExportedSourceLevelDeclarationInSystemExternalModule
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitPrefixUnaryExpression(node) { var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); if (exportChanged) { // emit // ++x // as // exports('x', ++x) write(exportFunctionForFile + "(\""); emitNodeWithoutSourceMap(node.operand); write("\", "); } write(ts.tokenToString(node.operator)); // In some cases, we need to emit a space between the operator and the operand. One obvious case // is when the operator is an identifier, like delete or typeof. We also need to do this for plus // and minus expressions in certain cases. Specifically, consider the following two cases (parens // are just for clarity of exposition, and not part of the source code): // // (+(+1)) // (+(++1)) // // We need to emit a space in both cases. In the first case, the absence of a space will make // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. if (node.operand.kind === 179 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { write(" "); } else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */)) { write(" "); } } emit(node.operand); if (exportChanged) { write(")"); } }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitPrefixUnaryExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitPostfixUnaryExpression(node) { var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); if (exportChanged) { // export function returns the value that was passes as the second argument // however for postfix unary expressions result value should be the value before modification. // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' write("(" + exportFunctionForFile + "(\""); emitNodeWithoutSourceMap(node.operand); write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); if (node.operator === 41 /* PlusPlusToken */) { write(") - 1)"); } else { write(") + 1)"); } } else { emit(node.operand); write(ts.tokenToString(node.operator)); } }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
emitPostfixUnaryExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function shouldHoistDeclarationInSystemJsModule(node) { return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
shouldHoistDeclarationInSystemJsModule
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { if (!node || !isCurrentFileSystemExternalModule()) { return false; } var current = node; while (current) { if (current.kind === 248 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 2 /* Export */) !== 0); } else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { return false; } else { current = current.parent; } } }
Returns whether the expression has lesser, greater, or equal precedence to the binary '+' operator
isSourceFileLevelDeclarationInSystemJsModule
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitSerializedTypeNode(node) { if (node) { switch (node.kind) { case 103 /* VoidKeyword */: write("void 0"); return; case 160 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; case 152 /* FunctionType */: case 153 /* ConstructorType */: write("Function"); return; case 156 /* ArrayType */: case 157 /* TupleType */: write("Array"); return; case 150 /* TypePredicate */: case 120 /* BooleanKeyword */: write("Boolean"); return; case 130 /* StringKeyword */: case 9 /* StringLiteral */: write("String"); return; case 128 /* NumberKeyword */: write("Number"); return; case 131 /* SymbolKeyword */: write("Symbol"); return; case 151 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; case 154 /* TypeQuery */: case 155 /* TypeLiteral */: case 158 /* UnionType */: case 159 /* IntersectionType */: case 117 /* AnyKeyword */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); break; } } write("Object"); }
Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member.
emitSerializedTypeNode
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitSerializedTypeReferenceNode(node) { var location = node.parent; while (ts.isDeclaration(location) || ts.isTypeNode(location)) { location = location.parent; } // Clone the type name and parent it to a location outside of the current declaration. var typeName = ts.cloneEntityName(node.typeName); typeName.parent = location; var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0 /* Auto */); write("(typeof ("); emitNodeWithoutSourceMap(temp); write(" = "); emitEntityNameAsExpression(typeName, /*useFallback*/ true); write(") === 'function' && "); emitNodeWithoutSourceMap(temp); write(") || Object"); break; case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: emitEntityNameAsExpression(typeName, /*useFallback*/ false); break; case ts.TypeReferenceSerializationKind.VoidType: write("void 0"); break; case ts.TypeReferenceSerializationKind.BooleanType: write("Boolean"); break; case ts.TypeReferenceSerializationKind.NumberLikeType: write("Number"); break; case ts.TypeReferenceSerializationKind.StringLikeType: write("String"); break; case ts.TypeReferenceSerializationKind.ArrayLikeType: write("Array"); break; case ts.TypeReferenceSerializationKind.ESSymbolType: if (languageVersion < 2 /* ES6 */) { write("typeof Symbol === 'function' ? Symbol : Object"); } else { write("Symbol"); } break; case ts.TypeReferenceSerializationKind.TypeWithCallSignature: write("Function"); break; case ts.TypeReferenceSerializationKind.ObjectType: write("Object"); break; } }
Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator.
emitSerializedTypeReferenceNode
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitSerializedParameterTypesOfNode(node) { // serialization of parameter types uses the following rules: // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; if (node.kind === 214 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { valueDeclaration = node; } if (valueDeclaration) { var parameters = valueDeclaration.parameters; var parameterCount = parameters.length; if (parameterCount > 0) { for (var i = 0; i < parameterCount; i++) { if (i > 0) { write(", "); } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; if (parameterType.kind === 156 /* ArrayType */) { parameterType = parameterType.elementType; } else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { parameterType = undefined; } emitSerializedTypeNode(parameterType); } else { emitSerializedTypeOfNode(parameters[i]); } } } } } }
Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor.
emitSerializedParameterTypesOfNode
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitSerializedTypeMetadata(node, writeComma) { // This method emits the serialized type metadata for a decorator target. // The caller should have already tested whether the node has decorators. var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { if (writeComma) { write(", "); } writeLine(); write("__metadata('design:type', "); emitSerializedTypeOfNode(node); write(")"); argumentsWritten++; } if (shouldEmitParamTypesMetadata(node)) { if (writeComma || argumentsWritten) { write(", "); } writeLine(); write("__metadata('design:paramtypes', ["); emitSerializedParameterTypesOfNode(node); write("])"); argumentsWritten++; } if (shouldEmitReturnTypeMetadata(node)) { if (writeComma || argumentsWritten) { write(", "); } writeLine(); write("__metadata('design:returntype', "); emitSerializedReturnTypeOfNode(node); write(")"); argumentsWritten++; } } return argumentsWritten; }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitSerializedTypeMetadata
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; }
Serializes the return type of function. Used by the __metadata decorator for a method.
shouldEmitEnumDeclaration
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitEnumDeclaration(node) { // const enums are completely erased during compilation. if (!shouldEmitEnumDeclaration(node)) { return; } if (!shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted if (!(node.flags & 2 /* Export */) || isES6ExportedDeclaration(node)) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); } write("var "); emit(node.name); emitEnd(node); write(";"); } } writeLine(); emitStart(node); write("(function ("); emitStart(node.name); write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") {"); increaseIndent(); scopeEmitStart(node); emitLines(node.members); decreaseIndent(); writeLine(); emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); write(" || ("); emitModuleMemberName(node); write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.flags & 2 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted writeLine(); emitStart(node); write("var "); emit(node.name); write(" = "); emitModuleMemberName(node); emitEnd(node); write(";"); } if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { // write the call to exporter for enum writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); write("\", "); emitDeclarationName(node); write(");"); } emitExportMemberAssignments(node.name); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitEnumDeclaration
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitEnumMember(node) { var enumParent = node.parent; emitStart(node); write(getGeneratedNameForNode(enumParent)); write("["); write(getGeneratedNameForNode(enumParent)); write("["); emitExpressionForPropertyName(node.name); write("] = "); writeEnumMemberDeclarationValue(node); write("] = "); emitExpressionForPropertyName(node.name); emitEnd(node); write(";"); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitEnumMember
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function writeEnumMemberDeclarationValue(member) { var value = resolver.getConstantValue(member); if (value !== undefined) { write(value.toString()); return; } else if (member.initializer) { emit(member.initializer); } else { write("undefined"); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
writeEnumMemberDeclarationValue
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { if (moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } }
Serializes the return type of function. Used by the __metadata decorator for a method.
getInnerMostModuleDeclarationFromDottedModule
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); }
Serializes the return type of function. Used by the __metadata decorator for a method.
shouldEmitModuleDeclaration
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function isModuleMergedWithES6Class(node) { return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); }
Serializes the return type of function. Used by the __metadata decorator for a method.
isModuleMergedWithES6Class
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitModuleDeclaration(node) { // Emit only if this module is non-ambient. var shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { return emitCommentsOnNotEmittedNode(node); } var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); } write("var "); emit(node.name); write(";"); emitEnd(node); writeLine(); } emitStart(node); write("(function ("); emitStart(node.name); write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); if (node.body.kind === 219 /* ModuleBlock */) { var saveConvertedLoopState = convertedLoopState; var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; convertedLoopState = undefined; tempFlags = 0; tempVariables = undefined; emit(node.body); ts.Debug.assert(convertedLoopState === undefined); convertedLoopState = saveConvertedLoopState; tempFlags = saveTempFlags; tempVariables = saveTempVariables; } else { write("{"); increaseIndent(); scopeEmitStart(node); emitCaptureThisForNodeIfNecessary(node); writeLine(); emit(node.body); decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); // write moduleDecl = containingModule.m only if it is not exported es6 module member if ((node.flags & 2 /* Export */) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } emitModuleMemberName(node); write(" || ("); emitModuleMemberName(node); write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); write("\", "); emitDeclarationName(node); write(");"); } emitExportMemberAssignments(node.name); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitModuleDeclaration
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function tryRenameExternalModule(moduleName) { if (renamedDependencies && ts.hasProperty(renamedDependencies, moduleName.text)) { return "\"" + renamedDependencies[moduleName.text] + "\""; } return undefined; }
Serializes the return type of function. Used by the __metadata decorator for a method.
tryRenameExternalModule
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitRequire(moduleName) { if (moduleName.kind === 9 /* StringLiteral */) { write("require("); var text = tryRenameExternalModule(moduleName); if (text) { write(text); } else { emitStart(moduleName); emitLiteral(moduleName); emitEnd(moduleName); } emitToken(18 /* CloseParenToken */, moduleName.end); } else { write("require()"); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitRequire
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function getNamespaceDeclarationNode(node) { if (node.kind === 221 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224 /* NamespaceImport */) { return importClause.namedBindings; } }
Serializes the return type of function. Used by the __metadata decorator for a method.
getNamespaceDeclarationNode
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function isDefaultImport(node) { return node.kind === 222 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; }
Serializes the return type of function. Used by the __metadata decorator for a method.
isDefaultImport
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { emitExportMemberAssignments(node.name); } ts.forEachChild(node, emitExportImportAssignments); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitExportImportAssignments
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitImportDeclaration(node) { if (modulekind !== 5 /* ES6 */) { return emitExternalImportDeclaration(node); } // ES6 import if (node.importClause) { var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { write("import "); emitStart(node.importClause); if (shouldEmitDefaultBindings) { emit(node.importClause.name); if (shouldEmitNamedBindings) { write(", "); } } if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } else { write("{ "); emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); write(" }"); } emitEnd(node.importClause.namedBindings); emitTrailingComments(node.importClause.namedBindings); } emitEnd(node.importClause); write(" from "); emit(node.moduleSpecifier); write(";"); } } else { write("import "); emit(node.moduleSpecifier); write(";"); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitImportDeclaration
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2 /* AMD */) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { // import x = require("foo") // import * as x from "foo" if (!isExportedImport) write("var "); emitModuleMemberName(namespaceDeclaration); write(" = "); } else { // import "foo" // import x from "foo" // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" var isNakedImport = 222 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); write(" = "); } } emitRequire(ts.getExternalModuleName(node)); if (namespaceDeclaration && isDefaultImport(node)) { // import d, * as x from "foo" write(", "); emitModuleMemberName(namespaceDeclaration); write(" = "); write(getGeneratedNameForNode(node)); } write(";"); emitEnd(node); emitExportImportAssignments(node); emitTrailingComments(node); } else { if (isExportedImport) { emitModuleMemberName(namespaceDeclaration); write(" = "); emit(namespaceDeclaration.name); write(";"); } else if (namespaceDeclaration && isDefaultImport(node)) { // import d, * as x from "foo" write("var "); emitModuleMemberName(namespaceDeclaration); write(" = "); write(getGeneratedNameForNode(node)); write(";"); } emitExportImportAssignments(node); } } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitExternalImportDeclaration
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { emitExternalImportDeclaration(node); return; } // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when // - current file is not external module // - import declaration is top level and target is value imported by entity name if (resolver.isReferencedAliasDeclaration(node) || (!isCurrentFileExternalModule && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); // variable declaration for import-equals declaration can be hoisted in system modules // in this case 'var' should be omitted and emit should contain only initialization var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); // is it top level export import v = a.b.c in system module? // if yes - it needs to be rewritten as exporter('v', v = a.b.c) var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); if (!variableDeclarationIsHoisted) { ts.Debug.assert(!isExported); if (isES6ExportedDeclaration(node)) { write("export "); write("var "); } else if (!(node.flags & 2 /* Export */)) { write("var "); } } if (isExported) { write(exportFunctionForFile + "(\""); emitNodeWithoutSourceMap(node.name); write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); if (isExported) { write(")"); } write(";"); emitEnd(node); emitExportImportAssignments(node); emitTrailingComments(node); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitImportEqualsDeclaration
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitExportDeclaration(node) { ts.Debug.assert(modulekind !== 4 /* System */); if (modulekind !== 5 /* ES6 */) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); var generatedName = getGeneratedNameForNode(node); if (node.exportClause) { // export { x, y, ... } from "foo" if (modulekind !== 2 /* AMD */) { write("var "); write(generatedName); write(" = "); emitRequire(ts.getExternalModuleName(node)); write(";"); } for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { var specifier = _b[_a]; if (resolver.isValueAliasDeclaration(specifier)) { writeLine(); emitStart(specifier); emitContainingModuleName(specifier); write("."); emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } } } else { // export * from "foo" writeLine(); write("__export("); if (modulekind !== 2 /* AMD */) { emitRequire(ts.getExternalModuleName(node)); } else { write(generatedName); } write(");"); } emitEnd(node); } } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { write("export "); if (node.exportClause) { // export { x, y, ... } write("{ "); emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); write(" }"); } else { write("*"); } if (node.moduleSpecifier) { write(" from "); emit(node.moduleSpecifier); } write(";"); } } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitExportDeclaration
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitExportOrImportSpecifierList(specifiers, shouldEmit) { ts.Debug.assert(modulekind === 5 /* ES6 */); var needsComma = false; for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { var specifier = specifiers_1[_a]; if (shouldEmit(specifier)) { if (needsComma) { write(", "); } if (specifier.propertyName) { emit(specifier.propertyName); write(" as "); } emit(specifier.name); needsComma = true; } } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitExportOrImportSpecifierList
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitExportAssignment(node) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { if (modulekind === 5 /* ES6 */) { writeLine(); emitStart(node); write("export default "); var expression = node.expression; emit(expression); if (expression.kind !== 213 /* FunctionDeclaration */ && expression.kind !== 214 /* ClassDeclaration */) { write(";"); } emitEnd(node); } else { writeLine(); emitStart(node); if (modulekind === 4 /* System */) { write(exportFunctionForFile + "(\"default\","); emit(node.expression); write(")"); } else { emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0 /* ES3 */) { write("[\"default\"] = "); } else { write(".default = "); } emit(node.expression); } write(";"); emitEnd(node); } } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitExportAssignment
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function collectExternalModuleInfo(sourceFile) { externalImports = []; exportSpecifiers = {}; exportEquals = undefined; hasExportStars = false; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { case 222 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" // import x from "mod" where x is referenced // import * as x from "mod" where x is referenced // import { x, y } from "mod" where at least one import is referenced externalImports.push(node); } break; case 221 /* ImportEqualsDeclaration */: if (node.moduleReference.kind === 232 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; case 228 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" externalImports.push(node); hasExportStars = true; } else if (resolver.isValueAliasDeclaration(node)) { // export { x, y } from "mod" where at least one export is a value symbol externalImports.push(node); } } else { // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; var name_26 = (specifier.propertyName || specifier.name).text; (exportSpecifiers[name_26] || (exportSpecifiers[name_26] = [])).push(specifier); } } break; case 227 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; } } }
Serializes the return type of function. Used by the __metadata decorator for a method.
collectExternalModuleInfo
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitExportStarHelper() { if (hasExportStars) { writeLine(); write("function __export(m) {"); increaseIndent(); writeLine(); write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); decreaseIndent(); writeLine(); write("}"); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitExportStarHelper
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function getLocalNameForExternalImport(node) { var namespaceDeclaration = getNamespaceDeclarationNode(node); if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getTextOfNodeFromSourceText(currentText, namespaceDeclaration.name); } if (node.kind === 222 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } if (node.kind === 228 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
getLocalNameForExternalImport
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); if (moduleName.kind === 9 /* StringLiteral */) { return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; }
Serializes the return type of function. Used by the __metadata decorator for a method.
getExternalModuleNameText
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitVariableDeclarationsForImports() { if (externalImports.length === 0) { return; } writeLine(); var started = false; for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { var importNode = externalImports_1[_a]; // do not create variable declaration for exports and imports that lack import clause var skipNode = importNode.kind === 228 /* ExportDeclaration */ || (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } if (!started) { write("var "); started = true; } else { write(", "); } write(getLocalNameForExternalImport(importNode)); } if (started) { write(";"); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitVariableDeclarationsForImports
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { // when resolving exports local exported entries/indirect exported entries in the module // should always win over entries with similar names that were added via star exports // to support this we store names of local/indirect exported entries in a set. // this set is used to filter names brought by star expors. if (!hasExportStars) { // local names set is needed only in presence of star exports return undefined; } // local names set should only be added if we have anything exported if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. var hasExportDeclarationWithExportClause = false; for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { var externalImport = externalImports_2[_a]; if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } } if (!hasExportDeclarationWithExportClause) { // we still need to emit exportStar helper return emitExportStarFunction(/*localNames*/ undefined); } } var exportedNamesStorageRef = makeUniqueName("exportedNames"); writeLine(); write("var " + exportedNamesStorageRef + " = {"); increaseIndent(); var started = false; if (exportedDeclarations) { for (var i = 0; i < exportedDeclarations.length; ++i) { // write name of exported declaration, i.e 'export var x...' writeExportedName(exportedDeclarations[i]); } } if (exportSpecifiers) { for (var n in exportSpecifiers) { for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { var specifier = _c[_b]; // write name of export specified, i.e. 'export {x}' writeExportedName(specifier.name); } } } for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { var externalImport = externalImports_3[_d]; if (externalImport.kind !== 228 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; if (!exportDecl.exportClause) { // export * from ... continue; } for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { var element = _f[_e]; // write name of indirectly exported entry, i.e. 'export {x} from ...' writeExportedName(element.name || element.propertyName); } } decreaseIndent(); writeLine(); write("};"); return emitExportStarFunction(exportedNamesStorageRef); function emitExportStarFunction(localNames) { var exportStarFunction = makeUniqueName("exportStar"); writeLine(); // define an export star helper function write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); write("var exports = {};"); writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); write("if (n !== \"default\""); if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); writeLine(); write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); return exportStarFunction; } function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export if (node.kind !== 69 /* Identifier */ && node.flags & 512 /* Default */) { return; } if (started) { write(","); } else { started = true; } writeLine(); write("'"); if (node.kind === 69 /* Identifier */) { emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); } write("': true"); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitLocalStorageForExportedNamesIfNecessary
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitExportStarFunction(localNames) { var exportStarFunction = makeUniqueName("exportStar"); writeLine(); // define an export star helper function write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); write("var exports = {};"); writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); write("if (n !== \"default\""); if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); writeLine(); write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); return exportStarFunction; }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitExportStarFunction
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export if (node.kind !== 69 /* Identifier */ && node.flags & 512 /* Default */) { return; } if (started) { write(","); } else { started = true; } writeLine(); write("'"); if (node.kind === 69 /* Identifier */) { emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); } write("': true"); }
Serializes the return type of function. Used by the __metadata decorator for a method.
writeExportedName
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function processTopLevelVariableAndFunctionDeclarations(node) { // per ES6 spec: // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method // - var declarations are initialized to undefined - 14.a.ii // - function/generator declarations are instantiated - 16.a.iv // this means that after module is instantiated but before its evaluation // exported functions are already accessible at import sites // in theory we should hoist only exported functions and its dependencies // in practice to simplify things we'll hoist all source level functions and variable declaration // including variables declarations for module and class declarations var hoistedVars; var hoistedFunctionDeclarations; var exportedDeclarations; visit(node); if (hoistedVars) { writeLine(); write("var "); var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; var name_27 = local.kind === 69 /* Identifier */ ? local : local.name; if (name_27) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables var text = ts.unescapeIdentifier(name_27.text); if (ts.hasProperty(seen, text)) { continue; } else { seen[text] = text; } } if (i !== 0) { write(", "); } if (local.kind === 214 /* ClassDeclaration */ || local.kind === 218 /* ModuleDeclaration */ || local.kind === 217 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); if (flags & 2 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } exportedDeclarations.push(local); } } write(";"); } if (hoistedFunctionDeclarations) { for (var _a = 0, hoistedFunctionDeclarations_1 = hoistedFunctionDeclarations; _a < hoistedFunctionDeclarations_1.length; _a++) { var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); if (f.flags & 2 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } exportedDeclarations.push(f); } } } return exportedDeclarations; function visit(node) { if (node.flags & 4 /* Ambient */) { return; } if (node.kind === 213 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } if (node.kind === 214 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } if (node.kind === 217 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); } return; } if (node.kind === 218 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); } return; } if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { var name_28 = node.name; if (name_28.kind === 69 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(name_28); } else { ts.forEachChild(name_28, visit); } } return; } if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node.name); return; } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; } if (!ts.isDeclaration(node)) { ts.forEachChild(node, visit); } } }
Serializes the return type of function. Used by the __metadata decorator for a method.
processTopLevelVariableAndFunctionDeclarations
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function visit(node) { if (node.flags & 4 /* Ambient */) { return; } if (node.kind === 213 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } if (node.kind === 214 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } if (node.kind === 217 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); } return; } if (node.kind === 218 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); } return; } if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { var name_28 = node.name; if (name_28.kind === 69 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(name_28); } else { ts.forEachChild(name_28, visit); } } return; } if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node.name); return; } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; } if (!ts.isDeclaration(node)) { ts.forEachChild(node, visit); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
visit
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { return false; } // hoist variable if // - it is not block scoped // - it is top level block scoped // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) === 0 || ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; }
Serializes the return type of function. Used by the __metadata decorator for a method.
shouldHoistVariable
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function isCurrentFileSystemExternalModule() { return modulekind === 4 /* System */ && isCurrentFileExternalModule; }
Serializes the return type of function. Used by the __metadata decorator for a method.
isCurrentFileSystemExternalModule
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: // function (exports) { // <list of local aliases for imports> // <hoisted function declarations> // <hoisted variable declarations> // return { // setters: [ // <list of setter function for imports> // ], // execute: function() { // <module statements> // } // } // <temp declarations> // } // I.e: // import {x} from 'file1' // var y = 1; // export function foo() { return y + x(); } // console.log(y); // will be transformed to // function(exports) { // var file1; // local alias // var y; // function foo() { return y + file1.x(); } // exports("foo", foo); // return { // setters: [ // function(v) { file1 = v } // ], // execute(): function() { // y = 1; // console.log(y); // } // }; // } emitVariableDeclarationsForImports(); writeLine(); var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); writeLine(); write("return {"); increaseIndent(); writeLine(); emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); writeLine(); write("}"); // return emitTempDeclarations(/*newLine*/ true); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitSystemModuleBody
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); var group = dependencyGroups[i]; // derive a unique name for parameter from the first named entry in the group var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); increaseIndent(); for (var _a = 0, group_1 = group; _a < group_1.length; _a++) { var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { case 222 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through case 221 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); break; case 228 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { // export {a, b as c} from 'foo' // emit as: // exports_({ // "a": _["a"], // "c": _["b"] // }); writeLine(); write(exportFunctionForFile + "({"); writeLine(); increaseIndent(); for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { if (i_2 !== 0) { write(","); writeLine(); } var e = entry.exportClause.elements[i_2]; write("\""); emitNodeWithCommentsAndWithoutSourcemap(e.name); write("\": " + parameterName + "[\""); emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); write("\"]"); } decreaseIndent(); writeLine(); write("});"); } else { writeLine(); // export * from 'foo' // emit as: // exportStar(_foo); write(exportStarFunction + "(" + parameterName + ");"); } writeLine(); break; } } decreaseIndent(); write("}"); decreaseIndent(); } write("],"); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitSetters
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitExecute(node, startIndex) { write("execute: function() {"); increaseIndent(); writeLine(); for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { // - function declarations are not emitted because they were already hoisted // - import declarations are not emitted since they are already handled in setters // - export declarations with module specifiers are not emitted since they were already written in setters // - export declarations without module specifiers are emitted preserving the order case 213 /* FunctionDeclaration */: case 222 /* ImportDeclaration */: continue; case 228 /* ExportDeclaration */: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; // write call to exporter function for every export specifier in exports list emitExportSpecifierInSystemModule(element); } } continue; case 221 /* ImportEqualsDeclaration */: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { // - import equals declarations that import external modules are not emitted continue; } // fall-though for import declarations that import internal modules default: writeLine(); emit(statement); } } decreaseIndent(); writeLine(); write("}"); // execute }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitExecute
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function writeModuleName(node, emitRelativePathAsModuleName) { var moduleName = node.moduleName; if (moduleName || (emitRelativePathAsModuleName && (moduleName = getResolvedExternalModuleName(host, node)))) { write("\"" + moduleName + "\", "); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
writeModuleName
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitSystemModule(node, emitRelativePathAsModuleName) { collectExternalModuleInfo(node); // System modules has the following shape // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) // 'exports' here is a function 'exports<T>(name: string, value: T): T' that is used to publish exported values. // 'exports' returns its 'value' argument so in most cases expressions // that mutate exported values can be rewritten as: // expr -> exports('name', expr). // The only exception in this rule is postfix unary operators, // see comment to 'emitPostfixUnaryExpression' for more details ts.Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); writeLine(); write("System.register("); writeModuleName(node, emitRelativePathAsModuleName); write("["); var groupIndices = {}; var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); if (ts.hasProperty(groupIndices, text)) { // deduplicate/group entries in dependency list by the dependency name var groupIndex = groupIndices[text]; dependencyGroups[groupIndex].push(externalImports[i]); continue; } else { groupIndices[text] = dependencyGroups.length; dependencyGroups.push([externalImports[i]]); } if (i !== 0) { write(", "); } if (emitRelativePathAsModuleName) { var name_29 = getExternalModuleNameFromDeclaration(host, resolver, externalImports[i]); if (name_29) { text = "\"" + name_29 + "\""; } } write(text); } write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitSystemModule
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function getAMDDependencyNames(node, includeNonAmdDependencies, emitRelativePathAsModuleName) { // names of modules with corresponding parameter in the factory function var aliasedModuleNames = []; // names of modules with no corresponding parameters in factory function var unaliasedModuleNames = []; var importAliasNames = []; // names of the parameters in the factory function; these // parameters need to match the indexes of the corresponding // module names in aliasedModuleNames. // Fill in amd-dependency tags for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { var amdDependency = _b[_a]; if (amdDependency.name) { aliasedModuleNames.push("\"" + amdDependency.path + "\""); importAliasNames.push(amdDependency.name); } else { unaliasedModuleNames.push("\"" + amdDependency.path + "\""); } } for (var _c = 0, externalImports_4 = externalImports; _c < externalImports_4.length; _c++) { var importNode = externalImports_4[_c]; // Find the name of the external module var externalModuleName = getExternalModuleNameText(importNode); if (emitRelativePathAsModuleName) { var name_30 = getExternalModuleNameFromDeclaration(host, resolver, importNode); if (name_30) { externalModuleName = "\"" + name_30 + "\""; } } // Find the name of the module alias, if there is one var importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); } else { unaliasedModuleNames.push(externalModuleName); } } return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; }
Serializes the return type of function. Used by the __metadata decorator for a method.
getAMDDependencyNames
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitAMDDependencies(node, includeNonAmdDependencies, emitRelativePathAsModuleName) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); // // This has the shape of // define(name, ["module1", "module2"], function (module1Alias) { // The location of the alias in the parameter list in the factory function needs to // match the position of the module name in the dependency list. // // To ensure this is true in cases of modules with no aliases, e.g.: // `import "module"` or `<amd-dependency path= "a.css" />` // we need to add modules without alias names to the end of the dependencies list var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies, emitRelativePathAsModuleName); emitAMDDependencyList(dependencyNames); write(", "); emitAMDFactoryHeader(dependencyNames); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitAMDDependencies
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitAMDDependencyList(_a) { var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); write(aliasedModuleNames.join(", ")); } if (unaliasedModuleNames.length) { write(", "); write(unaliasedModuleNames.join(", ")); } write("]"); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitAMDDependencyList
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitAMDFactoryHeader(_a) { var importAliasNames = _a.importAliasNames; write("function (require, exports"); if (importAliasNames.length) { write(", "); write(importAliasNames.join(", ")); } write(") {"); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitAMDFactoryHeader
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitAMDModule(node, emitRelativePathAsModuleName) { emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); writeModuleName(node, emitRelativePathAsModuleName); emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName); increaseIndent(); var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitAMDModule
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitCommonJSModule(node) { var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); emitExportEquals(/*emitAsReturn*/ false); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitCommonJSModule
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitUMDModule(node) { emitEmitHelpers(node); collectExternalModuleInfo(node); var dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); // Module is detected first to support Browserify users that load into a browser with an AMD loader writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); emitAMDDependencyList(dependencyNames); write(", factory);"); writeLines(" }\n})("); emitAMDFactoryHeader(dependencyNames); increaseIndent(); var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitUMDModule
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitES6Module(node) { externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); // Emit exportDefault if it exists will happen as part // or normal statement emit. }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitES6Module
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitExportEquals(emitAsReturn) { if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { writeLine(); emitStart(exportEquals); write(emitAsReturn ? "return " : "module.exports = "); emit(exportEquals.expression); write(";"); emitEnd(exportEquals); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitExportEquals
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitJsxElement(node) { switch (compilerOptions.jsx) { case 2 /* React */: jsxEmitReact(node); break; case 1 /* Preserve */: // Fall back to preserve if None was specified (we'll error earlier) default: jsxEmitPreserve(node); break; } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitJsxElement
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; var text = ts.getTextOfNode(node, /*includeTrivia*/ true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; // JSX trims whitespace at the end and beginning of lines, except that the // start/end of a tag is considered a start/end of a line only if that line is // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx for (var i = 0; i < text.length; i++) { var c = text.charCodeAt(i); if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); } firstNonWhitespace = -1; } else if (!ts.isWhiteSpace(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); } if (result) { // Replace entities like &nbsp; result = result.replace(/&(\w+);/g, function (s, m) { if (entities[m] !== undefined) { return String.fromCharCode(entities[m]); } else { return s; } }); } return result; }
Serializes the return type of function. Used by the __metadata decorator for a method.
trimReactWhitespaceAndApplyEntities
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2 /* React */: var text = trimReactWhitespaceAndApplyEntities(node); if (text === undefined || text.length === 0) { return undefined; } else { return text; } case 1 /* Preserve */: default: return ts.getTextOfNode(node, /*includeTrivia*/ true); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
getTextToEmit
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitJsxText(node) { switch (compilerOptions.jsx) { case 2 /* React */: write("\""); write(trimReactWhitespaceAndApplyEntities(node)); write("\""); break; case 1 /* Preserve */: default: writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); break; } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitJsxText
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitJsxExpression(node) { if (node.expression) { switch (compilerOptions.jsx) { case 1 /* Preserve */: default: write("{"); emit(node.expression); write("}"); break; case 2 /* React */: emit(node.expression); break; } } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitJsxExpression
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitDirectivePrologues(statements, startWithNewLine) { for (var i = 0; i < statements.length; ++i) { if (ts.isPrologueDirective(statements[i])) { if (startWithNewLine || i > 0) { writeLine(); } emit(statements[i]); } else { // return index of the first non prologue directive return i; } } return statements.length; }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitDirectivePrologues
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function writeLines(text) { var lines = text.split(/\r\n|\r|\n/g); for (var i = 0; i < lines.length; ++i) { var line = lines[i]; if (line.length) { writeLine(); write(line); } } }
Serializes the return type of function. Used by the __metadata decorator for a method.
writeLines
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitEmitHelpers(node) { // Only emit helpers if the user did not say otherwise. if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { writeLines(extendsHelper); extendsEmitted = true; } if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { writeLines(paramHelper); paramEmitted = true; } if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { writeLines(awaiterHelper); awaiterEmitted = true; } } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitEmitHelpers
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitSourceFileNode(node) { // Start new file on new line writeLine(); emitShebang(); emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (root || (!ts.isExternalModule(node) && compilerOptions.isolatedModules)) { var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; emitModule(node); } else { bundleEmitDelegates[modulekind](node, /*emitRelativePathAsModuleName*/ true); } } else { // emit prologue directives prior to __extends var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); } emitLeadingComments(node.endOfFileToken); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitSourceFileNode
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitNodeWithCommentsAndWithoutSourcemap(node) { emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitNodeWithCommentsAndWithoutSourcemap
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { if (node.flags & 4 /* Ambient */) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { // This is the node that will handle its own comments and sourcemap return emitNodeWithoutSourceMap(node); } var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); if (emitComments_1) { emitLeadingComments(node); } emitNodeConsideringSourcemap(node); if (emitComments_1) { emitTrailingComments(node); } } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitNodeConsideringCommentsOption
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitNodeWithoutSourceMap(node) { if (node) { emitJavaScriptWorker(node); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitNodeWithoutSourceMap
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function isSpecializedCommentHandling(node) { switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. case 215 /* InterfaceDeclaration */: case 213 /* FunctionDeclaration */: case 222 /* ImportDeclaration */: case 221 /* ImportEqualsDeclaration */: case 216 /* TypeAliasDeclaration */: case 227 /* ExportAssignment */: return true; } }
Serializes the return type of function. Used by the __metadata decorator for a method.
isSpecializedCommentHandling
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { case 193 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); case 218 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); case 217 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } // If the node is emitted in specialized fashion, dont emit comments as this node will handle // emitting comments when emitting itself ts.Debug.assert(!isSpecializedCommentHandling(node)); // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. if (node.kind !== 192 /* Block */ && node.parent && node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; } // Emit comments for everything else. return true; }
Serializes the return type of function. Used by the __metadata decorator for a method.
shouldEmitLeadingAndTrailingComments
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { case 69 /* Identifier */: return emitIdentifier(node); case 138 /* Parameter */: return emitParameter(node); case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: return emitMethod(node); case 145 /* GetAccessor */: case 146 /* SetAccessor */: return emitAccessor(node); case 97 /* ThisKeyword */: return emitThis(node); case 95 /* SuperKeyword */: return emitSuper(node); case 93 /* NullKeyword */: return write("null"); case 99 /* TrueKeyword */: return write("true"); case 84 /* FalseKeyword */: return write("false"); case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 10 /* RegularExpressionLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: case 12 /* TemplateHead */: case 13 /* TemplateMiddle */: case 14 /* TemplateTail */: return emitLiteral(node); case 183 /* TemplateExpression */: return emitTemplateExpression(node); case 190 /* TemplateSpan */: return emitTemplateSpan(node); case 233 /* JsxElement */: case 234 /* JsxSelfClosingElement */: return emitJsxElement(node); case 236 /* JsxText */: return emitJsxText(node); case 240 /* JsxExpression */: return emitJsxExpression(node); case 135 /* QualifiedName */: return emitQualifiedName(node); case 161 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); case 162 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); case 163 /* BindingElement */: return emitBindingElement(node); case 164 /* ArrayLiteralExpression */: return emitArrayLiteral(node); case 165 /* ObjectLiteralExpression */: return emitObjectLiteral(node); case 245 /* PropertyAssignment */: return emitPropertyAssignment(node); case 246 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); case 136 /* ComputedPropertyName */: return emitComputedPropertyName(node); case 166 /* PropertyAccessExpression */: return emitPropertyAccess(node); case 167 /* ElementAccessExpression */: return emitIndexedAccess(node); case 168 /* CallExpression */: return emitCallExpression(node); case 169 /* NewExpression */: return emitNewExpression(node); case 170 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); case 171 /* TypeAssertionExpression */: return emit(node.expression); case 189 /* AsExpression */: return emit(node.expression); case 172 /* ParenthesizedExpression */: return emitParenExpression(node); case 213 /* FunctionDeclaration */: case 173 /* FunctionExpression */: case 174 /* ArrowFunction */: return emitFunctionDeclaration(node); case 175 /* DeleteExpression */: return emitDeleteExpression(node); case 176 /* TypeOfExpression */: return emitTypeOfExpression(node); case 177 /* VoidExpression */: return emitVoidExpression(node); case 178 /* AwaitExpression */: return emitAwaitExpression(node); case 179 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); case 180 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); case 181 /* BinaryExpression */: return emitBinaryExpression(node); case 182 /* ConditionalExpression */: return emitConditionalExpression(node); case 185 /* SpreadElementExpression */: return emitSpreadElementExpression(node); case 184 /* YieldExpression */: return emitYieldExpression(node); case 187 /* OmittedExpression */: return; case 192 /* Block */: case 219 /* ModuleBlock */: return emitBlock(node); case 193 /* VariableStatement */: return emitVariableStatement(node); case 194 /* EmptyStatement */: return write(";"); case 195 /* ExpressionStatement */: return emitExpressionStatement(node); case 196 /* IfStatement */: return emitIfStatement(node); case 197 /* DoStatement */: return emitDoStatement(node); case 198 /* WhileStatement */: return emitWhileStatement(node); case 199 /* ForStatement */: return emitForStatement(node); case 201 /* ForOfStatement */: case 200 /* ForInStatement */: return emitForInOrForOfStatement(node); case 202 /* ContinueStatement */: case 203 /* BreakStatement */: return emitBreakOrContinueStatement(node); case 204 /* ReturnStatement */: return emitReturnStatement(node); case 205 /* WithStatement */: return emitWithStatement(node); case 206 /* SwitchStatement */: return emitSwitchStatement(node); case 241 /* CaseClause */: case 242 /* DefaultClause */: return emitCaseOrDefaultClause(node); case 207 /* LabeledStatement */: return emitLabeledStatement(node); case 208 /* ThrowStatement */: return emitThrowStatement(node); case 209 /* TryStatement */: return emitTryStatement(node); case 244 /* CatchClause */: return emitCatchClause(node); case 210 /* DebuggerStatement */: return emitDebuggerStatement(node); case 211 /* VariableDeclaration */: return emitVariableDeclaration(node); case 186 /* ClassExpression */: return emitClassExpression(node); case 214 /* ClassDeclaration */: return emitClassDeclaration(node); case 215 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); case 217 /* EnumDeclaration */: return emitEnumDeclaration(node); case 247 /* EnumMember */: return emitEnumMember(node); case 218 /* ModuleDeclaration */: return emitModuleDeclaration(node); case 222 /* ImportDeclaration */: return emitImportDeclaration(node); case 221 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); case 228 /* ExportDeclaration */: return emitExportDeclaration(node); case 227 /* ExportAssignment */: return emitExportAssignment(node); case 248 /* SourceFile */: return emitSourceFileNode(node); } }
Serializes the return type of function. Used by the __metadata decorator for a method.
emitJavaScriptWorker
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function hasDetachedComments(pos) { return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; }
Serializes the return type of function. Used by the __metadata decorator for a method.
hasDetachedComments
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function getLeadingCommentsWithoutDetachedComments() { // get the leading comments from detachedPos var leadingComments = ts.getLeadingCommentRanges(currentText, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } else { detachedCommentsInfo = undefined; } return leadingComments; }
Serializes the return type of function. Used by the __metadata decorator for a method.
getLeadingCommentsWithoutDetachedComments
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function isTripleSlashComment(comment) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments if (currentText.charCodeAt(comment.pos + 1) === 47 /* slash */ && comment.pos + 2 < comment.end && currentText.charCodeAt(comment.pos + 2) === 47 /* slash */) { var textSubStr = currentText.substring(comment.pos, comment.end); return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? true : false; } return false; }
Determine if the given comment is a triple-slash @return true if the comment is a triple-slash comment else false
isTripleSlashComment
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { if (node.parent.kind === 248 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); } else { // get the leading comments from the node return ts.getLeadingCommentRangesOfNodeFromText(node, currentText); } } } }
Determine if the given comment is a triple-slash @return true if the comment is a triple-slash comment else false
getLeadingCommentsToEmit
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { if (node.parent.kind === 248 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentText, node.end); } } }
Determine if the given comment is a triple-slash @return true if the comment is a triple-slash comment else false
getTrailingCommentsToEmit
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { if (ts.sys.fileExists(fileName)) { return fileName; } var parentPath = ts.getDirectoryPath(searchPath); if (parentPath === searchPath) { break; } searchPath = parentPath; fileName = "../" + fileName; } return undefined; }
The version of the TypeScript compiler release
findConfigFile
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function resolveTripleslashReference(moduleName, containingFile) { var basePath = ts.getDirectoryPath(containingFile); var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); return ts.normalizePath(referencedFileName); }
The version of the TypeScript compiler release
resolveTripleslashReference
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function resolveModuleName(moduleName, containingFile, compilerOptions, host) { var moduleResolution = compilerOptions.moduleResolution !== undefined ? compilerOptions.moduleResolution : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; switch (moduleResolution) { case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); } }
The version of the TypeScript compiler release
resolveModuleName
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function nodeModuleNameResolver(moduleName, containingFile, host) { var containingDirectory = ts.getDirectoryPath(containingFile); if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolvedFileName = loadNodeModuleFromFile(ts.supportedJsExtensions, candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } resolvedFileName = loadNodeModuleFromDirectory(ts.supportedJsExtensions, candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; } else { return loadModuleFromNodeModules(moduleName, containingDirectory, host); } }
The version of the TypeScript compiler release
nodeModuleNameResolver
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function loadNodeModuleFromFile(extensions, candidate, failedLookupLocation, host) { return ts.forEach(extensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { return fileName; } else { failedLookupLocation.push(fileName); return undefined; } } }
The version of the TypeScript compiler release
loadNodeModuleFromFile
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT
function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { return fileName; } else { failedLookupLocation.push(fileName); return undefined; } }
The version of the TypeScript compiler release
tryLoad
javascript
amol-/dukpy
dukpy/jsmodules/typescriptServices.js
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
MIT