Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
index.js2108 linesDownload Raw Back to lib
1import ts9 from 'typescript';2 3// src/comments.ts4function forEachToken(node, callback, sourceFile = node.getSourceFile()) {5  for (const token of iterateTokens(node, sourceFile)) {6    callback(token);7  }8}9function* iterateTokens(node, sourceFile = node.getSourceFile()) {10  const queue = [];11  while (true) {12    if (ts9.isTokenKind(node.kind)) {13      yield node;14    } else {15      const children = node.getChildren(sourceFile);16      if (children.length === 1) {17        node = children[0];18        continue;19      }20      for (let i = children.length - 1; i >= 0; --i) {21        queue.push(children[i]);22      }23    }24    if (queue.length === 0) {25      break;26    }27    node = queue.pop();28  }29}30 31// src/comments.ts32function forEachComment(node, callback, sourceFile = node.getSourceFile()) {33  const fullText = sourceFile.text;34  for (const { end, kind, pos } of iterateComments(node, sourceFile)) {35    callback(fullText, { end, kind, pos });36  }37}38function* iterateComments(node, sourceFile = node.getSourceFile()) {39  const fullText = sourceFile.text;40  const notJsx = sourceFile.languageVariant !== ts9.LanguageVariant.JSX;41  for (const token of iterateTokens(node, sourceFile)) {42    if (token.pos === token.end) {43      continue;44    }45    if (token.kind !== ts9.SyntaxKind.JsxText) {46      yield* collectComments((callback) => {47        ts9.forEachLeadingCommentRange(48          fullText,49          // skip shebang at position 050          token.pos === 0 ? (ts9.getShebang(fullText) ?? "").length : token.pos,51          callback52        );53      }, fullText);54    }55    if (notJsx || canHaveTrailingTrivia(token)) {56      yield* collectComments((callback) => {57        ts9.forEachTrailingCommentRange(fullText, token.end, callback);58      }, fullText);59    }60  }61}62function canHaveTrailingTrivia(token) {63  switch (token.kind) {64    case ts9.SyntaxKind.CloseBraceToken:65      return token.parent.kind !== ts9.SyntaxKind.JsxExpression || !isJsxElementOrFragment(token.parent.parent);66    case ts9.SyntaxKind.GreaterThanToken:67      switch (token.parent.kind) {68        case ts9.SyntaxKind.JsxClosingElement:69        case ts9.SyntaxKind.JsxClosingFragment:70          return !isJsxElementOrFragment(token.parent.parent.parent);71        case ts9.SyntaxKind.JsxOpeningElement:72          return token.end !== token.parent.end;73        case ts9.SyntaxKind.JsxOpeningFragment:74          return false;75        // would be inside the fragment76        case ts9.SyntaxKind.JsxSelfClosingElement:77          return token.end !== token.parent.end || // if end is not equal, this is part of the type arguments list78          !isJsxElementOrFragment(token.parent.parent);79      }80  }81  return true;82}83function collectComments(execute, fullText) {84  const comments = [];85  execute((pos, end, kind) => {86    const text = fullText.slice(pos, end);87    const value = text.slice(88      2,89      kind === ts9.SyntaxKind.SingleLineCommentTrivia ? void 0 : -290    );91    comments.push({ end, kind, pos, text, value });92  });93  return comments;94}95function isJsxElementOrFragment(node) {96  return node.kind === ts9.SyntaxKind.JsxElement || node.kind === ts9.SyntaxKind.JsxFragment;97}98var [tsMajor, tsMinor] = ts9.versionMajorMinor.split(".").map((raw) => Number.parseInt(raw, 10));99function isTsVersionAtLeast(major, minor = 0) {100  return tsMajor > major || tsMajor === major && tsMinor >= minor;101}102 103// src/compilerOptions.ts104function isCompilerOptionEnabled(options, option) {105  switch (option) {106    case "allowJs":107      return options.allowJs === void 0 ? isCompilerOptionEnabled(options, "checkJs") : options.allowJs;108    case "allowSyntheticDefaultImports":109      return options.allowSyntheticDefaultImports !== void 0 ? options.allowSyntheticDefaultImports : isCompilerOptionEnabled(options, "esModuleInterop") || options.module === ts9.ModuleKind.System;110    case "alwaysStrict":111    case "noImplicitAny":112    case "noImplicitThis":113    case "strictBindCallApply":114    case "strictFunctionTypes":115    case "strictNullChecks":116    case "strictPropertyInitialization":117      return isStrictCompilerOptionEnabled(118        options,119        option120      );121    case "declaration":122      return options.declaration || isCompilerOptionEnabled(options, "composite");123    case "declarationMap":124    case "emitDeclarationOnly":125    case "stripInternal":126      return options[option] === true && isCompilerOptionEnabled(options, "declaration");127    case "incremental":128      return options.incremental === void 0 ? isCompilerOptionEnabled(options, "composite") : options.incremental;129    case "noUncheckedIndexedAccess":130      return options.noUncheckedIndexedAccess === true && isCompilerOptionEnabled(options, "strictNullChecks");131    case "skipDefaultLibCheck":132      return options.skipDefaultLibCheck || isCompilerOptionEnabled(options, "skipLibCheck");133    case "suppressImplicitAnyIndexErrors":134      return (135        // eslint-disable-next-line @typescript-eslint/no-deprecated136        options.suppressImplicitAnyIndexErrors === true && isCompilerOptionEnabled(options, "noImplicitAny")137      );138  }139  return options[option] === true;140}141function isStrictCompilerOptionEnabled(options, option) {142  if (option === "strictPropertyInitialization") {143    if (!isStrictCompilerOptionEnabled(options, "strictNullChecks")) {144      return false;145    }146  }147  return options[option] ?? options.strict ?? isTsVersionAtLeast(6);148}149function isModifierFlagSet(node, flag) {150  return isFlagSet(ts9.getCombinedModifierFlags(node), flag);151}152function isFlagSet(allFlags, flag) {153  return (allFlags & flag) !== 0;154}155function isFlagSetOnObject(obj, flag) {156  return isFlagSet(obj.flags, flag);157}158var isNodeFlagSet = isFlagSetOnObject;159function isObjectFlagSet(objectType, flag) {160  return isFlagSet(objectType.objectFlags, flag);161}162var isSymbolFlagSet = isFlagSetOnObject;163function isTransientSymbolLinksFlagSet(links, flag) {164  return isFlagSet(links.checkFlags, flag);165}166var isTypeFlagSet = isFlagSetOnObject;167 168// src/modifiers.ts169function includesModifier(modifiers, ...kinds) {170  if (modifiers === void 0) {171    return false;172  }173  for (const modifier of modifiers) {174    if (kinds.includes(modifier.kind)) {175      return true;176    }177  }178  return false;179}180function isAssignmentKind(kind) {181  return kind >= ts9.SyntaxKind.FirstAssignment && kind <= ts9.SyntaxKind.LastAssignment;182}183function isNumericPropertyName(name) {184  return String(+name) === name;185}186function isValidPropertyAccess(text, languageVersion = ts9.ScriptTarget.Latest) {187  if (text.length === 0) {188    return false;189  }190  let ch = text.codePointAt(0);191  if (!ts9.isIdentifierStart(ch, languageVersion)) {192    return false;193  }194  for (let i = charSize(ch); i < text.length; i += charSize(ch)) {195    ch = text.codePointAt(i);196    if (!ts9.isIdentifierPart(ch, languageVersion)) {197      return false;198    }199  }200  return true;201}202function charSize(ch) {203  return ch >= 65536 ? 2 : 1;204}205 206// src/nodes/access.ts207var AccessKind = /* @__PURE__ */ ((AccessKind2) => {208  AccessKind2[AccessKind2["None"] = 0] = "None";209  AccessKind2[AccessKind2["Read"] = 1] = "Read";210  AccessKind2[AccessKind2["Write"] = 2] = "Write";211  AccessKind2[AccessKind2["Delete"] = 4] = "Delete";212  AccessKind2[AccessKind2["ReadWrite"] = 3] = "ReadWrite";213  return AccessKind2;214})(AccessKind || {});215function getAccessKind(node) {216  const parent = node.parent;217  switch (parent.kind) {218    case ts9.SyntaxKind.ArrayLiteralExpression:219    case ts9.SyntaxKind.SpreadAssignment:220    case ts9.SyntaxKind.SpreadElement:221      return isInDestructuringAssignment(222        parent223      ) ? 2 /* Write */ : 1 /* Read */;224    case ts9.SyntaxKind.ArrowFunction:225      return parent.body === node ? 1 /* Read */ : 2 /* Write */;226    case ts9.SyntaxKind.AsExpression:227    case ts9.SyntaxKind.NonNullExpression:228    case ts9.SyntaxKind.ParenthesizedExpression:229    case ts9.SyntaxKind.TypeAssertionExpression:230      return getAccessKind(parent);231    case ts9.SyntaxKind.AwaitExpression:232    case ts9.SyntaxKind.CallExpression:233    case ts9.SyntaxKind.CaseClause:234    case ts9.SyntaxKind.ComputedPropertyName:235    case ts9.SyntaxKind.ConditionalExpression:236    case ts9.SyntaxKind.Decorator:237    case ts9.SyntaxKind.DoStatement:238    case ts9.SyntaxKind.ElementAccessExpression:239    case ts9.SyntaxKind.ExpressionStatement:240    case ts9.SyntaxKind.ForStatement:241    case ts9.SyntaxKind.IfStatement:242    case ts9.SyntaxKind.JsxElement:243    case ts9.SyntaxKind.JsxExpression:244    case ts9.SyntaxKind.JsxOpeningElement:245    case ts9.SyntaxKind.JsxSelfClosingElement:246    case ts9.SyntaxKind.JsxSpreadAttribute:247    case ts9.SyntaxKind.NewExpression:248    case ts9.SyntaxKind.ReturnStatement:249    case ts9.SyntaxKind.SwitchStatement:250    case ts9.SyntaxKind.TaggedTemplateExpression:251    case ts9.SyntaxKind.TemplateSpan:252    case ts9.SyntaxKind.ThrowStatement:253    case ts9.SyntaxKind.TypeOfExpression:254    case ts9.SyntaxKind.VoidExpression:255    case ts9.SyntaxKind.WhileStatement:256    case ts9.SyntaxKind.WithStatement:257    case ts9.SyntaxKind.YieldExpression:258      return 1 /* Read */;259    case ts9.SyntaxKind.BinaryExpression:260      return parent.right === node ? 1 /* Read */ : !isAssignmentKind(parent.operatorToken.kind) ? 1 /* Read */ : parent.operatorToken.kind === ts9.SyntaxKind.EqualsToken ? 2 /* Write */ : 3 /* ReadWrite */;261    case ts9.SyntaxKind.BindingElement:262    case ts9.SyntaxKind.EnumMember:263    case ts9.SyntaxKind.JsxAttribute:264    case ts9.SyntaxKind.Parameter:265    case ts9.SyntaxKind.PropertyDeclaration:266    case ts9.SyntaxKind.VariableDeclaration:267      return parent.initializer === node ? 1 /* Read */ : 0 /* None */;268    case ts9.SyntaxKind.DeleteExpression:269      return 4 /* Delete */;270    case ts9.SyntaxKind.ExportAssignment:271      return parent.isExportEquals ? 1 /* Read */ : 0 /* None */;272    case ts9.SyntaxKind.ExpressionWithTypeArguments:273      return parent.parent.token === ts9.SyntaxKind.ExtendsKeyword && parent.parent.parent.kind !== ts9.SyntaxKind.InterfaceDeclaration ? 1 /* Read */ : 0 /* None */;274    case ts9.SyntaxKind.ForInStatement:275    case ts9.SyntaxKind.ForOfStatement:276      return parent.initializer === node ? 2 /* Write */ : 1 /* Read */;277    case ts9.SyntaxKind.PostfixUnaryExpression:278      return 3 /* ReadWrite */;279    case ts9.SyntaxKind.PrefixUnaryExpression:280      return parent.operator === ts9.SyntaxKind.PlusPlusToken || parent.operator === ts9.SyntaxKind.MinusMinusToken ? 3 /* ReadWrite */ : 1 /* Read */;281    case ts9.SyntaxKind.PropertyAccessExpression:282      return parent.expression === node ? 1 /* Read */ : 0 /* None */;283    case ts9.SyntaxKind.PropertyAssignment:284      return parent.name === node ? 0 /* None */ : isInDestructuringAssignment(parent) ? 2 /* Write */ : 1 /* Read */;285    case ts9.SyntaxKind.ShorthandPropertyAssignment:286      return parent.objectAssignmentInitializer === node ? 1 /* Read */ : isInDestructuringAssignment(parent) ? 2 /* Write */ : 1 /* Read */;287  }288  return 0 /* None */;289}290function isInDestructuringAssignment(node) {291  switch (node.kind) {292    case ts9.SyntaxKind.ShorthandPropertyAssignment:293      if (node.objectAssignmentInitializer !== void 0) {294        return true;295      }296    // falls through297    case ts9.SyntaxKind.PropertyAssignment:298    case ts9.SyntaxKind.SpreadAssignment:299      node = node.parent;300      break;301    case ts9.SyntaxKind.SpreadElement:302      if (node.parent.kind !== ts9.SyntaxKind.ArrayLiteralExpression) {303        return false;304      }305      node = node.parent;306  }307  while (true) {308    switch (node.parent.kind) {309      case ts9.SyntaxKind.ArrayLiteralExpression:310      case ts9.SyntaxKind.ObjectLiteralExpression:311        node = node.parent;312        break;313      case ts9.SyntaxKind.BinaryExpression:314        return node.parent.left === node && node.parent.operatorToken.kind === ts9.SyntaxKind.EqualsToken;315      case ts9.SyntaxKind.ForOfStatement:316        return node.parent.initializer === node;317      case ts9.SyntaxKind.PropertyAssignment:318      case ts9.SyntaxKind.SpreadAssignment:319        node = node.parent.parent;320        break;321      case ts9.SyntaxKind.SpreadElement:322        if (node.parent.parent.kind !== ts9.SyntaxKind.ArrayLiteralExpression) {323          return false;324        }325        node = node.parent.parent;326        break;327      default:328        return false;329    }330  }331}332function isAbstractKeyword(node) {333  return node.kind === ts9.SyntaxKind.AbstractKeyword;334}335function isAccessorKeyword(node) {336  return node.kind === ts9.SyntaxKind.AccessorKeyword;337}338function isAnyKeyword(node) {339  return node.kind === ts9.SyntaxKind.AnyKeyword;340}341function isAssertKeyword(node) {342  return node.kind === ts9.SyntaxKind.AssertKeyword;343}344function isAssertsKeyword(node) {345  return node.kind === ts9.SyntaxKind.AssertsKeyword;346}347function isAsyncKeyword(node) {348  return node.kind === ts9.SyntaxKind.AsyncKeyword;349}350function isAwaitKeyword(node) {351  return node.kind === ts9.SyntaxKind.AwaitKeyword;352}353function isBigIntKeyword(node) {354  return node.kind === ts9.SyntaxKind.BigIntKeyword;355}356function isBooleanKeyword(node) {357  return node.kind === ts9.SyntaxKind.BooleanKeyword;358}359function isColonToken(node) {360  return node.kind === ts9.SyntaxKind.ColonToken;361}362function isConstKeyword(node) {363  return node.kind === ts9.SyntaxKind.ConstKeyword;364}365function isDeclareKeyword(node) {366  return node.kind === ts9.SyntaxKind.DeclareKeyword;367}368function isDefaultKeyword(node) {369  return node.kind === ts9.SyntaxKind.DefaultKeyword;370}371function isDotToken(node) {372  return node.kind === ts9.SyntaxKind.DotToken;373}374function isEndOfFileToken(node) {375  return node.kind === ts9.SyntaxKind.EndOfFileToken;376}377function isEqualsGreaterThanToken(node) {378  return node.kind === ts9.SyntaxKind.EqualsGreaterThanToken;379}380function isEqualsToken(node) {381  return node.kind === ts9.SyntaxKind.EqualsToken;382}383function isExclamationToken(node) {384  return node.kind === ts9.SyntaxKind.ExclamationToken;385}386function isExportKeyword(node) {387  return node.kind === ts9.SyntaxKind.ExportKeyword;388}389function isFalseKeyword(node) {390  return node.kind === ts9.SyntaxKind.FalseKeyword;391}392function isFalseLiteral(node) {393  return node.kind === ts9.SyntaxKind.FalseKeyword;394}395function isImportExpression(node) {396  return node.kind === ts9.SyntaxKind.ImportKeyword;397}398function isImportKeyword(node) {399  return node.kind === ts9.SyntaxKind.ImportKeyword;400}401function isInKeyword(node) {402  return node.kind === ts9.SyntaxKind.InKeyword;403}404function isJSDocText(node) {405  return node.kind === ts9.SyntaxKind.JSDocText;406}407function isJsonMinusNumericLiteral(node) {408  return node.kind === ts9.SyntaxKind.PrefixUnaryExpression;409}410function isNeverKeyword(node) {411  return node.kind === ts9.SyntaxKind.NeverKeyword;412}413function isNullKeyword(node) {414  return node.kind === ts9.SyntaxKind.NullKeyword;415}416function isNullLiteral(node) {417  return node.kind === ts9.SyntaxKind.NullKeyword;418}419function isNumberKeyword(node) {420  return node.kind === ts9.SyntaxKind.NumberKeyword;421}422function isObjectKeyword(node) {423  return node.kind === ts9.SyntaxKind.ObjectKeyword;424}425function isOutKeyword(node) {426  return node.kind === ts9.SyntaxKind.OutKeyword;427}428function isOverrideKeyword(node) {429  return node.kind === ts9.SyntaxKind.OverrideKeyword;430}431function isPrivateKeyword(node) {432  return node.kind === ts9.SyntaxKind.PrivateKeyword;433}434function isProtectedKeyword(node) {435  return node.kind === ts9.SyntaxKind.ProtectedKeyword;436}437function isPublicKeyword(node) {438  return node.kind === ts9.SyntaxKind.PublicKeyword;439}440function isQuestionDotToken(node) {441  return node.kind === ts9.SyntaxKind.QuestionDotToken;442}443function isQuestionToken(node) {444  return node.kind === ts9.SyntaxKind.QuestionToken;445}446function isReadonlyKeyword(node) {447  return node.kind === ts9.SyntaxKind.ReadonlyKeyword;448}449function isStaticKeyword(node) {450  return node.kind === ts9.SyntaxKind.StaticKeyword;451}452function isStringKeyword(node) {453  return node.kind === ts9.SyntaxKind.StringKeyword;454}455function isSuperExpression(node) {456  return node.kind === ts9.SyntaxKind.SuperKeyword;457}458function isSuperKeyword(node) {459  return node.kind === ts9.SyntaxKind.SuperKeyword;460}461function isSymbolKeyword(node) {462  return node.kind === ts9.SyntaxKind.SymbolKeyword;463}464function isSyntaxList(node) {465  return node.kind === ts9.SyntaxKind.SyntaxList;466}467function isThisExpression(node) {468  return node.kind === ts9.SyntaxKind.ThisKeyword;469}470function isThisKeyword(node) {471  return node.kind === ts9.SyntaxKind.ThisKeyword;472}473function isTrueKeyword(node) {474  return node.kind === ts9.SyntaxKind.TrueKeyword;475}476function isTrueLiteral(node) {477  return node.kind === ts9.SyntaxKind.TrueKeyword;478}479function isUndefinedKeyword(node) {480  return node.kind === ts9.SyntaxKind.UndefinedKeyword;481}482function isUnknownKeyword(node) {483  return node.kind === ts9.SyntaxKind.UnknownKeyword;484}485function isVoidKeyword(node) {486  return node.kind === ts9.SyntaxKind.VoidKeyword;487}488function hasDecorators(node) {489  return ts9.isParameter(node) || ts9.isPropertyDeclaration(node) || ts9.isMethodDeclaration(node) || ts9.isGetAccessorDeclaration(node) || ts9.isSetAccessorDeclaration(node) || ts9.isClassExpression(node) || ts9.isClassDeclaration(node);490}491function hasExpressionInitializer(node) {492  return ts9.isVariableDeclaration(node) || ts9.isParameter(node) || ts9.isBindingElement(node) || ts9.isPropertyDeclaration(node) || ts9.isPropertyAssignment(node) || ts9.isEnumMember(node);493}494function hasInitializer(node) {495  return hasExpressionInitializer(node) || ts9.isForStatement(node) || ts9.isForInStatement(node) || ts9.isForOfStatement(node) || ts9.isJsxAttribute(node);496}497function hasJSDoc(node) {498  if (499    // eslint-disable-next-line @typescript-eslint/no-deprecated -- Keep compatibility with ts <5500    isAccessorDeclaration(node) || ts9.isArrowFunction(node) || ts9.isBlock(node) || ts9.isBreakStatement(node) || ts9.isCallSignatureDeclaration(node) || ts9.isCaseClause(node) || // eslint-disable-next-line @typescript-eslint/no-deprecated -- Keep compatibility with ts <5501    isClassLikeDeclaration(node) || ts9.isConstructorDeclaration(node) || ts9.isConstructorTypeNode(node) || ts9.isConstructSignatureDeclaration(node) || ts9.isContinueStatement(node) || ts9.isDebuggerStatement(node) || ts9.isDoStatement(node) || ts9.isEmptyStatement(node) || isEndOfFileToken(node) || ts9.isEnumDeclaration(node) || ts9.isEnumMember(node) || ts9.isExportAssignment(node) || ts9.isExportDeclaration(node) || ts9.isExportSpecifier(node) || ts9.isExpressionStatement(node) || ts9.isForInStatement(node) || ts9.isForOfStatement(node) || ts9.isForStatement(node) || ts9.isFunctionDeclaration(node) || ts9.isFunctionExpression(node) || ts9.isFunctionTypeNode(node) || ts9.isIfStatement(node) || ts9.isImportDeclaration(node) || ts9.isImportEqualsDeclaration(node) || ts9.isIndexSignatureDeclaration(node) || ts9.isInterfaceDeclaration(node) || ts9.isJSDocFunctionType(node) || ts9.isLabeledStatement(node) || ts9.isMethodDeclaration(node) || ts9.isMethodSignature(node) || ts9.isModuleDeclaration(node) || ts9.isNamedTupleMember(node) || ts9.isNamespaceExportDeclaration(node) || ts9.isParameter(node) || ts9.isParenthesizedExpression(node) || ts9.isPropertyAssignment(node) || ts9.isPropertyDeclaration(node) || ts9.isPropertySignature(node) || ts9.isReturnStatement(node) || ts9.isShorthandPropertyAssignment(node) || ts9.isSpreadAssignment(node) || ts9.isSwitchStatement(node) || ts9.isThrowStatement(node) || ts9.isTryStatement(node) || ts9.isTypeAliasDeclaration(node) || ts9.isVariableDeclaration(node) || ts9.isVariableStatement(node) || ts9.isWhileStatement(node) || ts9.isWithStatement(node)502  ) {503    return true;504  }505  if (isTsVersionAtLeast(4, 4) && ts9.isClassStaticBlockDeclaration(node)) {506    return true;507  }508  if (isTsVersionAtLeast(5, 0) && (ts9.isBinaryExpression(node) || ts9.isElementAccessExpression(node) || ts9.isIdentifier(node) || ts9.isJSDocSignature(node) || ts9.isObjectLiteralExpression(node) || ts9.isPropertyAccessExpression(node) || ts9.isTypeParameterDeclaration(node))) {509    return true;510  }511  return false;512}513function hasModifiers(node) {514  return ts9.isTypeParameterDeclaration(node) || ts9.isParameter(node) || ts9.isConstructorTypeNode(node) || ts9.isPropertySignature(node) || ts9.isPropertyDeclaration(node) || ts9.isMethodSignature(node) || ts9.isMethodDeclaration(node) || ts9.isConstructorDeclaration(node) || ts9.isGetAccessorDeclaration(node) || ts9.isSetAccessorDeclaration(node) || ts9.isIndexSignatureDeclaration(node) || ts9.isFunctionExpression(node) || ts9.isArrowFunction(node) || ts9.isClassExpression(node) || ts9.isVariableStatement(node) || ts9.isFunctionDeclaration(node) || ts9.isClassDeclaration(node) || ts9.isInterfaceDeclaration(node) || ts9.isTypeAliasDeclaration(node) || ts9.isEnumDeclaration(node) || ts9.isModuleDeclaration(node) || ts9.isImportEqualsDeclaration(node) || ts9.isImportDeclaration(node) || ts9.isExportAssignment(node) || ts9.isExportDeclaration(node);515}516function hasType(node) {517  return isSignatureDeclaration(node) || ts9.isVariableDeclaration(node) || ts9.isParameter(node) || ts9.isPropertySignature(node) || ts9.isPropertyDeclaration(node) || ts9.isTypePredicateNode(node) || ts9.isParenthesizedTypeNode(node) || ts9.isTypeOperatorNode(node) || ts9.isMappedTypeNode(node) || ts9.isAssertionExpression(node) || ts9.isTypeAliasDeclaration(node) || ts9.isJSDocTypeExpression(node) || ts9.isJSDocNonNullableType(node) || ts9.isJSDocNullableType(node) || ts9.isJSDocOptionalType(node) || ts9.isJSDocVariadicType(node);518}519function hasTypeArguments(node) {520  return ts9.isCallExpression(node) || ts9.isNewExpression(node) || ts9.isTaggedTemplateExpression(node) || ts9.isJsxOpeningElement(node) || ts9.isJsxSelfClosingElement(node);521}522function isAccessExpression(node) {523  return ts9.isPropertyAccessExpression(node) || ts9.isElementAccessExpression(node);524}525function isAccessibilityModifier(node) {526  return isPublicKeyword(node) || isPrivateKeyword(node) || isProtectedKeyword(node);527}528function isAccessorDeclaration(node) {529  return ts9.isGetAccessorDeclaration(node) || ts9.isSetAccessorDeclaration(node);530}531function isArrayBindingElement(node) {532  return ts9.isBindingElement(node) || ts9.isOmittedExpression(node);533}534function isArrayBindingOrAssignmentPattern(node) {535  return ts9.isArrayBindingPattern(node) || ts9.isArrayLiteralExpression(node);536}537function isAssignmentPattern(node) {538  return ts9.isObjectLiteralExpression(node) || ts9.isArrayLiteralExpression(node);539}540function isBindingOrAssignmentElementRestIndicator(node) {541  if (ts9.isSpreadElement(node) || ts9.isSpreadAssignment(node)) {542    return true;543  }544  if (isTsVersionAtLeast(4, 4)) {545    return ts9.isDotDotDotToken(node);546  }547  return false;548}549function isBindingOrAssignmentElementTarget(node) {550  return isBindingOrAssignmentPattern(node) || ts9.isIdentifier(node) || ts9.isPropertyAccessExpression(node) || ts9.isElementAccessExpression(node) || ts9.isOmittedExpression(node);551}552function isBindingOrAssignmentPattern(node) {553  return isObjectBindingOrAssignmentPattern(node) || isArrayBindingOrAssignmentPattern(node);554}555function isBindingPattern(node) {556  return ts9.isObjectBindingPattern(node) || ts9.isArrayBindingPattern(node);557}558function isBlockLike(node) {559  return ts9.isSourceFile(node) || ts9.isBlock(node) || ts9.isModuleBlock(node) || ts9.isCaseOrDefaultClause(node);560}561function isBooleanLiteral(node) {562  return isTrueLiteral(node) || isFalseLiteral(node);563}564function isClassLikeDeclaration(node) {565  return ts9.isClassDeclaration(node) || ts9.isClassExpression(node);566}567function isClassMemberModifier(node) {568  return isAccessibilityModifier(node) || isReadonlyKeyword(node) || isStaticKeyword(node) || isAccessorKeyword(node);569}570function isDeclarationName(node) {571  return ts9.isIdentifier(node) || ts9.isPrivateIdentifier(node) || ts9.isStringLiteralLike(node) || ts9.isNumericLiteral(node) || ts9.isComputedPropertyName(node) || ts9.isElementAccessExpression(node) || isBindingPattern(node) || isEntityNameExpression(node);572}573function isDeclarationWithTypeParameterChildren(node) {574  return isSignatureDeclaration(node) || // eslint-disable-next-line @typescript-eslint/no-deprecated -- Keep compatibility with ts <5575  isClassLikeDeclaration(node) || ts9.isInterfaceDeclaration(node) || ts9.isTypeAliasDeclaration(node) || ts9.isJSDocTemplateTag(node);576}577function isDeclarationWithTypeParameters(node) {578  return isDeclarationWithTypeParameterChildren(node) || ts9.isJSDocTypedefTag(node) || ts9.isJSDocCallbackTag(node) || ts9.isJSDocSignature(node);579}580function isDestructuringPattern(node) {581  return isBindingPattern(node) || ts9.isObjectLiteralExpression(node) || ts9.isArrayLiteralExpression(node);582}583function isEntityNameExpression(node) {584  return ts9.isIdentifier(node) || isPropertyAccessEntityNameExpression(node);585}586function isEntityNameOrEntityNameExpression(node) {587  return ts9.isEntityName(node) || isEntityNameExpression(node);588}589function isForInOrOfStatement(node) {590  return ts9.isForInStatement(node) || ts9.isForOfStatement(node);591}592function isFunctionLikeDeclaration(node) {593  return ts9.isFunctionDeclaration(node) || ts9.isMethodDeclaration(node) || ts9.isGetAccessorDeclaration(node) || ts9.isSetAccessorDeclaration(node) || ts9.isConstructorDeclaration(node) || ts9.isFunctionExpression(node) || ts9.isArrowFunction(node);594}595function isJSDocComment(node) {596  if (isJSDocText(node)) {597    return true;598  }599  if (isTsVersionAtLeast(4, 4)) {600    return ts9.isJSDocLink(node) || ts9.isJSDocLinkCode(node) || ts9.isJSDocLinkPlain(node);601  }602  return false;603}604function isJSDocNamespaceBody(node) {605  return ts9.isIdentifier(node) || isJSDocNamespaceDeclaration(node);606}607function isJSDocTypeReferencingNode(node) {608  return ts9.isJSDocVariadicType(node) || ts9.isJSDocOptionalType(node) || ts9.isJSDocNullableType(node) || ts9.isJSDocNonNullableType(node);609}610function isJsonObjectExpression(node) {611  return ts9.isObjectLiteralExpression(node) || ts9.isArrayLiteralExpression(node) || isJsonMinusNumericLiteral(node) || ts9.isNumericLiteral(node) || ts9.isStringLiteral(node) || isBooleanLiteral(node) || isNullLiteral(node);612}613function isJsxAttributeLike(node) {614  return ts9.isJsxAttribute(node) || ts9.isJsxSpreadAttribute(node);615}616function isJsxAttributeValue(node) {617  return ts9.isStringLiteral(node) || ts9.isJsxExpression(node) || ts9.isJsxElement(node) || ts9.isJsxSelfClosingElement(node) || ts9.isJsxFragment(node);618}619function isJsxChild(node) {620  return ts9.isJsxText(node) || ts9.isJsxExpression(node) || ts9.isJsxElement(node) || ts9.isJsxSelfClosingElement(node) || ts9.isJsxFragment(node);621}622function isJsxTagNameExpression(node) {623  return ts9.isIdentifier(node) || isThisExpression(node) || isJsxTagNamePropertyAccess(node);624}625function isLiteralToken(node) {626  return ts9.isNumericLiteral(node) || ts9.isBigIntLiteral(node) || ts9.isStringLiteral(node) || ts9.isJsxText(node) || ts9.isRegularExpressionLiteral(node) || ts9.isNoSubstitutionTemplateLiteral(node);627}628function isModuleBody(node) {629  return isNamespaceBody(node) || isJSDocNamespaceBody(node);630}631function isModuleName(node) {632  return ts9.isIdentifier(node) || ts9.isStringLiteral(node);633}634function isModuleReference(node) {635  return ts9.isEntityName(node) || ts9.isExternalModuleReference(node);636}637function isNamedImportBindings(node) {638  return ts9.isNamespaceImport(node) || ts9.isNamedImports(node);639}640function isNamedImportsOrExports(node) {641  return ts9.isNamedImports(node) || ts9.isNamedExports(node);642}643function isNamespaceBody(node) {644  return ts9.isModuleBlock(node) || isNamespaceDeclaration(node);645}646function isObjectBindingOrAssignmentElement(node) {647  return ts9.isBindingElement(node) || ts9.isPropertyAssignment(node) || ts9.isShorthandPropertyAssignment(node) || ts9.isSpreadAssignment(node);648}649function isObjectBindingOrAssignmentPattern(node) {650  return ts9.isObjectBindingPattern(node) || ts9.isObjectLiteralExpression(node);651}652function isObjectTypeDeclaration(node) {653  return (654    // eslint-disable-next-line @typescript-eslint/no-deprecated -- Keep compatibility with ts <5655    isClassLikeDeclaration(node) || ts9.isInterfaceDeclaration(node) || ts9.isTypeLiteralNode(node)656  );657}658function isParameterPropertyModifier(node) {659  return isAccessibilityModifier(node) || isReadonlyKeyword(node);660}661function isPropertyNameLiteral(node) {662  return ts9.isIdentifier(node) || ts9.isStringLiteralLike(node) || ts9.isNumericLiteral(node);663}664function isPseudoLiteralToken(node) {665  return ts9.isTemplateHead(node) || ts9.isTemplateMiddle(node) || ts9.isTemplateTail(node);666}667function isSignatureDeclaration(node) {668  return ts9.isCallSignatureDeclaration(node) || ts9.isConstructSignatureDeclaration(node) || ts9.isMethodSignature(node) || ts9.isIndexSignatureDeclaration(node) || ts9.isFunctionTypeNode(node) || ts9.isConstructorTypeNode(node) || ts9.isJSDocFunctionType(node) || ts9.isFunctionDeclaration(node) || ts9.isMethodDeclaration(node) || ts9.isConstructorDeclaration(node) || // eslint-disable-next-line @typescript-eslint/no-deprecated -- Keep compatibility with ts <5669  isAccessorDeclaration(node) || ts9.isFunctionExpression(node) || ts9.isArrowFunction(node);670}671function isSuperProperty(node) {672  return isSuperPropertyAccessExpression(node) || isSuperElementAccessExpression(node);673}674function isTypeOnlyCompatibleAliasDeclaration(node) {675  if (ts9.isImportClause(node) || ts9.isImportEqualsDeclaration(node) || ts9.isNamespaceImport(node) || ts9.isImportOrExportSpecifier(node)) {676    return true;677  }678  if (isTsVersionAtLeast(5, 0) && (ts9.isExportDeclaration(node) || ts9.isNamespaceExport(node))) {679    return true;680  }681  return false;682}683function isTypeReferenceType(node) {684  return ts9.isTypeReferenceNode(node) || ts9.isExpressionWithTypeArguments(node);685}686function isUnionOrIntersectionTypeNode(node) {687  return ts9.isUnionTypeNode(node) || ts9.isIntersectionTypeNode(node);688}689function isVariableLikeDeclaration(node) {690  return ts9.isVariableDeclaration(node) || ts9.isParameter(node) || ts9.isBindingElement(node) || ts9.isPropertyDeclaration(node) || ts9.isPropertyAssignment(node) || ts9.isPropertySignature(node) || ts9.isJsxAttribute(node) || ts9.isShorthandPropertyAssignment(node) || ts9.isEnumMember(node) || ts9.isJSDocPropertyTag(node) || ts9.isJSDocParameterTag(node);691}692 693// src/nodes/typeGuards/compound.ts694function isConstAssertionExpression(node) {695  return ts9.isTypeReferenceNode(node.type) && ts9.isIdentifier(node.type.typeName) && node.type.typeName.escapedText === "const";696}697function isIterationStatement(node) {698  switch (node.kind) {699    case ts9.SyntaxKind.DoStatement:700    case ts9.SyntaxKind.ForInStatement:701    case ts9.SyntaxKind.ForOfStatement:702    case ts9.SyntaxKind.ForStatement:703    case ts9.SyntaxKind.WhileStatement:704      return true;705    default:706      return false;707  }708}709function isJSDocNamespaceDeclaration(node) {710  return ts9.isModuleDeclaration(node) && ts9.isIdentifier(node.name) && (node.body === void 0 || isJSDocNamespaceBody(node.body));711}712function isJsxTagNamePropertyAccess(node) {713  return ts9.isPropertyAccessExpression(node) && // eslint-disable-next-line @typescript-eslint/no-deprecated -- Keep compatibility with ts < 5714  isJsxTagNameExpression(node.expression);715}716function isNamedDeclarationWithName(node) {717  return "name" in node && node.name !== void 0 && node.name !== null && isDeclarationName(node.name);718}719function isNamespaceDeclaration(node) {720  return ts9.isModuleDeclaration(node) && ts9.isIdentifier(node.name) && node.body !== void 0 && isNamespaceBody(node.body);721}722function isNumericOrStringLikeLiteral(node) {723  switch (node.kind) {724    case ts9.SyntaxKind.NoSubstitutionTemplateLiteral:725    case ts9.SyntaxKind.NumericLiteral:726    case ts9.SyntaxKind.StringLiteral:727      return true;728    default:729      return false;730  }731}732function isPropertyAccessEntityNameExpression(node) {733  return ts9.isPropertyAccessExpression(node) && ts9.isIdentifier(node.name) && isEntityNameExpression(node.expression);734}735function isSuperElementAccessExpression(node) {736  return ts9.isElementAccessExpression(node) && isSuperExpression(node.expression);737}738function isSuperPropertyAccessExpression(node) {739  return ts9.isPropertyAccessExpression(node) && isSuperExpression(node.expression);740}741function isFunctionScopeBoundary(node) {742  switch (node.kind) {743    case ts9.SyntaxKind.ArrowFunction:744    case ts9.SyntaxKind.CallSignature:745    case ts9.SyntaxKind.ClassDeclaration:746    case ts9.SyntaxKind.ClassExpression:747    case ts9.SyntaxKind.Constructor:748    case ts9.SyntaxKind.ConstructorType:749    case ts9.SyntaxKind.ConstructSignature:750    case ts9.SyntaxKind.EnumDeclaration:751    case ts9.SyntaxKind.FunctionDeclaration:752    case ts9.SyntaxKind.FunctionExpression:753    case ts9.SyntaxKind.FunctionType:754    case ts9.SyntaxKind.GetAccessor:755    case ts9.SyntaxKind.MethodDeclaration:756    case ts9.SyntaxKind.MethodSignature:757    case ts9.SyntaxKind.ModuleDeclaration:758    case ts9.SyntaxKind.SetAccessor:759      return true;760    case ts9.SyntaxKind.SourceFile:761      return ts9.isExternalModule(node);762    default:763      return false;764  }765}766function isIntrinsicAnyType(type) {767  return isTypeFlagSet(type, ts9.TypeFlags.Any);768}769function isIntrinsicBigIntType(type) {770  return isTypeFlagSet(type, ts9.TypeFlags.BigInt);771}772function isIntrinsicBooleanType(type) {773  return isTypeFlagSet(type, ts9.TypeFlags.Boolean);774}775function isIntrinsicErrorType(type) {776  return isIntrinsicType(type) && type.intrinsicName === "error";777}778function isIntrinsicESSymbolType(type) {779  return isTypeFlagSet(type, ts9.TypeFlags.ESSymbol);780}781var IntrinsicTypeFlags = ts9.TypeFlags.Intrinsic ?? ts9.TypeFlags.Any | ts9.TypeFlags.Unknown | ts9.TypeFlags.String | ts9.TypeFlags.Number | ts9.TypeFlags.BigInt | ts9.TypeFlags.Boolean | ts9.TypeFlags.BooleanLiteral | ts9.TypeFlags.ESSymbol | ts9.TypeFlags.Void | ts9.TypeFlags.Undefined | ts9.TypeFlags.Null | ts9.TypeFlags.Never | ts9.TypeFlags.NonPrimitive;782function isIntrinsicNeverType(type) {783  return isTypeFlagSet(type, ts9.TypeFlags.Never);784}785function isIntrinsicNonPrimitiveType(type) {786  return isTypeFlagSet(type, ts9.TypeFlags.NonPrimitive);787}788function isIntrinsicNullType(type) {789  return isTypeFlagSet(type, ts9.TypeFlags.Null);790}791function isIntrinsicNumberType(type) {792  return isTypeFlagSet(type, ts9.TypeFlags.Number);793}794function isIntrinsicStringType(type) {795  return isTypeFlagSet(type, ts9.TypeFlags.String);796}797function isIntrinsicType(type) {798  return isTypeFlagSet(type, IntrinsicTypeFlags);799}800function isIntrinsicUndefinedType(type) {801  return isTypeFlagSet(type, ts9.TypeFlags.Undefined);802}803function isIntrinsicUnknownType(type) {804  return isTypeFlagSet(type, ts9.TypeFlags.Unknown);805}806function isIntrinsicVoidType(type) {807  return isTypeFlagSet(type, ts9.TypeFlags.Void);808}809function isConditionalType(type) {810  return isTypeFlagSet(type, ts9.TypeFlags.Conditional);811}812function isEnumType(type) {813  return isTypeFlagSet(type, ts9.TypeFlags.Enum);814}815function isFreshableType(type) {816  return isTypeFlagSet(type, ts9.TypeFlags.Freshable);817}818function isIndexedAccessType(type) {819  return isTypeFlagSet(type, ts9.TypeFlags.IndexedAccess);820}821function isIndexType(type) {822  return isTypeFlagSet(type, ts9.TypeFlags.Index);823}824function isInstantiableType(type) {825  return isTypeFlagSet(type, ts9.TypeFlags.Instantiable);826}827function isIntersectionType(type) {828  return isTypeFlagSet(type, ts9.TypeFlags.Intersection);829}830function isObjectType(type) {831  return isTypeFlagSet(type, ts9.TypeFlags.Object);832}833function isStringMappingType(type) {834  return isTypeFlagSet(type, ts9.TypeFlags.StringMapping);835}836function isSubstitutionType(type) {837  return isTypeFlagSet(type, ts9.TypeFlags.Substitution);838}839function isTypeParameter(type) {840  return isTypeFlagSet(type, ts9.TypeFlags.TypeParameter);841}842function isTypeVariable(type) {843  return isTypeFlagSet(type, ts9.TypeFlags.TypeVariable);844}845function isUnionOrIntersectionType(type) {846  return isTypeFlagSet(type, ts9.TypeFlags.UnionOrIntersection);847}848function isUnionType(type) {849  return isTypeFlagSet(type, ts9.TypeFlags.Union);850}851function isUniqueESSymbolType(type) {852  return isTypeFlagSet(type, ts9.TypeFlags.UniqueESSymbol);853}854 855// src/types/typeGuards/objects.ts856function isEvolvingArrayType(type) {857  return isObjectType(type) && isObjectFlagSet(type, ts9.ObjectFlags.EvolvingArray);858}859function isTupleType(type) {860  return isObjectType(type) && isObjectFlagSet(type, ts9.ObjectFlags.Tuple);861}862function isTypeReference(type) {863  return isObjectType(type) && isObjectFlagSet(type, ts9.ObjectFlags.Reference);864}865 866// src/types/typeGuards/compound.ts867function isFreshableIntrinsicType(type) {868  return isIntrinsicType(type) && isFreshableType(type);869}870function isTupleTypeReference(type) {871  return isTypeReference(type) && isTupleType(type.target);872}873function isBigIntLiteralType(type) {874  return isTypeFlagSet(type, ts9.TypeFlags.BigIntLiteral);875}876function isBooleanLiteralType(type) {877  return isTypeFlagSet(type, ts9.TypeFlags.BooleanLiteral);878}879function isFalseLiteralType(type) {880  return isBooleanLiteralType(type) && type.intrinsicName === "false";881}882function isLiteralType(type) {883  return isTypeFlagSet(type, ts9.TypeFlags.Literal);884}885function isNumberLiteralType(type) {886  return isTypeFlagSet(type, ts9.TypeFlags.NumberLiteral);887}888function isStringLiteralType(type) {889  return isTypeFlagSet(type, ts9.TypeFlags.StringLiteral);890}891function isTemplateLiteralType(type) {892  return isTypeFlagSet(type, ts9.TypeFlags.TemplateLiteral);893}894function isTrueLiteralType(type) {895  return isBooleanLiteralType(type) && type.intrinsicName === "true";896}897 898// src/types/getters.ts899function getCallSignaturesOfType(type) {900  if (isUnionType(type)) {901    const signatures = [];902    for (const subType of type.types) {903      signatures.push(...getCallSignaturesOfType(subType));904    }905    return signatures;906  }907  if (isIntersectionType(type)) {908    let signatures;909    for (const subType of type.types) {910      const sig = getCallSignaturesOfType(subType);911      if (sig.length !== 0) {912        if (signatures !== void 0) {913          return [];914        }915        signatures = sig;916      }917    }918    return signatures === void 0 ? [] : signatures;919  }920  return type.getCallSignatures();921}922function getPropertyOfType(type, name) {923  if (!name.startsWith("__")) {924    return type.getProperty(name);925  }926  return type.getProperties().find((s) => s.escapedName === name);927}928function getWellKnownSymbolPropertyOfType(type, wellKnownSymbolName, typeChecker) {929  const prefix = "__@" + wellKnownSymbolName;930  for (const prop of type.getProperties()) {931    if (!prop.name.startsWith(prefix)) {932      continue;933    }934    const declaration = prop.valueDeclaration ?? prop.getDeclarations()?.[0];935    if (!declaration || !isNamedDeclarationWithName(declaration) || declaration.name === void 0 || !ts9.isComputedPropertyName(declaration.name)) {936      continue;937    }938    const globalSymbol = typeChecker.getApparentType(939      typeChecker.getTypeAtLocation(declaration.name.expression)940    ).symbol;941    if (prop.escapedName === getPropertyNameOfWellKnownSymbol(942      typeChecker,943      globalSymbol,944      wellKnownSymbolName945    )) {946      return prop;947    }948  }949  return void 0;950}951function getPropertyNameOfWellKnownSymbol(typeChecker, symbolConstructor, symbolName) {952  const knownSymbol = symbolConstructor && typeChecker.getTypeOfSymbolAtLocation(953    symbolConstructor,954    // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access955    symbolConstructor.valueDeclaration956  ).getProperty(symbolName);957  const knownSymbolType = knownSymbol && typeChecker.getTypeOfSymbolAtLocation(958    knownSymbol,959    // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access960    knownSymbol.valueDeclaration961  );962  if (knownSymbolType && isUniqueESSymbolType(knownSymbolType)) {963    return knownSymbolType.escapedName;964  }965  return "__@" + symbolName;966}967function isBindableObjectDefinePropertyCall(node) {968  return node.arguments.length === 3 && isEntityNameExpression(node.arguments[0]) && isNumericOrStringLikeLiteral(node.arguments[1]) && ts9.isPropertyAccessExpression(node.expression) && node.expression.name.escapedText === "defineProperty" && ts9.isIdentifier(node.expression.expression) && node.expression.expression.escapedText === "Object";969}970function isInConstContext(node, typeChecker) {971  let current = node;972  while (true) {973    const parent = current.parent;974    outer: switch (parent.kind) {975      case ts9.SyntaxKind.ArrayLiteralExpression:976      case ts9.SyntaxKind.ObjectLiteralExpression:977      case ts9.SyntaxKind.ParenthesizedExpression:978      case ts9.SyntaxKind.TemplateExpression:979        current = parent;980        break;981      case ts9.SyntaxKind.AsExpression:982      case ts9.SyntaxKind.TypeAssertionExpression:983        return isConstAssertionExpression(parent);984      case ts9.SyntaxKind.CallExpression: {985        if (!ts9.isExpression(current)) {986          return false;987        }988        const functionSignature = typeChecker.getResolvedSignature(989          parent990        );991        if (functionSignature === void 0) {992          return false;993        }994        const argumentIndex = parent.arguments.indexOf(995          current996        );997        if (argumentIndex < 0) {998          return false;999        }1000        const parameterSymbol = functionSignature.getParameters()[argumentIndex];1001        if (parameterSymbol === void 0 || !("links" in parameterSymbol)) {1002          return false;1003        }1004        const parameterSymbolLinks = parameterSymbol.links;1005        const propertySymbol = parameterSymbolLinks.type?.getProperties()?.[argumentIndex];1006        if (propertySymbol === void 0 || !("links" in propertySymbol)) {1007          return false;1008        }1009        return !!propertySymbol.links && isTransientSymbolLinksFlagSet(1010          propertySymbol.links,1011          ts9.CheckFlags.Readonly1012        );1013      }1014      case ts9.SyntaxKind.PrefixUnaryExpression:1015        if (current.kind !== ts9.SyntaxKind.NumericLiteral) {1016          return false;1017        }1018        switch (parent.operator) {1019          case ts9.SyntaxKind.MinusToken:1020          case ts9.SyntaxKind.PlusToken:1021            current = parent;1022            break outer;1023          default:1024            return false;1025        }1026      case ts9.SyntaxKind.PropertyAssignment:1027        if (parent.initializer !== current) {1028          return false;1029        }1030        current = parent.parent;1031        break;1032      case ts9.SyntaxKind.ShorthandPropertyAssignment:1033        current = parent.parent;1034        break;1035      default:1036        return false;1037    }1038  }1039}1040 1041// src/types/utilities.ts1042function intersectionConstituents(type) {1043  return isIntersectionType(type) ? type.types : [type];1044}1045var intersectionTypeParts = intersectionConstituents;1046function isFalsyType(type) {1047  if (isTypeFlagSet(1048    type,1049    ts9.TypeFlags.Undefined | ts9.TypeFlags.Null | ts9.TypeFlags.Void1050  )) {1051    return true;1052  }1053  if (typeIsLiteral(type)) {1054    if (typeof type.value === "object") {1055      return type.value.base10Value === "0";1056    } else {1057      return !type.value;1058    }1059  }1060  return isFalseLiteralType(type);1061}1062function isPropertyReadonlyInType(type, name, typeChecker) {1063  let seenProperty = false;1064  let seenReadonlySignature = false;1065  for (const subType of unionConstituents(type)) {1066    if (getPropertyOfType(subType, name) === void 0) {1067      const index = (isNumericPropertyName(name) ? typeChecker.getIndexInfoOfType(subType, ts9.IndexKind.Number) : void 0) ?? typeChecker.getIndexInfoOfType(subType, ts9.IndexKind.String);1068      if (index?.isReadonly) {1069        if (seenProperty) {1070          return true;1071        }1072        seenReadonlySignature = true;1073      }1074    } else if (seenReadonlySignature || isReadonlyPropertyIntersection(subType, name, typeChecker)) {1075      return true;1076    } else {1077      seenProperty = true;1078    }1079  }1080  return false;1081}1082function isThenableType(typeChecker, node, type = typeChecker.getTypeAtLocation(node)) {1083  for (const constituent of unionConstituents(1084    typeChecker.getApparentType(type)1085  )) {1086    const then = constituent.getProperty("then");1087    if (then === void 0) {1088      continue;1089    }1090    const thenType = typeChecker.getTypeOfSymbolAtLocation(then, node);1091    for (const subConstituent of unionConstituents(thenType)) {1092      for (const signature of subConstituent.getCallSignatures()) {1093        if (signature.parameters.length !== 0 && isCallback(typeChecker, signature.parameters[0], node)) {1094          return true;1095        }1096      }1097    }1098  }1099  return false;1100}1101function symbolHasReadonlyDeclaration(symbol, typeChecker) {1102  return !!((symbol.flags & ts9.SymbolFlags.Accessor) === ts9.SymbolFlags.GetAccessor || symbol.declarations?.some(1103    (node) => isModifierFlagSet(node, ts9.ModifierFlags.Readonly) || ts9.isVariableDeclaration(node) && isNodeFlagSet(node.parent, ts9.NodeFlags.Const) || ts9.isCallExpression(node) && isReadonlyAssignmentDeclaration(node, typeChecker) || ts9.isEnumMember(node) || (ts9.isPropertyAssignment(node) || ts9.isShorthandPropertyAssignment(node)) && isInConstContext(node, typeChecker)1104  ));1105}1106function typeConstituents(type) {1107  return isIntersectionType(type) || isUnionType(type) ? type.types : [type];1108}1109function typeIsLiteral(type) {1110  if (isTsVersionAtLeast(5, 0)) {1111    return type.isLiteral();1112  } else {1113    return isTypeFlagSet(1114      type,1115      ts9.TypeFlags.StringLiteral | ts9.TypeFlags.NumberLiteral | ts9.TypeFlags.BigIntLiteral1116    );1117  }1118}1119var typeParts = typeConstituents;1120function unionConstituents(type) {1121  return isUnionType(type) ? type.types : [type];1122}1123var unionTypeParts = unionConstituents;1124function isCallback(typeChecker, param, node) {1125  let type = typeChecker.getApparentType(1126    typeChecker.getTypeOfSymbolAtLocation(param, node)1127  );1128  if (param.valueDeclaration.dotDotDotToken) {1129    type = type.getNumberIndexType();1130    if (type === void 0) {1131      return false;1132    }1133  }1134  for (const subType of unionConstituents(type)) {1135    if (subType.getCallSignatures().length !== 0) {1136      return true;1137    }1138  }1139  return false;1140}1141function isReadonlyAssignmentDeclaration(node, typeChecker) {1142  if (!isBindableObjectDefinePropertyCall(node)) {1143    return false;1144  }1145  const descriptorType = typeChecker.getTypeAtLocation(node.arguments[2]);1146  if (descriptorType.getProperty("value") === void 0) {1147    return descriptorType.getProperty("set") === void 0;1148  }1149  const writableProp = descriptorType.getProperty("writable");1150  if (writableProp === void 0) {1151    return false;1152  }1153  const writableType = writableProp.valueDeclaration !== void 0 && ts9.isPropertyAssignment(writableProp.valueDeclaration) ? typeChecker.getTypeAtLocation(writableProp.valueDeclaration.initializer) : typeChecker.getTypeOfSymbolAtLocation(writableProp, node.arguments[2]);1154  return isFalseLiteralType(writableType);1155}1156function isReadonlyPropertyFromMappedType(type, name, typeChecker) {1157  if (!isObjectType(type) || !isObjectFlagSet(type, ts9.ObjectFlags.Mapped)) {1158    return;1159  }1160  const declaration = type.symbol.declarations[0];1161  if (declaration.readonlyToken !== void 0 && !/^__@[^@]+$/.test(name)) {1162    return declaration.readonlyToken.kind !== ts9.SyntaxKind.MinusToken;1163  }1164  const { modifiersType } = type;1165  return modifiersType && isPropertyReadonlyInType(modifiersType, name, typeChecker);1166}1167function isReadonlyPropertyIntersection(type, name, typeChecker) {1168  const constituents = intersectionConstituents(type);1169  return constituents.some((constituent) => {1170    const prop = getPropertyOfType(constituent, name);1171    if (prop === void 0) {1172      return false;1173    }1174    if (prop.flags & ts9.SymbolFlags.Transient) {1175      if (/^(?:[1-9]\d*|0)$/.test(name) && isTupleTypeReference(constituent)) {1176        return constituent.target.readonly;1177      }1178      switch (isReadonlyPropertyFromMappedType(constituent, name, typeChecker)) {1179        case false:1180          return false;1181        case true:1182          return true;1183      }1184    }1185    return (1186      // members of namespace import1187      isSymbolFlagSet(prop, ts9.SymbolFlags.ValueModule) || // we unwrapped every mapped type, now we can check the actual declarations1188      // eslint-disable-next-line @typescript-eslint/no-deprecated -- Will be made private-only soon.1189      symbolHasReadonlyDeclaration(prop, typeChecker)1190    );1191  });1192}1193function identifierToKeywordKind(node) {1194  return "originalKeywordKind" in node ? node.originalKeywordKind : ts9.identifierToKeywordKind(node);1195}1196 1197// src/usage/declarations.ts1198var DeclarationDomain = /* @__PURE__ */ ((DeclarationDomain2) => {1199  DeclarationDomain2[DeclarationDomain2["Namespace"] = 1] = "Namespace";1200  DeclarationDomain2[DeclarationDomain2["Type"] = 2] = "Type";

Showing the first 1,200 of 2108 lines. Download the file for the rest.

Brunobkr/llama.cpp_AlgMor24_github · Team Ai