_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q1500
isSymbolAccessible
train
function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) { if (symbol && enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { var initialSymbol = symbol; var meaningToLook = meaning; while (symbol...
javascript
{ "resource": "" }
q1501
appendPropertyOrElementAccessForSymbol
train
function appendPropertyOrElementAccessForSymbol(symbol, writer) { var symbolName = getNameOfSymbol(symbol); var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { ...
javascript
{ "resource": "" }
q1502
buildSymbolDisplay
train
function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { var parentSymbol; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { // Write type arguments of instantiated class/interfa...
javascript
{ "resource": "" }
q1503
pushTypeResolution
train
function pushTypeResolution(target, propertyName) { var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { // A cycle was found var length_2 = resolutionTargets.length; for (var i ...
javascript
{ "resource": "" }
q1504
getTypeForBindingElement
train
function getTypeForBindingElement(declaration) { var pattern = declaration.parent; var parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element if (parentType === unknownType) { ...
javascript
{ "resource": "" }
q1505
getTypeForVariableLikeDeclaration
train
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 134217728 /* JavaScriptFile */) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has // one as its type), otherwise fallback to the below stand...
javascript
{ "resource": "" }
q1506
getTypeFromBindingElement
train
function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { return checkExpressionCached(element.initializer); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, in...
javascript
{ "resource": "" }
q1507
getTypeFromObjectBindingPattern
train
function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createMap(); var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (isComputedNonL...
javascript
{ "resource": "" }
q1508
getTypeFromArrayBindingPattern
train
function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType;...
javascript
{ "resource": "" }
q1509
appendTypeParameters
train
function appendTypeParameters(typeParameters, declarations) { for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!...
javascript
{ "resource": "" }
q1510
appendOuterTypeParameters
train
function appendOuterTypeParameters(typeParameters, node) { while (true) { node = node.parent; if (!node) { return typeParameters; } if (node.kind === 221 /* ClassDeclaration */ || node.kind === 192 /* ClassExpression */ || ...
javascript
{ "resource": "" }
q1511
getOuterTypeParametersOfClassOrInterface
train
function getOuterTypeParametersOfClassOrInterface(symbol) { var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 222 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); }
javascript
{ "resource": "" }
q1512
isIndependentInterface
train
function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (declaration.kind === 222 /* InterfaceDeclaration */) { if (declaration.flags & 16384 /* ContainsThis */) { ...
javascript
{ "resource": "" }
q1513
isIndependentType
train
function isIndependentType(node) { switch (node.kind) { case 117 /* AnyKeyword */: case 132 /* StringKeyword */: case 130 /* NumberKeyword */: case 120 /* BooleanKeyword */: case 133 /* SymbolKeyword */: case 103...
javascript
{ "resource": "" }
q1514
isIndependentMember
train
function isIndependentMember(symbol) { if (symbol.declarations && symbol.declarations.length === 1) { var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { case 145 /* PropertyDeclaration */: ...
javascript
{ "resource": "" }
q1515
createInstantiatedSymbolTable
train
function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = ts.createMap(); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; result[symbol.name] = mappingThisOnly && isIndependentMember(sy...
javascript
{ "resource": "" }
q1516
getUnionSignatures
train
function getUnionSignatures(types, kind) { var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); var result = undefined; for (var i = 0; i < signatureLists.length; i++) { for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i+...
javascript
{ "resource": "" }
q1517
getApparentTypeOfTypeParameter
train
function getApparentTypeOfTypeParameter(type) { if (!type.resolvedApparentType) { var constraintType = getConstraintOfTypeParameter(type); while (constraintType && constraintType.flags & 16384 /* TypeParameter */) { constraintType = getConstraintOfTypePara...
javascript
{ "resource": "" }
q1518
getApparentType
train
function getApparentType(type) { if (type.flags & 16384 /* TypeParameter */) { type = getApparentTypeOfTypeParameter(type); } if (type.flags & 34 /* StringLike */) { type = globalStringType; } else if (type.flags & 340 /* Number...
javascript
{ "resource": "" }
q1519
getPropagatingFlagsOfTypes
train
function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { var type = types_3[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } ...
javascript
{ "resource": "" }
q1520
getUnionTypeFromSortedList
train
function getUnionTypeFromSortedList(types, aliasSymbol, aliasTypeArguments) { if (types.length === 0) { return neverType; } if (types.length === 1) { return types[0]; } var id = getTypeListId(types); var type = union...
javascript
{ "resource": "" }
q1521
isKnownProperty
train
function isKnownProperty(type, name) { if (type.flags & 2588672 /* ObjectType */) { var resolved = resolveStructuredTypeMembers(type); if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resol...
javascript
{ "resource": "" }
q1522
objectTypeRelatedTo
train
function objectTypeRelatedTo(source, originalSource, target, reportErrors) { if (overflow) { return 0 /* False */; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; ...
javascript
{ "resource": "" }
q1523
signatureRelatedTo
train
function signatureRelatedTo(source, target, reportErrors) { return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); }
javascript
{ "resource": "" }
q1524
isAbstractConstructorType
train
function isAbstractConstructorType(type) { if (type.flags & 2097152 /* Anonymous */) { var symbol = type.symbol; if (symbol && symbol.flags & 32 /* Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); if (declaration &...
javascript
{ "resource": "" }
q1525
isObjectLiteralType
train
function isObjectLiteralType(type) { return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */)) !== 0 && getSignaturesOfType(type, 0 /* Call */).length === 0 && getSignaturesOfType(type, 1 /* Construct */).length === 0; }
javascript
{ "resource": "" }
q1526
getRegularTypeOfObjectLiteral
train
function getRegularTypeOfObjectLiteral(type) { if (!(type.flags & 16777216 /* FreshObjectLiteral */)) { return type; } var regularType = type.regularType; if (regularType) { return regularType; } var resolved = type;...
javascript
{ "resource": "" }
q1527
removeTypesFromUnionOrIntersection
train
function removeTypesFromUnionOrIntersection(type, typesToRemove) { var reducedTypes = []; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (!typeIdenticalToSomeType(t, typesToRemove)) { reducedTypes.push(t); ...
javascript
{ "resource": "" }
q1528
getResolvedSymbol
train
function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && resolveName(node, node.text, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node) || unknownSymbol...
javascript
{ "resource": "" }
q1529
containsMatchingReferenceDiscriminant
train
function containsMatchingReferenceDiscriminant(source, target) { return target.kind === 172 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); ...
javascript
{ "resource": "" }
q1530
getAssignmentReducedType
train
function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); if (reducedType !== neverType) { return reduce...
javascript
{ "resource": "" }
q1531
narrowType
train
function narrowType(type, expr, assumeTrue) { switch (expr.kind) { case 69 /* Identifier */: case 97 /* ThisKeyword */: case 172 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); ...
javascript
{ "resource": "" }
q1532
isParameterAssigned
train
function isParameterAssigned(symbol) { var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(func); if (!(links.flags & 4194304 /* AssignmentsMarked */)) { links.flags |= 4194304 /* AssignmentsMarked */; if (!hasPar...
javascript
{ "resource": "" }
q1533
getSuperCallInConstructor
train
function getSuperCallInConstructor(constructor) { var links = getNodeLinks(constructor); // Only trying to find super-call if we haven't yet tried to find one. Once we try, we will record the result if (links.hasSuperCall === undefined) { links.superCall = findFirstS...
javascript
{ "resource": "" }
q1534
classDeclarationExtendsNull
train
function classDeclarationExtendsNull(classDecl) { var classSymbol = getSymbolOfNode(classDecl); var classInstanceType = getDeclaredTypeOfSymbol(classSymbol); var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType); return baseConstructorType === nullWid...
javascript
{ "resource": "" }
q1535
getContextuallyTypedParameterType
train
function getContextuallyTypedParameterType(parameter) { var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife) { var indexOfParameter = ts...
javascript
{ "resource": "" }
q1536
getContextualTypeForInitializerExpression
train
function getContextualTypeForInitializerExpression(node) { var declaration = node.parent; if (node === declaration.initializer) { if (declaration.type) { return getTypeFromTypeNode(declaration.type); } if (declaration.kind === 1...
javascript
{ "resource": "" }
q1537
getContextualTypeForArgument
train
function getContextualTypeForArgument(callTarget, arg) { var args = getEffectiveCallArguments(callTarget); var argIndex = ts.indexOf(args, arg); if (argIndex >= 0) { var signature = getResolvedOrAnySignature(callTarget); return getTypeAtPosition(signat...
javascript
{ "resource": "" }
q1538
contextualTypeIsTupleLikeType
train
function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 524288 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); }
javascript
{ "resource": "" }
q1539
getContextualSignature
train
function getContextualSignature(node) { ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; } if (!(type.flag...
javascript
{ "resource": "" }
q1540
isJsxIntrinsicIdentifier
train
function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment if (tagName.kind === 172 /* PropertyAccessExpression */ || tagName.kind === 97 /* ThisKeyword */) { return false; } else { return ts.isIntrinsicJsxName(tagName.text); ...
javascript
{ "resource": "" }
q1541
checkClassPropertyAccess
train
function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); var errorNode = node.kind === 172 /* PropertyAccessExpression */ || node.kind === 218 /* VariableDeclara...
javascript
{ "resource": "" }
q1542
getForInVariableSymbol
train
function getForInVariableSymbol(node) { var initializer = node.initializer; if (initializer.kind === 219 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return ...
javascript
{ "resource": "" }
q1543
getSingleCallSignature
train
function getSingleCallSignature(type) { if (type.flags & 2588672 /* ObjectType */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === ...
javascript
{ "resource": "" }
q1544
getEffectiveDecoratorFirstArgumentType
train
function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. if (node.kind === 221 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" sid...
javascript
{ "resource": "" }
q1545
getEffectiveArgumentType
train
function getEffectiveArgumentType(node, argIndex, arg) { // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors if (node.kind === 143 /* Deco...
javascript
{ "resource": "" }
q1546
getResolvedSignature
train
function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); // If getResolvedSignature has already been called, we will have cached the resolvedSignature. // However, it is possible that either candidatesOutArray was not passed in the first time, ...
javascript
{ "resource": "" }
q1547
checkCallExpression
train
function checkCallExpression(node) { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); if (nod...
javascript
{ "resource": "" }
q1548
maybeTypeOfKind
train
function maybeTypeOfKind(type, kind) { if (type.flags & kind) { return true; } if (type.flags & 1572864 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { ...
javascript
{ "resource": "" }
q1549
isTypeOfKind
train
function isTypeOfKind(type, kind) { if (type.flags & kind) { return true; } if (type.flags & 524288 /* Union */) { var types = type.types; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var t = type...
javascript
{ "resource": "" }
q1550
checkForDisallowedESSymbolOperand
train
function checkForDisallowedESSymbolOperand(operator) { var offendingSymbolOperand = maybeTypeOfKind(leftType, 512 /* ESSymbol */) ? left : maybeTypeOfKind(rightType, 512 /* ESSymbol */) ? right : undefined; if (offendingSymbolOperand) { ...
javascript
{ "resource": "" }
q1551
checkTypeParameter
train
function checkTypeParameter(node) { // Grammar Checking if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); getConstraintOfTypeParameter(getDeclaredTypeOfTypePar...
javascript
{ "resource": "" }
q1552
getPromisedType
train
function getPromisedType(promise) { // // { // promise // then( // thenFunction // onfulfilled: ( // onfulfilledParameterType // value: T // valueParameterType // ) => any // ): any; ...
javascript
{ "resource": "" }
q1553
checkAsyncFunctionReturnType
train
function checkAsyncFunctionReturnType(node) { if (languageVersion >= 2 /* ES6 */) { var returnType = getTypeFromTypeNode(node.type); return checkCorrectPromiseType(returnType, node.type); } var globalPromiseConstructorLikeType = getGlobalPromiseConstru...
javascript
{ "resource": "" }
q1554
checkDecorators
train
function checkDecorators(node) { if (!node.decorators) { return; } // skip this check for nodes that cannot have decorators. These should have already had an error reported by // checkGrammarDecorators. if (!ts.nodeCanBeDecorated(node)) { ...
javascript
{ "resource": "" }
q1555
checkParameterInitializer
train
function checkParameterInitializer(node) { if (ts.getRootDeclaration(node).kind !== 142 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { if (ts.isTypeNode(n) ||...
javascript
{ "resource": "" }
q1556
checkTypeParameterListsIdentical
train
function checkTypeParameterListsIdentical(node, symbol) { if (symbol.declarations.length === 1) { return; } var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (decl...
javascript
{ "resource": "" }
q1557
checkSourceFileWorker
train
function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { // If skipLibCheck is enabled, skip type checking if file is a declaration file. // If skipDefaultLibCheck is enabled, skip type checking if file con...
javascript
{ "resource": "" }
q1558
isInsideWithStatementBody
train
function isInsideWithStatementBody(node) { if (node) { while (node.parent) { if (node.parent.kind === 212 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; ...
javascript
{ "resource": "" }
q1559
copySymbol
train
function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; // We will copy all symbol regardless of its reserved name because // symbolsToArray will check whether the key is a reserved name and ...
javascript
{ "resource": "" }
q1560
isTypeReferenceIdentifier
train
function isTypeReferenceIdentifier(entityName) { var node = entityName; while (node.parent && node.parent.kind === 139 /* QualifiedName */) { node = node.parent; } return node.parent && (node.parent.kind === 155 /* TypeReference */ || node.parent.kind === ...
javascript
{ "resource": "" }
q1561
getExportSpecifierLocalTargetSymbol
train
function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Al...
javascript
{ "resource": "" }
q1562
getReferencedDeclarationWithCollidingName
train
function getReferencedDeclarationWithCollidingName(node) { var symbol = getReferencedValueSymbol(node); return symbol && isSymbolOfDeclarationWithCollidingName(symbol) ? symbol.valueDeclaration : undefined; }
javascript
{ "resource": "" }
q1563
encodeLastRecordedSourceMapSpan
train
function encodeLastRecordedSourceMapSpan() { if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { return; } var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; // Line/Comma delimiters i...
javascript
{ "resource": "" }
q1564
getExportDefaultTempVariableName
train
function getExportDefaultTempVariableName() { var baseName = "_default"; if (!(baseName in currentIdentifiers)) { return baseName; } var count = 0; while (true) { count++; var name_23 = baseName + "_" + count; ...
javascript
{ "resource": "" }
q1565
writeReferencePath
train
function writeReferencePath(referencedFile, addBundledFileReference, emitOnlyDtsFiles) { var declFileName; var addedBundledEmitReference = false; if (ts.isDeclarationFile(referencedFile)) { // Declaration file, use declaration file name declFileName = ...
javascript
{ "resource": "" }
q1566
emitFiles
train
function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { // emit output for the __extends helper function var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor...
javascript
{ "resource": "" }
q1567
makeTempVariableName
train
function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { var name_24 = flags === 268435456 /* _i */ ? "_i" : "_n"; if (isUniqueName(name_24)) { tempFlags |= flags; return name_24; ...
javascript
{ "resource": "" }
q1568
writeEmittedFiles
train
function writeEmittedFiles(emitOutput, jsFilePath, sourceMapFilePath, writeByteOrderMark, sourceFiles) { if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false, s...
javascript
{ "resource": "" }
q1569
emitToken
train
function emitToken(tokenKind, startPos, emitFn) { var tokenStartPos = ts.skipTrivia(currentText, startPos); emitPos(tokenStartPos); var tokenString = ts.tokenToString(tokenKind); if (emitFn) { emitFn(); } ...
javascript
{ "resource": "" }
q1570
isImportedReference
train
function isImportedReference(node) { var declaration = resolver.getReferencedImportDeclaration(node); return declaration && (declaration.kind === 231 /* ImportClause */ || declaration.kind === 234 /* ImportSpecifier */); }
javascript
{ "resource": "" }
q1571
tryEmitStartOfVariableDeclarationList
train
function tryEmitStartOfVariableDeclarationList(decl) { if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { // variables in variable declaration list were already hoisted return false; } if (convertedLoopState && (t...
javascript
{ "resource": "" }
q1572
emitAssignment
train
function emitAssignment(name, value, shouldEmitCommaBeforeAssignment, nodeForSourceMap) { if (shouldEmitCommaBeforeAssignment) { write(", "); } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (...
javascript
{ "resource": "" }
q1573
getSuperCallAtGivenIndex
train
function getSuperCallAtGivenIndex(ctor, index) { if (!ctor.body) { return undefined; } var statements = ctor.body.statements; if (!statements || index >= statements.length) { return undefined; } ...
javascript
{ "resource": "" }
q1574
isTripleSlashComment
train
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.p...
javascript
{ "resource": "" }
q1575
getAutomaticTypeDirectiveNames
train
function getAutomaticTypeDirectiveNames(options, host) { // Use explicit type list from tsconfig.json if (options.types) { return options.types; } // Walk the primary type lookup locations var result = []; if (host.directoryExists && host.getDirectories) { ...
javascript
{ "resource": "" }
q1576
findSourceFile
train
function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { if (filesByName.contains(path)) { var file_1 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: thi...
javascript
{ "resource": "" }
q1577
verifyEmitFilePath
train
function verifyEmitFilePath(emitFileName, emitFilesSeen) { if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); // Report error if the output overwrites input file if (filesByName.contains(emit...
javascript
{ "resource": "" }
q1578
parseConfigFileTextToJson
train
function parseConfigFileTextToJson(fileName, jsonText, stripComments) { if (stripComments === void 0) { stripComments = true; } try { var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToPars...
javascript
{ "resource": "" }
q1579
matchFileNames
train
function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { basePath = ts.normalizePath(basePath); // The exclude spec list is converted into a regular expression, which allows us to quickly // test whether a file or directory should be excluded before recursively tra...
javascript
{ "resource": "" }
q1580
getWildcardDirectories
train
function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { // We watch a directory recursively if it contains a wildcard anywhere in a directory segment // of the pattern: // // /a/b/**/d - Watch /a/b recursively to catch changes to any d in any subfolder rec...
javascript
{ "resource": "" }
q1581
hasFileWithHigherPriorityExtension
train
function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); for (var i = 0 /* Highest */; i < adjustedExte...
javascript
{ "resource": "" }
q1582
removeWildcardFilesWithLowerPriorityExtension
train
function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); for (var i = nextExtensionPriority; i < extens...
javascript
{ "resource": "" }
q1583
startNode
train
function startNode(node) { var navNode = emptyNavigationBarNode(node); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); parent = navNode; }
javascript
{ "resource": "" }
q1584
endNode
train
function endNode() { if (parent.children) { mergeChildren(parent.children); sortChildren(parent.children); } parent = parentsStack.pop(); }
javascript
{ "resource": "" }
q1585
mergeChildren
train
function mergeChildren(children) { var nameToItems = ts.createMap(); ts.filterMutate(children, function (child) { var decl = child.node; var name = decl.name && nodeText(decl.name); if (!name) { // Anonymous items are never merg...
javascript
{ "resource": "" }
q1586
shouldReallyMerge
train
function shouldReallyMerge(a, b) { return a.kind === b.kind && (a.kind !== 225 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge ...
javascript
{ "resource": "" }
q1587
areSameModule
train
function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } if (a.body.kind !== 225 /* ModuleDeclaration */) { return true; } return areSameModule(a.b...
javascript
{ "resource": "" }
q1588
merge
train
function merge(target, source) { target.additionalNodes = target.additionalNodes || []; target.additionalNodes.push(source.node); if (source.additionalNodes) { (_a = target.additionalNodes).push.apply(_a, source.additionalNodes); } ...
javascript
{ "resource": "" }
q1589
topLevelItems
train
function topLevelItems(root) { var topLevel = []; function recur(item) { if (isTopLevel(item)) { topLevel.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { ...
javascript
{ "resource": "" }
q1590
getArgumentIndexForTemplatePiece
train
function getArgumentIndexForTemplatePiece(spanIndex, node, position) { // Because the TemplateStringsArray is the first argument, we have to offset each substitution expression by 1. // There are three cases we can encounter: // 1. We are precisely in the template literal (argIn...
javascript
{ "resource": "" }
q1591
getTokenAtPosition
train
function getTokenAtPosition(sourceFile, position, includeJsDocComment) { if (includeJsDocComment === void 0) { includeJsDocComment = false; } return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined, includeJsDocComment); }
javascript
{ "resource": "" }
q1592
isInsideJsxElementOrAttribute
train
function isInsideJsxElementOrAttribute(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position); if (!token) { return false; } if (token.kind === 244 /* JsxText */) { return true; } // <div>Hello |</div> if (token.kind =...
javascript
{ "resource": "" }
q1593
isInCommentHelper
train
function isInCommentHelper(sourceFile, position, predicate) { var token = getTokenAtPosition(sourceFile, position); if (token && position <= token.getStart(sourceFile)) { var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); // The end marker of a single-lin...
javascript
{ "resource": "" }
q1594
mergeTypings
train
function mergeTypings(typingNames) { if (!typingNames) { return; } for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { var typing = typingNames_1[_i]; if (!(typing in inferredTypings)...
javascript
{ "resource": "" }
q1595
getTypingNamesFromJson
train
function getTypingNamesFromJson(jsonPath, filesToWatch) { if (host.fileExists(jsonPath)) { filesToWatch.push(jsonPath); } var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); if (result.config) { ...
javascript
{ "resource": "" }
q1596
getTypingNamesFromSourceFileNames
train
function getTypingNamesFromSourceFileNames(fileNames) { var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); var cleanedT...
javascript
{ "resource": "" }
q1597
getTypingNamesFromNodeModuleFolder
train
function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { // Todo: add support for ModuleResolutionHost too if (!host.directoryExists(nodeModulesPath)) { return; } var typingNames = []; var fileNames = host.readDire...
javascript
{ "resource": "" }
q1598
getScanStartPosition
train
function getScanStartPosition(enclosingNode, originalRange, sourceFile) { var start = enclosingNode.getStart(sourceFile); if (start === originalRange.pos && enclosingNode.end === originalRange.end) { return start; } var precedingToken = ts.findPrecedingTok...
javascript
{ "resource": "" }
q1599
tryComputeIndentationForListItem
train
function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { ...
javascript
{ "resource": "" }