.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / tsutils / util / util.js
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/tsutils/util/util.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/tsutils/util/util.js
new file mode 100644 (file)
index 0000000..0109fea
--- /dev/null
@@ -0,0 +1,1686 @@
+"use strict";\r
+Object.defineProperty(exports, "__esModule", { value: true });\r
+exports.isValidIdentifier = exports.getLineBreakStyle = exports.getLineRanges = exports.forEachComment = exports.forEachTokenWithTrivia = exports.forEachToken = exports.isFunctionWithBody = exports.hasOwnThisReference = exports.isBlockScopeBoundary = exports.isFunctionScopeBoundary = exports.isTypeScopeBoundary = exports.isScopeBoundary = exports.ScopeBoundarySelector = exports.ScopeBoundary = exports.isInSingleStatementContext = exports.isBlockScopedDeclarationStatement = exports.isBlockScopedVariableDeclaration = exports.isBlockScopedVariableDeclarationList = exports.getVariableDeclarationKind = exports.VariableDeclarationKind = exports.forEachDeclaredVariable = exports.forEachDestructuringIdentifier = exports.getPropertyName = exports.getWrappedNodeAtPosition = exports.getAstNodeAtPosition = exports.commentText = exports.isPositionInComment = exports.getCommentAtPosition = exports.getTokenAtPosition = exports.getNextToken = exports.getPreviousToken = exports.getNextStatement = exports.getPreviousStatement = exports.isModifierFlagSet = exports.isObjectFlagSet = exports.isSymbolFlagSet = exports.isTypeFlagSet = exports.isNodeFlagSet = exports.hasAccessModifier = exports.isParameterProperty = exports.hasModifier = exports.getModifier = exports.isThisParameter = exports.isKeywordKind = exports.isJsDocKind = exports.isTypeNodeKind = exports.isAssignmentKind = exports.isNodeKind = exports.isTokenKind = exports.getChildOfKind = void 0;\r
+exports.getBaseOfClassLikeExpression = exports.hasExhaustiveCaseClauses = exports.formatPseudoBigInt = exports.unwrapParentheses = exports.getSingleLateBoundPropertyNameOfPropertyName = exports.getLateBoundPropertyNamesOfPropertyName = exports.getLateBoundPropertyNames = exports.getPropertyNameOfWellKnownSymbol = exports.isWellKnownSymbolLiterally = exports.isBindableObjectDefinePropertyCall = exports.isReadonlyAssignmentDeclaration = exports.isInConstContext = exports.isConstAssertion = exports.getTsCheckDirective = exports.getCheckJsDirective = exports.isAmbientModule = exports.isCompilerOptionEnabled = exports.isStrictCompilerOptionEnabled = exports.getIIFE = exports.isAmbientModuleBlock = exports.isStatementInAmbientContext = exports.findImportLikeNodes = exports.findImports = exports.ImportKind = exports.parseJsDocOfNode = exports.getJsDoc = exports.canHaveJsDoc = exports.isReassignmentTarget = exports.getAccessKind = exports.AccessKind = exports.isExpressionValueUsed = exports.getDeclarationOfBindingElement = exports.hasSideEffects = exports.SideEffectOptions = exports.isSameLine = exports.isNumericPropertyName = exports.isValidJsxIdentifier = exports.isValidNumericLiteral = exports.isValidPropertyName = exports.isValidPropertyAccess = void 0;\r
+const ts = require("typescript");\r
+const node_1 = require("../typeguard/node");\r
+const _3_2_1 = require("../typeguard/3.2");\r
+const type_1 = require("./type");\r
+function getChildOfKind(node, kind, sourceFile) {\r
+    for (const child of node.getChildren(sourceFile))\r
+        if (child.kind === kind)\r
+            return child;\r
+}\r
+exports.getChildOfKind = getChildOfKind;\r
+function isTokenKind(kind) {\r
+    return kind >= ts.SyntaxKind.FirstToken && kind <= ts.SyntaxKind.LastToken;\r
+}\r
+exports.isTokenKind = isTokenKind;\r
+function isNodeKind(kind) {\r
+    return kind >= ts.SyntaxKind.FirstNode;\r
+}\r
+exports.isNodeKind = isNodeKind;\r
+function isAssignmentKind(kind) {\r
+    return kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;\r
+}\r
+exports.isAssignmentKind = isAssignmentKind;\r
+function isTypeNodeKind(kind) {\r
+    return kind >= ts.SyntaxKind.FirstTypeNode && kind <= ts.SyntaxKind.LastTypeNode;\r
+}\r
+exports.isTypeNodeKind = isTypeNodeKind;\r
+function isJsDocKind(kind) {\r
+    return kind >= ts.SyntaxKind.FirstJSDocNode && kind <= ts.SyntaxKind.LastJSDocNode;\r
+}\r
+exports.isJsDocKind = isJsDocKind;\r
+function isKeywordKind(kind) {\r
+    return kind >= ts.SyntaxKind.FirstKeyword && kind <= ts.SyntaxKind.LastKeyword;\r
+}\r
+exports.isKeywordKind = isKeywordKind;\r
+function isThisParameter(parameter) {\r
+    return parameter.name.kind === ts.SyntaxKind.Identifier && parameter.name.originalKeywordKind === ts.SyntaxKind.ThisKeyword;\r
+}\r
+exports.isThisParameter = isThisParameter;\r
+function getModifier(node, kind) {\r
+    if (node.modifiers !== undefined)\r
+        for (const modifier of node.modifiers)\r
+            if (modifier.kind === kind)\r
+                return modifier;\r
+}\r
+exports.getModifier = getModifier;\r
+function hasModifier(modifiers, ...kinds) {\r
+    if (modifiers === undefined)\r
+        return false;\r
+    for (const modifier of modifiers)\r
+        if (kinds.includes(modifier.kind))\r
+            return true;\r
+    return false;\r
+}\r
+exports.hasModifier = hasModifier;\r
+function isParameterProperty(node) {\r
+    return hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword, ts.SyntaxKind.ReadonlyKeyword);\r
+}\r
+exports.isParameterProperty = isParameterProperty;\r
+function hasAccessModifier(node) {\r
+    return isModifierFlagSet(node, ts.ModifierFlags.AccessibilityModifier);\r
+}\r
+exports.hasAccessModifier = hasAccessModifier;\r
+function isFlagSet(obj, flag) {\r
+    return (obj.flags & flag) !== 0;\r
+}\r
+exports.isNodeFlagSet = isFlagSet;\r
+exports.isTypeFlagSet = isFlagSet;\r
+exports.isSymbolFlagSet = isFlagSet;\r
+function isObjectFlagSet(objectType, flag) {\r
+    return (objectType.objectFlags & flag) !== 0;\r
+}\r
+exports.isObjectFlagSet = isObjectFlagSet;\r
+function isModifierFlagSet(node, flag) {\r
+    return (ts.getCombinedModifierFlags(node) & flag) !== 0;\r
+}\r
+exports.isModifierFlagSet = isModifierFlagSet;\r
+function getPreviousStatement(statement) {\r
+    const parent = statement.parent;\r
+    if (node_1.isBlockLike(parent)) {\r
+        const index = parent.statements.indexOf(statement);\r
+        if (index > 0)\r
+            return parent.statements[index - 1];\r
+    }\r
+}\r
+exports.getPreviousStatement = getPreviousStatement;\r
+function getNextStatement(statement) {\r
+    const parent = statement.parent;\r
+    if (node_1.isBlockLike(parent)) {\r
+        const index = parent.statements.indexOf(statement);\r
+        if (index < parent.statements.length)\r
+            return parent.statements[index + 1];\r
+    }\r
+}\r
+exports.getNextStatement = getNextStatement;\r
+/** Returns the token before the start of `node` or `undefined` if there is none. */\r
+function getPreviousToken(node, sourceFile) {\r
+    const { pos } = node;\r
+    if (pos === 0)\r
+        return;\r
+    do\r
+        node = node.parent;\r
+    while (node.pos === pos);\r
+    return getTokenAtPositionWorker(node, pos - 1, sourceFile !== null && sourceFile !== void 0 ? sourceFile : node.getSourceFile(), false);\r
+}\r
+exports.getPreviousToken = getPreviousToken;\r
+/** Returns the next token that begins after the end of `node`. Returns `undefined` for SourceFile and EndOfFileToken */\r
+function getNextToken(node, sourceFile) {\r
+    if (node.kind === ts.SyntaxKind.SourceFile || node.kind === ts.SyntaxKind.EndOfFileToken)\r
+        return;\r
+    const end = node.end;\r
+    node = node.parent;\r
+    while (node.end === end) {\r
+        if (node.parent === undefined)\r
+            return node.endOfFileToken;\r
+        node = node.parent;\r
+    }\r
+    return getTokenAtPositionWorker(node, end, sourceFile !== null && sourceFile !== void 0 ? sourceFile : node.getSourceFile(), false);\r
+}\r
+exports.getNextToken = getNextToken;\r
+/** Returns the token at or following the specified position or undefined if none is found inside `parent`. */\r
+function getTokenAtPosition(parent, pos, sourceFile, allowJsDoc) {\r
+    if (pos < parent.pos || pos >= parent.end)\r
+        return;\r
+    if (isTokenKind(parent.kind))\r
+        return parent;\r
+    return getTokenAtPositionWorker(parent, pos, sourceFile !== null && sourceFile !== void 0 ? sourceFile : parent.getSourceFile(), allowJsDoc === true);\r
+}\r
+exports.getTokenAtPosition = getTokenAtPosition;\r
+function getTokenAtPositionWorker(node, pos, sourceFile, allowJsDoc) {\r
+    if (!allowJsDoc) {\r
+        // if we are not interested in JSDoc, we can skip to the deepest AST node at the given position\r
+        node = getAstNodeAtPosition(node, pos);\r
+        if (isTokenKind(node.kind))\r
+            return node;\r
+    }\r
+    outer: while (true) {\r
+        for (const child of node.getChildren(sourceFile)) {\r
+            if (child.end > pos && (allowJsDoc || child.kind !== ts.SyntaxKind.JSDocComment)) {\r
+                if (isTokenKind(child.kind))\r
+                    return child;\r
+                // next token is nested in another node\r
+                node = child;\r
+                continue outer;\r
+            }\r
+        }\r
+        return;\r
+    }\r
+}\r
+/**\r
+ * Return the comment at the specified position.\r
+ * You can pass an optional `parent` to avoid some work finding the corresponding token starting at `sourceFile`.\r
+ * If the `parent` parameter is passed, `pos` must be between `parent.pos` and `parent.end`.\r
+*/\r
+function getCommentAtPosition(sourceFile, pos, parent = sourceFile) {\r
+    const token = getTokenAtPosition(parent, pos, sourceFile);\r
+    if (token === undefined || token.kind === ts.SyntaxKind.JsxText || pos >= token.end - (ts.tokenToString(token.kind) || '').length)\r
+        return;\r
+    const startPos = token.pos === 0\r
+        ? (ts.getShebang(sourceFile.text) || '').length\r
+        : token.pos;\r
+    return startPos !== 0 && ts.forEachTrailingCommentRange(sourceFile.text, startPos, commentAtPositionCallback, pos) ||\r
+        ts.forEachLeadingCommentRange(sourceFile.text, startPos, commentAtPositionCallback, pos);\r
+}\r
+exports.getCommentAtPosition = getCommentAtPosition;\r
+function commentAtPositionCallback(pos, end, kind, _nl, at) {\r
+    return at >= pos && at < end ? { pos, end, kind } : undefined;\r
+}\r
+/**\r
+ * Returns whether the specified position is inside a comment.\r
+ * You can pass an optional `parent` to avoid some work finding the corresponding token starting at `sourceFile`.\r
+ * If the `parent` parameter is passed, `pos` must be between `parent.pos` and `parent.end`.\r
+ */\r
+function isPositionInComment(sourceFile, pos, parent) {\r
+    return getCommentAtPosition(sourceFile, pos, parent) !== undefined;\r
+}\r
+exports.isPositionInComment = isPositionInComment;\r
+function commentText(sourceText, comment) {\r
+    return sourceText.substring(comment.pos + 2, comment.kind === ts.SyntaxKind.SingleLineCommentTrivia ? comment.end : comment.end - 2);\r
+}\r
+exports.commentText = commentText;\r
+/** Returns the deepest AST Node at `pos`. Returns undefined if `pos` is outside of the range of `node` */\r
+function getAstNodeAtPosition(node, pos) {\r
+    if (node.pos > pos || node.end <= pos)\r
+        return;\r
+    while (isNodeKind(node.kind)) {\r
+        const nested = ts.forEachChild(node, (child) => child.pos <= pos && child.end > pos ? child : undefined);\r
+        if (nested === undefined)\r
+            break;\r
+        node = nested;\r
+    }\r
+    return node;\r
+}\r
+exports.getAstNodeAtPosition = getAstNodeAtPosition;\r
+/**\r
+ * Returns the NodeWrap of deepest AST node that contains `pos` between its `pos` and `end`.\r
+ * Only returns undefined if pos is outside of `wrap`\r
+ */\r
+function getWrappedNodeAtPosition(wrap, pos) {\r
+    if (wrap.node.pos > pos || wrap.node.end <= pos)\r
+        return;\r
+    outer: while (true) {\r
+        for (const child of wrap.children) {\r
+            if (child.node.pos > pos)\r
+                return wrap;\r
+            if (child.node.end > pos) {\r
+                wrap = child;\r
+                continue outer;\r
+            }\r
+        }\r
+        return wrap;\r
+    }\r
+}\r
+exports.getWrappedNodeAtPosition = getWrappedNodeAtPosition;\r
+function getPropertyName(propertyName) {\r
+    if (propertyName.kind === ts.SyntaxKind.ComputedPropertyName) {\r
+        const expression = unwrapParentheses(propertyName.expression);\r
+        if (node_1.isPrefixUnaryExpression(expression)) {\r
+            let negate = false;\r
+            switch (expression.operator) {\r
+                case ts.SyntaxKind.MinusToken:\r
+                    negate = true;\r
+                // falls through\r
+                case ts.SyntaxKind.PlusToken:\r
+                    return node_1.isNumericLiteral(expression.operand)\r
+                        ? `${negate ? '-' : ''}${expression.operand.text}`\r
+                        : _3_2_1.isBigIntLiteral(expression.operand)\r
+                            ? `${negate ? '-' : ''}${expression.operand.text.slice(0, -1)}`\r
+                            : undefined;\r
+                default:\r
+                    return;\r
+            }\r
+        }\r
+        if (_3_2_1.isBigIntLiteral(expression))\r
+            // handle BigInt, even though TypeScript doesn't allow BigInt as computed property name\r
+            return expression.text.slice(0, -1);\r
+        if (node_1.isNumericOrStringLikeLiteral(expression))\r
+            return expression.text;\r
+        return;\r
+    }\r
+    return propertyName.kind === ts.SyntaxKind.PrivateIdentifier ? undefined : propertyName.text;\r
+}\r
+exports.getPropertyName = getPropertyName;\r
+function forEachDestructuringIdentifier(pattern, fn) {\r
+    for (const element of pattern.elements) {\r
+        if (element.kind !== ts.SyntaxKind.BindingElement)\r
+            continue;\r
+        let result;\r
+        if (element.name.kind === ts.SyntaxKind.Identifier) {\r
+            result = fn(element);\r
+        }\r
+        else {\r
+            result = forEachDestructuringIdentifier(element.name, fn);\r
+        }\r
+        if (result)\r
+            return result;\r
+    }\r
+}\r
+exports.forEachDestructuringIdentifier = forEachDestructuringIdentifier;\r
+function forEachDeclaredVariable(declarationList, cb) {\r
+    for (const declaration of declarationList.declarations) {\r
+        let result;\r
+        if (declaration.name.kind === ts.SyntaxKind.Identifier) {\r
+            result = cb(declaration);\r
+        }\r
+        else {\r
+            result = forEachDestructuringIdentifier(declaration.name, cb);\r
+        }\r
+        if (result)\r
+            return result;\r
+    }\r
+}\r
+exports.forEachDeclaredVariable = forEachDeclaredVariable;\r
+var VariableDeclarationKind;\r
+(function (VariableDeclarationKind) {\r
+    VariableDeclarationKind[VariableDeclarationKind["Var"] = 0] = "Var";\r
+    VariableDeclarationKind[VariableDeclarationKind["Let"] = 1] = "Let";\r
+    VariableDeclarationKind[VariableDeclarationKind["Const"] = 2] = "Const";\r
+})(VariableDeclarationKind = exports.VariableDeclarationKind || (exports.VariableDeclarationKind = {}));\r
+function getVariableDeclarationKind(declarationList) {\r
+    if (declarationList.flags & ts.NodeFlags.Let)\r
+        return 1 /* Let */;\r
+    if (declarationList.flags & ts.NodeFlags.Const)\r
+        return 2 /* Const */;\r
+    return 0 /* Var */;\r
+}\r
+exports.getVariableDeclarationKind = getVariableDeclarationKind;\r
+function isBlockScopedVariableDeclarationList(declarationList) {\r
+    return (declarationList.flags & ts.NodeFlags.BlockScoped) !== 0;\r
+}\r
+exports.isBlockScopedVariableDeclarationList = isBlockScopedVariableDeclarationList;\r
+function isBlockScopedVariableDeclaration(declaration) {\r
+    const parent = declaration.parent;\r
+    return parent.kind === ts.SyntaxKind.CatchClause ||\r
+        isBlockScopedVariableDeclarationList(parent);\r
+}\r
+exports.isBlockScopedVariableDeclaration = isBlockScopedVariableDeclaration;\r
+function isBlockScopedDeclarationStatement(statement) {\r
+    switch (statement.kind) {\r
+        case ts.SyntaxKind.VariableStatement:\r
+            return isBlockScopedVariableDeclarationList(statement.declarationList);\r
+        case ts.SyntaxKind.ClassDeclaration:\r
+        case ts.SyntaxKind.EnumDeclaration:\r
+        case ts.SyntaxKind.InterfaceDeclaration:\r
+        case ts.SyntaxKind.TypeAliasDeclaration:\r
+            return true;\r
+        default:\r
+            return false;\r
+    }\r
+}\r
+exports.isBlockScopedDeclarationStatement = isBlockScopedDeclarationStatement;\r
+function isInSingleStatementContext(statement) {\r
+    switch (statement.parent.kind) {\r
+        case ts.SyntaxKind.ForStatement:\r
+        case ts.SyntaxKind.ForInStatement:\r
+        case ts.SyntaxKind.ForOfStatement:\r
+        case ts.SyntaxKind.WhileStatement:\r
+        case ts.SyntaxKind.DoStatement:\r
+        case ts.SyntaxKind.IfStatement:\r
+        case ts.SyntaxKind.WithStatement:\r
+        case ts.SyntaxKind.LabeledStatement:\r
+            return true;\r
+        default:\r
+            return false;\r
+    }\r
+}\r
+exports.isInSingleStatementContext = isInSingleStatementContext;\r
+var ScopeBoundary;\r
+(function (ScopeBoundary) {\r
+    ScopeBoundary[ScopeBoundary["None"] = 0] = "None";\r
+    ScopeBoundary[ScopeBoundary["Function"] = 1] = "Function";\r
+    ScopeBoundary[ScopeBoundary["Block"] = 2] = "Block";\r
+    ScopeBoundary[ScopeBoundary["Type"] = 4] = "Type";\r
+    ScopeBoundary[ScopeBoundary["ConditionalType"] = 8] = "ConditionalType";\r
+})(ScopeBoundary = exports.ScopeBoundary || (exports.ScopeBoundary = {}));\r
+var ScopeBoundarySelector;\r
+(function (ScopeBoundarySelector) {\r
+    ScopeBoundarySelector[ScopeBoundarySelector["Function"] = 1] = "Function";\r
+    ScopeBoundarySelector[ScopeBoundarySelector["Block"] = 3] = "Block";\r
+    ScopeBoundarySelector[ScopeBoundarySelector["Type"] = 7] = "Type";\r
+    ScopeBoundarySelector[ScopeBoundarySelector["InferType"] = 8] = "InferType";\r
+})(ScopeBoundarySelector = exports.ScopeBoundarySelector || (exports.ScopeBoundarySelector = {}));\r
+function isScopeBoundary(node) {\r
+    return isFunctionScopeBoundary(node) || isBlockScopeBoundary(node) || isTypeScopeBoundary(node);\r
+}\r
+exports.isScopeBoundary = isScopeBoundary;\r
+function isTypeScopeBoundary(node) {\r
+    switch (node.kind) {\r
+        case ts.SyntaxKind.InterfaceDeclaration:\r
+        case ts.SyntaxKind.TypeAliasDeclaration:\r
+        case ts.SyntaxKind.MappedType:\r
+            return 4 /* Type */;\r
+        case ts.SyntaxKind.ConditionalType:\r
+            return 8 /* ConditionalType */;\r
+        default:\r
+            return 0 /* None */;\r
+    }\r
+}\r
+exports.isTypeScopeBoundary = isTypeScopeBoundary;\r
+function isFunctionScopeBoundary(node) {\r
+    switch (node.kind) {\r
+        case ts.SyntaxKind.FunctionExpression:\r
+        case ts.SyntaxKind.ArrowFunction:\r
+        case ts.SyntaxKind.Constructor:\r
+        case ts.SyntaxKind.ModuleDeclaration:\r
+        case ts.SyntaxKind.ClassDeclaration:\r
+        case ts.SyntaxKind.ClassExpression:\r
+        case ts.SyntaxKind.EnumDeclaration:\r
+        case ts.SyntaxKind.MethodDeclaration:\r
+        case ts.SyntaxKind.FunctionDeclaration:\r
+        case ts.SyntaxKind.GetAccessor:\r
+        case ts.SyntaxKind.SetAccessor:\r
+        case ts.SyntaxKind.MethodSignature:\r
+        case ts.SyntaxKind.CallSignature:\r
+        case ts.SyntaxKind.ConstructSignature:\r
+        case ts.SyntaxKind.ConstructorType:\r
+        case ts.SyntaxKind.FunctionType:\r
+            return 1 /* Function */;\r
+        case ts.SyntaxKind.SourceFile:\r
+            // if SourceFile is no module, it contributes to the global scope and is therefore no scope boundary\r
+            return ts.isExternalModule(node) ? 1 /* Function */ : 0 /* None */;\r
+        default:\r
+            return 0 /* None */;\r
+    }\r
+}\r
+exports.isFunctionScopeBoundary = isFunctionScopeBoundary;\r
+function isBlockScopeBoundary(node) {\r
+    switch (node.kind) {\r
+        case ts.SyntaxKind.Block:\r
+            const parent = node.parent;\r
+            return parent.kind !== ts.SyntaxKind.CatchClause &&\r
+                // blocks inside SourceFile are block scope boundaries\r
+                (parent.kind === ts.SyntaxKind.SourceFile ||\r
+                    // blocks that are direct children of a function scope boundary are no scope boundary\r
+                    // for example the FunctionBlock is part of the function scope of the containing function\r
+                    !isFunctionScopeBoundary(parent))\r
+                ? 2 /* Block */\r
+                : 0 /* None */;\r
+        case ts.SyntaxKind.ForStatement:\r
+        case ts.SyntaxKind.ForInStatement:\r
+        case ts.SyntaxKind.ForOfStatement:\r
+        case ts.SyntaxKind.CaseBlock:\r
+        case ts.SyntaxKind.CatchClause:\r
+        case ts.SyntaxKind.WithStatement:\r
+            return 2 /* Block */;\r
+        default:\r
+            return 0 /* None */;\r
+    }\r
+}\r
+exports.isBlockScopeBoundary = isBlockScopeBoundary;\r
+/** Returns true for scope boundaries that have their own `this` reference instead of inheriting it from the containing scope */\r
+function hasOwnThisReference(node) {\r
+    switch (node.kind) {\r
+        case ts.SyntaxKind.ClassDeclaration:\r
+        case ts.SyntaxKind.ClassExpression:\r
+        case ts.SyntaxKind.FunctionExpression:\r
+            return true;\r
+        case ts.SyntaxKind.FunctionDeclaration:\r
+            return node.body !== undefined;\r
+        case ts.SyntaxKind.MethodDeclaration:\r
+        case ts.SyntaxKind.GetAccessor:\r
+        case ts.SyntaxKind.SetAccessor:\r
+            return node.parent.kind === ts.SyntaxKind.ObjectLiteralExpression;\r
+        default:\r
+            return false;\r
+    }\r
+}\r
+exports.hasOwnThisReference = hasOwnThisReference;\r
+function isFunctionWithBody(node) {\r
+    switch (node.kind) {\r
+        case ts.SyntaxKind.GetAccessor:\r
+        case ts.SyntaxKind.SetAccessor:\r
+        case ts.SyntaxKind.FunctionDeclaration:\r
+        case ts.SyntaxKind.MethodDeclaration:\r
+        case ts.SyntaxKind.Constructor:\r
+            return node.body !== undefined;\r
+        case ts.SyntaxKind.FunctionExpression:\r
+        case ts.SyntaxKind.ArrowFunction:\r
+            return true;\r
+        default:\r
+            return false;\r
+    }\r
+}\r
+exports.isFunctionWithBody = isFunctionWithBody;\r
+/**\r
+ * Iterate over all tokens of `node`\r
+ *\r
+ * @param node The node whose tokens should be visited\r
+ * @param cb Is called for every token contained in `node`\r
+ */\r
+function forEachToken(node, cb, sourceFile = node.getSourceFile()) {\r
+    const queue = [];\r
+    while (true) {\r
+        if (isTokenKind(node.kind)) {\r
+            cb(node);\r
+        }\r
+        else if (node.kind !== ts.SyntaxKind.JSDocComment) {\r
+            const children = node.getChildren(sourceFile);\r
+            if (children.length === 1) {\r
+                node = children[0];\r
+                continue;\r
+            }\r
+            for (let i = children.length - 1; i >= 0; --i)\r
+                queue.push(children[i]); // add children in reverse order, when we pop the next element from the queue, it's the first child\r
+        }\r
+        if (queue.length === 0)\r
+            break;\r
+        node = queue.pop();\r
+    }\r
+}\r
+exports.forEachToken = forEachToken;\r
+/**\r
+ * Iterate over all tokens and trivia of `node`\r
+ *\r
+ * @description JsDoc comments are treated like regular comments\r
+ *\r
+ * @param node The node whose tokens should be visited\r
+ * @param cb Is called for every token contained in `node` and trivia before the token\r
+ */\r
+function forEachTokenWithTrivia(node, cb, sourceFile = node.getSourceFile()) {\r
+    const fullText = sourceFile.text;\r
+    const scanner = ts.createScanner(sourceFile.languageVersion, false, sourceFile.languageVariant, fullText);\r
+    return forEachToken(node, (token) => {\r
+        const tokenStart = token.kind === ts.SyntaxKind.JsxText || token.pos === token.end ? token.pos : token.getStart(sourceFile);\r
+        if (tokenStart !== token.pos) {\r
+            // we only have to handle trivia before each token. whitespace at the end of the file is followed by EndOfFileToken\r
+            scanner.setTextPos(token.pos);\r
+            let kind = scanner.scan();\r
+            let pos = scanner.getTokenPos();\r
+            while (pos < tokenStart) {\r
+                const textPos = scanner.getTextPos();\r
+                cb(fullText, kind, { pos, end: textPos }, token.parent);\r
+                if (textPos === tokenStart)\r
+                    break;\r
+                kind = scanner.scan();\r
+                pos = scanner.getTokenPos();\r
+            }\r
+        }\r
+        return cb(fullText, token.kind, { end: token.end, pos: tokenStart }, token.parent);\r
+    }, sourceFile);\r
+}\r
+exports.forEachTokenWithTrivia = forEachTokenWithTrivia;\r
+/** Iterate over all comments owned by `node` or its children */\r
+function forEachComment(node, cb, sourceFile = node.getSourceFile()) {\r
+    /* Visit all tokens and skip trivia.\r
+       Comment ranges between tokens are parsed without the need of a scanner.\r
+       forEachTokenWithWhitespace does intentionally not pay attention to the correct comment ownership of nodes as it always\r
+       scans all trivia before each token, which could include trailing comments of the previous token.\r
+       Comment onwership is done right in this function*/\r
+    const fullText = sourceFile.text;\r
+    const notJsx = sourceFile.languageVariant !== ts.LanguageVariant.JSX;\r
+    return forEachToken(node, (token) => {\r
+        if (token.pos === token.end)\r
+            return;\r
+        if (token.kind !== ts.SyntaxKind.JsxText)\r
+            ts.forEachLeadingCommentRange(fullText, \r
+            // skip shebang at position 0\r
+            token.pos === 0 ? (ts.getShebang(fullText) || '').length : token.pos, commentCallback);\r
+        if (notJsx || canHaveTrailingTrivia(token))\r
+            return ts.forEachTrailingCommentRange(fullText, token.end, commentCallback);\r
+    }, sourceFile);\r
+    function commentCallback(pos, end, kind) {\r
+        cb(fullText, { pos, end, kind });\r
+    }\r
+}\r
+exports.forEachComment = forEachComment;\r
+/** Exclude trailing positions that would lead to scanning for trivia inside JsxText */\r
+function canHaveTrailingTrivia(token) {\r
+    switch (token.kind) {\r
+        case ts.SyntaxKind.CloseBraceToken:\r
+            // after a JsxExpression inside a JsxElement's body can only be other JsxChild, but no trivia\r
+            return token.parent.kind !== ts.SyntaxKind.JsxExpression || !isJsxElementOrFragment(token.parent.parent);\r
+        case ts.SyntaxKind.GreaterThanToken:\r
+            switch (token.parent.kind) {\r
+                case ts.SyntaxKind.JsxOpeningElement:\r
+                    // if end is not equal, this is part of the type arguments list. in all other cases it would be inside the element body\r
+                    return token.end !== token.parent.end;\r
+                case ts.SyntaxKind.JsxOpeningFragment:\r
+                    return false; // would be inside the fragment\r
+                case ts.SyntaxKind.JsxSelfClosingElement:\r
+                    return token.end !== token.parent.end || // if end is not equal, this is part of the type arguments list\r
+                        !isJsxElementOrFragment(token.parent.parent); // there's only trailing trivia if it's the end of the top element\r
+                case ts.SyntaxKind.JsxClosingElement:\r
+                case ts.SyntaxKind.JsxClosingFragment:\r
+                    // there's only trailing trivia if it's the end of the top element\r
+                    return !isJsxElementOrFragment(token.parent.parent.parent);\r
+            }\r
+    }\r
+    return true;\r
+}\r
+function isJsxElementOrFragment(node) {\r
+    return node.kind === ts.SyntaxKind.JsxElement || node.kind === ts.SyntaxKind.JsxFragment;\r
+}\r
+function getLineRanges(sourceFile) {\r
+    const lineStarts = sourceFile.getLineStarts();\r
+    const result = [];\r
+    const length = lineStarts.length;\r
+    const sourceText = sourceFile.text;\r
+    let pos = 0;\r
+    for (let i = 1; i < length; ++i) {\r
+        const end = lineStarts[i];\r
+        let lineEnd = end;\r
+        for (; lineEnd > pos; --lineEnd)\r
+            if (!ts.isLineBreak(sourceText.charCodeAt(lineEnd - 1)))\r
+                break;\r
+        result.push({\r
+            pos,\r
+            end,\r
+            contentLength: lineEnd - pos,\r
+        });\r
+        pos = end;\r
+    }\r
+    result.push({\r
+        pos,\r
+        end: sourceFile.end,\r
+        contentLength: sourceFile.end - pos,\r
+    });\r
+    return result;\r
+}\r
+exports.getLineRanges = getLineRanges;\r
+/** Get the line break style used in sourceFile. This function only looks at the first line break. If there is none, \n is assumed. */\r
+function getLineBreakStyle(sourceFile) {\r
+    const lineStarts = sourceFile.getLineStarts();\r
+    return lineStarts.length === 1 || lineStarts[1] < 2 || sourceFile.text[lineStarts[1] - 2] !== '\r'\r
+        ? '\n'\r
+        : '\r\n';\r
+}\r
+exports.getLineBreakStyle = getLineBreakStyle;\r
+let cachedScanner;\r
+function scanToken(text, languageVersion) {\r
+    if (cachedScanner === undefined) {\r
+        // cache scanner\r
+        cachedScanner = ts.createScanner(languageVersion, false, undefined, text);\r
+    }\r
+    else {\r
+        cachedScanner.setScriptTarget(languageVersion);\r
+        cachedScanner.setText(text);\r
+    }\r
+    cachedScanner.scan();\r
+    return cachedScanner;\r
+}\r
+/**\r
+ * Determines whether the given text parses as a standalone identifier.\r
+ * This is not a guarantee that it works in every context. The property name in PropertyAccessExpressions for example allows reserved words.\r
+ * Depending on the context it could be parsed as contextual keyword or TypeScript keyword.\r
+ */\r
+function isValidIdentifier(text, languageVersion = ts.ScriptTarget.Latest) {\r
+    const scan = scanToken(text, languageVersion);\r
+    return scan.isIdentifier() && scan.getTextPos() === text.length && scan.getTokenPos() === 0;\r
+}\r
+exports.isValidIdentifier = isValidIdentifier;\r
+function charSize(ch) {\r
+    return ch >= 0x10000 ? 2 : 1;\r
+}\r
+/**\r
+ * Determines whether the given text can be used to access a property with a PropertyAccessExpression while preserving the property's name.\r
+ */\r
+function isValidPropertyAccess(text, languageVersion = ts.ScriptTarget.Latest) {\r
+    if (text.length === 0)\r
+        return false;\r
+    let ch = text.codePointAt(0);\r
+    if (!ts.isIdentifierStart(ch, languageVersion))\r
+        return false;\r
+    for (let i = charSize(ch); i < text.length; i += charSize(ch)) {\r
+        ch = text.codePointAt(i);\r
+        if (!ts.isIdentifierPart(ch, languageVersion))\r
+            return false;\r
+    }\r
+    return true;\r
+}\r
+exports.isValidPropertyAccess = isValidPropertyAccess;\r
+/**\r
+ * Determines whether the given text can be used as unquoted name of a property declaration while preserving the property's name.\r
+ */\r
+function isValidPropertyName(text, languageVersion = ts.ScriptTarget.Latest) {\r
+    if (isValidPropertyAccess(text, languageVersion))\r
+        return true;\r
+    const scan = scanToken(text, languageVersion);\r
+    return scan.getTextPos() === text.length &&\r
+        scan.getToken() === ts.SyntaxKind.NumericLiteral && scan.getTokenValue() === text; // ensure stringified number equals literal\r
+}\r
+exports.isValidPropertyName = isValidPropertyName;\r
+/**\r
+ * Determines whether the given text can be parsed as a numeric literal.\r
+ */\r
+function isValidNumericLiteral(text, languageVersion = ts.ScriptTarget.Latest) {\r
+    const scan = scanToken(text, languageVersion);\r
+    return scan.getToken() === ts.SyntaxKind.NumericLiteral && scan.getTextPos() === text.length && scan.getTokenPos() === 0;\r
+}\r
+exports.isValidNumericLiteral = isValidNumericLiteral;\r
+/**\r
+ * Determines whether the given text can be used as JSX tag or attribute name while preserving the exact name.\r
+ */\r
+function isValidJsxIdentifier(text, languageVersion = ts.ScriptTarget.Latest) {\r
+    if (text.length === 0)\r
+        return false;\r
+    let seenNamespaceSeparator = false;\r
+    let ch = text.codePointAt(0);\r
+    if (!ts.isIdentifierStart(ch, languageVersion))\r
+        return false;\r
+    for (let i = charSize(ch); i < text.length; i += charSize(ch)) {\r
+        ch = text.codePointAt(i);\r
+        if (!ts.isIdentifierPart(ch, languageVersion) && ch !== 45 /* minus */) {\r
+            if (!seenNamespaceSeparator && ch === 58 /* colon */ && i + charSize(ch) !== text.length) {\r
+                seenNamespaceSeparator = true;\r
+            }\r
+            else {\r
+                return false;\r
+            }\r
+        }\r
+    }\r
+    return true;\r
+}\r
+exports.isValidJsxIdentifier = isValidJsxIdentifier;\r
+function isNumericPropertyName(name) {\r
+    return String(+name) === name;\r
+}\r
+exports.isNumericPropertyName = isNumericPropertyName;\r
+function isSameLine(sourceFile, pos1, pos2) {\r
+    return ts.getLineAndCharacterOfPosition(sourceFile, pos1).line === ts.getLineAndCharacterOfPosition(sourceFile, pos2).line;\r
+}\r
+exports.isSameLine = isSameLine;\r
+var SideEffectOptions;\r
+(function (SideEffectOptions) {\r
+    SideEffectOptions[SideEffectOptions["None"] = 0] = "None";\r
+    SideEffectOptions[SideEffectOptions["TaggedTemplate"] = 1] = "TaggedTemplate";\r
+    SideEffectOptions[SideEffectOptions["Constructor"] = 2] = "Constructor";\r
+    SideEffectOptions[SideEffectOptions["JsxElement"] = 4] = "JsxElement";\r
+})(SideEffectOptions = exports.SideEffectOptions || (exports.SideEffectOptions = {}));\r
+function hasSideEffects(node, options) {\r
+    var _a, _b;\r
+    const queue = [];\r
+    while (true) {\r
+        switch (node.kind) {\r
+            case ts.SyntaxKind.CallExpression:\r
+            case ts.SyntaxKind.PostfixUnaryExpression:\r
+            case ts.SyntaxKind.AwaitExpression:\r
+            case ts.SyntaxKind.YieldExpression:\r
+            case ts.SyntaxKind.DeleteExpression:\r
+                return true;\r
+            case ts.SyntaxKind.TypeAssertionExpression:\r
+            case ts.SyntaxKind.AsExpression:\r
+            case ts.SyntaxKind.ParenthesizedExpression:\r
+            case ts.SyntaxKind.NonNullExpression:\r
+            case ts.SyntaxKind.VoidExpression:\r
+            case ts.SyntaxKind.TypeOfExpression:\r
+            case ts.SyntaxKind.PropertyAccessExpression:\r
+            case ts.SyntaxKind.SpreadElement:\r
+            case ts.SyntaxKind.PartiallyEmittedExpression:\r
+                node = node.expression;\r
+                continue;\r
+            case ts.SyntaxKind.BinaryExpression:\r
+                if (isAssignmentKind(node.operatorToken.kind))\r
+                    return true;\r
+                queue.push(node.right);\r
+                node = node.left;\r
+                continue;\r
+            case ts.SyntaxKind.PrefixUnaryExpression:\r
+                switch (node.operator) {\r
+                    case ts.SyntaxKind.PlusPlusToken:\r
+                    case ts.SyntaxKind.MinusMinusToken:\r
+                        return true;\r
+                    default:\r
+                        node = node.operand;\r
+                        continue;\r
+                }\r
+            case ts.SyntaxKind.ElementAccessExpression:\r
+                if (node.argumentExpression !== undefined) // for compatibility with typescript@<2.9.0\r
+                    queue.push(node.argumentExpression);\r
+                node = node.expression;\r
+                continue;\r
+            case ts.SyntaxKind.ConditionalExpression:\r
+                queue.push(node.whenTrue, node.whenFalse);\r
+                node = node.condition;\r
+                continue;\r
+            case ts.SyntaxKind.NewExpression:\r
+                if (options & 2 /* Constructor */)\r
+                    return true;\r
+                if (node.arguments !== undefined)\r
+                    queue.push(...node.arguments);\r
+                node = node.expression;\r
+                continue;\r
+            case ts.SyntaxKind.TaggedTemplateExpression:\r
+                if (options & 1 /* TaggedTemplate */)\r
+                    return true;\r
+                queue.push(node.tag);\r
+                node = node.template;\r
+                if (node.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral)\r
+                    break;\r
+            // falls through\r
+            case ts.SyntaxKind.TemplateExpression:\r
+                for (const child of node.templateSpans)\r
+                    queue.push(child.expression);\r
+                break;\r
+            case ts.SyntaxKind.ClassExpression: {\r
+                if (node.decorators !== undefined)\r
+                    return true;\r
+                for (const child of node.members) {\r
+                    if (child.decorators !== undefined)\r
+                        return true;\r
+                    if (!hasModifier(child.modifiers, ts.SyntaxKind.DeclareKeyword)) {\r
+                        if (((_a = child.name) === null || _a === void 0 ? void 0 : _a.kind) === ts.SyntaxKind.ComputedPropertyName)\r
+                            queue.push(child.name.expression);\r
+                        if (node_1.isMethodDeclaration(child)) {\r
+                            for (const p of child.parameters)\r
+                                if (p.decorators !== undefined)\r
+                                    return true;\r
+                        }\r
+                        else if (node_1.isPropertyDeclaration(child) &&\r
+                            child.initializer !== undefined &&\r
+                            hasModifier(child.modifiers, ts.SyntaxKind.StaticKeyword)) {\r
+                            queue.push(child.initializer);\r
+                        }\r
+                    }\r
+                }\r
+                const base = getBaseOfClassLikeExpression(node);\r
+                if (base === undefined)\r
+                    break;\r
+                node = base.expression;\r
+                continue;\r
+            }\r
+            case ts.SyntaxKind.ArrayLiteralExpression:\r
+                queue.push(...node.elements);\r
+                break;\r
+            case ts.SyntaxKind.ObjectLiteralExpression:\r
+                for (const child of node.properties) {\r
+                    if (((_b = child.name) === null || _b === void 0 ? void 0 : _b.kind) === ts.SyntaxKind.ComputedPropertyName)\r
+                        queue.push(child.name.expression);\r
+                    switch (child.kind) {\r
+                        case ts.SyntaxKind.PropertyAssignment:\r
+                            queue.push(child.initializer);\r
+                            break;\r
+                        case ts.SyntaxKind.SpreadAssignment:\r
+                            queue.push(child.expression);\r
+                    }\r
+                }\r
+                break;\r
+            case ts.SyntaxKind.JsxExpression:\r
+                if (node.expression === undefined)\r
+                    break;\r
+                node = node.expression;\r
+                continue;\r
+            case ts.SyntaxKind.JsxElement:\r
+            case ts.SyntaxKind.JsxFragment:\r
+                for (const child of node.children)\r
+                    if (child.kind !== ts.SyntaxKind.JsxText)\r
+                        queue.push(child);\r
+                if (node.kind === ts.SyntaxKind.JsxFragment)\r
+                    break;\r
+                node = node.openingElement;\r
+            // falls through\r
+            case ts.SyntaxKind.JsxSelfClosingElement:\r
+            case ts.SyntaxKind.JsxOpeningElement:\r
+                if (options & 4 /* JsxElement */)\r
+                    return true;\r
+                for (const child of node.attributes.properties) {\r
+                    if (child.kind === ts.SyntaxKind.JsxSpreadAttribute) {\r
+                        queue.push(child.expression);\r
+                    }\r
+                    else if (child.initializer !== undefined) {\r
+                        queue.push(child.initializer);\r
+                    }\r
+                }\r
+                break;\r
+            case ts.SyntaxKind.CommaListExpression:\r
+                queue.push(...node.elements);\r
+        }\r
+        if (queue.length === 0)\r
+            return false;\r
+        node = queue.pop();\r
+    }\r
+}\r
+exports.hasSideEffects = hasSideEffects;\r
+/** Returns the VariableDeclaration or ParameterDeclaration that contains the BindingElement */\r
+function getDeclarationOfBindingElement(node) {\r
+    let parent = node.parent.parent;\r
+    while (parent.kind === ts.SyntaxKind.BindingElement)\r
+        parent = parent.parent.parent;\r
+    return parent;\r
+}\r
+exports.getDeclarationOfBindingElement = getDeclarationOfBindingElement;\r
+function isExpressionValueUsed(node) {\r
+    while (true) {\r
+        const parent = node.parent;\r
+        switch (parent.kind) {\r
+            case ts.SyntaxKind.CallExpression:\r
+            case ts.SyntaxKind.NewExpression:\r
+            case ts.SyntaxKind.ElementAccessExpression:\r
+            case ts.SyntaxKind.WhileStatement:\r
+            case ts.SyntaxKind.DoStatement:\r
+            case ts.SyntaxKind.WithStatement:\r
+            case ts.SyntaxKind.ThrowStatement:\r
+            case ts.SyntaxKind.ReturnStatement:\r
+            case ts.SyntaxKind.JsxExpression:\r
+            case ts.SyntaxKind.JsxSpreadAttribute:\r
+            case ts.SyntaxKind.JsxElement:\r
+            case ts.SyntaxKind.JsxFragment:\r
+            case ts.SyntaxKind.JsxSelfClosingElement:\r
+            case ts.SyntaxKind.ComputedPropertyName:\r
+            case ts.SyntaxKind.ArrowFunction:\r
+            case ts.SyntaxKind.ExportSpecifier:\r
+            case ts.SyntaxKind.ExportAssignment:\r
+            case ts.SyntaxKind.ImportDeclaration:\r
+            case ts.SyntaxKind.ExternalModuleReference:\r
+            case ts.SyntaxKind.Decorator:\r
+            case ts.SyntaxKind.TaggedTemplateExpression:\r
+            case ts.SyntaxKind.TemplateSpan:\r
+            case ts.SyntaxKind.ExpressionWithTypeArguments:\r
+            case ts.SyntaxKind.TypeOfExpression:\r
+            case ts.SyntaxKind.AwaitExpression:\r
+            case ts.SyntaxKind.YieldExpression:\r
+            case ts.SyntaxKind.LiteralType:\r
+            case ts.SyntaxKind.JsxAttributes:\r
+            case ts.SyntaxKind.JsxOpeningElement:\r
+            case ts.SyntaxKind.JsxClosingElement:\r
+            case ts.SyntaxKind.IfStatement:\r
+            case ts.SyntaxKind.CaseClause:\r
+            case ts.SyntaxKind.SwitchStatement:\r
+                return true;\r
+            case ts.SyntaxKind.PropertyAccessExpression:\r
+                return parent.expression === node;\r
+            case ts.SyntaxKind.QualifiedName:\r
+                return parent.left === node;\r
+            case ts.SyntaxKind.ShorthandPropertyAssignment:\r
+                return parent.objectAssignmentInitializer === node ||\r
+                    !isInDestructuringAssignment(parent);\r
+            case ts.SyntaxKind.PropertyAssignment:\r
+                return parent.initializer === node && !isInDestructuringAssignment(parent);\r
+            case ts.SyntaxKind.SpreadAssignment:\r
+            case ts.SyntaxKind.SpreadElement:\r
+            case ts.SyntaxKind.ArrayLiteralExpression:\r
+                return !isInDestructuringAssignment(parent);\r
+            case ts.SyntaxKind.ParenthesizedExpression:\r
+            case ts.SyntaxKind.AsExpression:\r
+            case ts.SyntaxKind.TypeAssertionExpression:\r
+            case ts.SyntaxKind.PostfixUnaryExpression:\r
+            case ts.SyntaxKind.PrefixUnaryExpression:\r
+            case ts.SyntaxKind.NonNullExpression:\r
+                node = parent;\r
+                continue;\r
+            case ts.SyntaxKind.ForStatement:\r
+                return parent.condition === node;\r
+            case ts.SyntaxKind.ForInStatement:\r
+            case ts.SyntaxKind.ForOfStatement:\r
+                return parent.expression === node;\r
+            case ts.SyntaxKind.ConditionalExpression:\r
+                if (parent.condition === node)\r
+                    return true;\r
+                node = parent;\r
+                break;\r
+            case ts.SyntaxKind.PropertyDeclaration:\r
+            case ts.SyntaxKind.BindingElement:\r
+            case ts.SyntaxKind.VariableDeclaration:\r
+            case ts.SyntaxKind.Parameter:\r
+            case ts.SyntaxKind.EnumMember:\r
+                return parent.initializer === node;\r
+            case ts.SyntaxKind.ImportEqualsDeclaration:\r
+                return parent.moduleReference === node;\r
+            case ts.SyntaxKind.CommaListExpression:\r
+                if (parent.elements[parent.elements.length - 1] !== node)\r
+                    return false;\r
+                node = parent;\r
+                break;\r
+            case ts.SyntaxKind.BinaryExpression:\r
+                if (parent.right === node) {\r
+                    if (parent.operatorToken.kind === ts.SyntaxKind.CommaToken) {\r
+                        node = parent;\r
+                        break;\r
+                    }\r
+                    return true;\r
+                }\r
+                switch (parent.operatorToken.kind) {\r
+                    case ts.SyntaxKind.CommaToken:\r
+                    case ts.SyntaxKind.EqualsToken:\r
+                        return false;\r
+                    case ts.SyntaxKind.EqualsEqualsEqualsToken:\r
+                    case ts.SyntaxKind.EqualsEqualsToken:\r
+                    case ts.SyntaxKind.ExclamationEqualsEqualsToken:\r
+                    case ts.SyntaxKind.ExclamationEqualsToken:\r
+                    case ts.SyntaxKind.InstanceOfKeyword:\r
+                    case ts.SyntaxKind.PlusToken:\r
+                    case ts.SyntaxKind.MinusToken:\r
+                    case ts.SyntaxKind.AsteriskToken:\r
+                    case ts.SyntaxKind.SlashToken:\r
+                    case ts.SyntaxKind.PercentToken:\r
+                    case ts.SyntaxKind.AsteriskAsteriskToken:\r
+                    case ts.SyntaxKind.GreaterThanToken:\r
+                    case ts.SyntaxKind.GreaterThanGreaterThanToken:\r
+                    case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:\r
+                    case ts.SyntaxKind.GreaterThanEqualsToken:\r
+                    case ts.SyntaxKind.LessThanToken:\r
+                    case ts.SyntaxKind.LessThanLessThanToken:\r
+                    case ts.SyntaxKind.LessThanEqualsToken:\r
+                    case ts.SyntaxKind.AmpersandToken:\r
+                    case ts.SyntaxKind.BarToken:\r
+                    case ts.SyntaxKind.CaretToken:\r
+                    case ts.SyntaxKind.BarBarToken:\r
+                    case ts.SyntaxKind.AmpersandAmpersandToken:\r
+                    case ts.SyntaxKind.QuestionQuestionToken:\r
+                    case ts.SyntaxKind.InKeyword:\r
+                    case ts.SyntaxKind.QuestionQuestionEqualsToken:\r
+                    case ts.SyntaxKind.AmpersandAmpersandEqualsToken:\r
+                    case ts.SyntaxKind.BarBarEqualsToken:\r
+                        return true;\r
+                    default:\r
+                        node = parent;\r
+                }\r
+                break;\r
+            default:\r
+                return false;\r
+        }\r
+    }\r
+}\r
+exports.isExpressionValueUsed = isExpressionValueUsed;\r
+function isInDestructuringAssignment(node) {\r
+    switch (node.kind) {\r
+        case ts.SyntaxKind.ShorthandPropertyAssignment:\r
+            if (node.objectAssignmentInitializer !== undefined)\r
+                return true;\r
+        // falls through\r
+        case ts.SyntaxKind.PropertyAssignment:\r
+        case ts.SyntaxKind.SpreadAssignment:\r
+            node = node.parent;\r
+            break;\r
+        case ts.SyntaxKind.SpreadElement:\r
+            if (node.parent.kind !== ts.SyntaxKind.ArrayLiteralExpression)\r
+                return false;\r
+            node = node.parent;\r
+    }\r
+    while (true) {\r
+        switch (node.parent.kind) {\r
+            case ts.SyntaxKind.BinaryExpression:\r
+                return node.parent.left === node &&\r
+                    node.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken;\r
+            case ts.SyntaxKind.ForOfStatement:\r
+                return node.parent.initializer === node;\r
+            case ts.SyntaxKind.ArrayLiteralExpression:\r
+            case ts.SyntaxKind.ObjectLiteralExpression:\r
+                node = node.parent;\r
+                break;\r
+            case ts.SyntaxKind.SpreadAssignment:\r
+            case ts.SyntaxKind.PropertyAssignment:\r
+                node = node.parent.parent;\r
+                break;\r
+            case ts.SyntaxKind.SpreadElement:\r
+                if (node.parent.parent.kind !== ts.SyntaxKind.ArrayLiteralExpression)\r
+                    return false;\r
+                node = node.parent.parent;\r
+                break;\r
+            default:\r
+                return false;\r
+        }\r
+    }\r
+}\r
+var AccessKind;\r
+(function (AccessKind) {\r
+    AccessKind[AccessKind["None"] = 0] = "None";\r
+    AccessKind[AccessKind["Read"] = 1] = "Read";\r
+    AccessKind[AccessKind["Write"] = 2] = "Write";\r
+    AccessKind[AccessKind["Delete"] = 4] = "Delete";\r
+    AccessKind[AccessKind["ReadWrite"] = 3] = "ReadWrite";\r
+    AccessKind[AccessKind["Modification"] = 6] = "Modification";\r
+})(AccessKind = exports.AccessKind || (exports.AccessKind = {}));\r
+function getAccessKind(node) {\r
+    const parent = node.parent;\r
+    switch (parent.kind) {\r
+        case ts.SyntaxKind.DeleteExpression:\r
+            return 4 /* Delete */;\r
+        case ts.SyntaxKind.PostfixUnaryExpression:\r
+            return 3 /* ReadWrite */;\r
+        case ts.SyntaxKind.PrefixUnaryExpression:\r
+            return parent.operator === ts.SyntaxKind.PlusPlusToken ||\r
+                parent.operator === ts.SyntaxKind.MinusMinusToken\r
+                ? 3 /* ReadWrite */\r
+                : 1 /* Read */;\r
+        case ts.SyntaxKind.BinaryExpression:\r
+            return parent.right === node\r
+                ? 1 /* Read */\r
+                : !isAssignmentKind(parent.operatorToken.kind)\r
+                    ? 1 /* Read */\r
+                    : parent.operatorToken.kind === ts.SyntaxKind.EqualsToken\r
+                        ? 2 /* Write */\r
+                        : 3 /* ReadWrite */;\r
+        case ts.SyntaxKind.ShorthandPropertyAssignment:\r
+            return parent.objectAssignmentInitializer === node\r
+                ? 1 /* Read */\r
+                : isInDestructuringAssignment(parent)\r
+                    ? 2 /* Write */\r
+                    : 1 /* Read */;\r
+        case ts.SyntaxKind.PropertyAssignment:\r
+            return parent.name === node\r
+                ? 0 /* None */\r
+                : isInDestructuringAssignment(parent)\r
+                    ? 2 /* Write */\r
+                    : 1 /* Read */;\r
+        case ts.SyntaxKind.ArrayLiteralExpression:\r
+        case ts.SyntaxKind.SpreadElement:\r
+        case ts.SyntaxKind.SpreadAssignment:\r
+            return isInDestructuringAssignment(parent)\r
+                ? 2 /* Write */\r
+                : 1 /* Read */;\r
+        case ts.SyntaxKind.ParenthesizedExpression:\r
+        case ts.SyntaxKind.NonNullExpression:\r
+        case ts.SyntaxKind.TypeAssertionExpression:\r
+        case ts.SyntaxKind.AsExpression:\r
+            // (<number>foo! as {})++\r
+            return getAccessKind(parent);\r
+        case ts.SyntaxKind.ForOfStatement:\r
+        case ts.SyntaxKind.ForInStatement:\r
+            return parent.initializer === node\r
+                ? 2 /* Write */\r
+                : 1 /* Read */;\r
+        case ts.SyntaxKind.ExpressionWithTypeArguments:\r
+            return parent.parent.token === ts.SyntaxKind.ExtendsKeyword &&\r
+                parent.parent.parent.kind !== ts.SyntaxKind.InterfaceDeclaration\r
+                ? 1 /* Read */\r
+                : 0 /* None */;\r
+        case ts.SyntaxKind.ComputedPropertyName:\r
+        case ts.SyntaxKind.ExpressionStatement:\r
+        case ts.SyntaxKind.TypeOfExpression:\r
+        case ts.SyntaxKind.ElementAccessExpression:\r
+        case ts.SyntaxKind.ForStatement:\r
+        case ts.SyntaxKind.IfStatement:\r
+        case ts.SyntaxKind.DoStatement:\r
+        case ts.SyntaxKind.WhileStatement:\r
+        case ts.SyntaxKind.SwitchStatement:\r
+        case ts.SyntaxKind.WithStatement:\r
+        case ts.SyntaxKind.ThrowStatement:\r
+        case ts.SyntaxKind.CallExpression:\r
+        case ts.SyntaxKind.NewExpression:\r
+        case ts.SyntaxKind.TaggedTemplateExpression:\r
+        case ts.SyntaxKind.JsxExpression:\r
+        case ts.SyntaxKind.Decorator:\r
+        case ts.SyntaxKind.TemplateSpan:\r
+        case ts.SyntaxKind.JsxOpeningElement:\r
+        case ts.SyntaxKind.JsxSelfClosingElement:\r
+        case ts.SyntaxKind.JsxSpreadAttribute:\r
+        case ts.SyntaxKind.VoidExpression:\r
+        case ts.SyntaxKind.ReturnStatement:\r
+        case ts.SyntaxKind.AwaitExpression:\r
+        case ts.SyntaxKind.YieldExpression:\r
+        case ts.SyntaxKind.ConditionalExpression:\r
+        case ts.SyntaxKind.CaseClause:\r
+        case ts.SyntaxKind.JsxElement:\r
+            return 1 /* Read */;\r
+        case ts.SyntaxKind.ArrowFunction:\r
+            return parent.body === node\r
+                ? 1 /* Read */\r
+                : 2 /* Write */;\r
+        case ts.SyntaxKind.PropertyDeclaration:\r
+        case ts.SyntaxKind.VariableDeclaration:\r
+        case ts.SyntaxKind.Parameter:\r
+        case ts.SyntaxKind.EnumMember:\r
+        case ts.SyntaxKind.BindingElement:\r
+        case ts.SyntaxKind.JsxAttribute:\r
+            return parent.initializer === node\r
+                ? 1 /* Read */\r
+                : 0 /* None */;\r
+        case ts.SyntaxKind.PropertyAccessExpression:\r
+            return parent.expression === node\r
+                ? 1 /* Read */\r
+                : 0 /* None */;\r
+        case ts.SyntaxKind.ExportAssignment:\r
+            return parent.isExportEquals\r
+                ? 1 /* Read */\r
+                : 0 /* None */;\r
+    }\r
+    return 0 /* None */;\r
+}\r
+exports.getAccessKind = getAccessKind;\r
+function isReassignmentTarget(node) {\r
+    return (getAccessKind(node) & 2 /* Write */) !== 0;\r
+}\r
+exports.isReassignmentTarget = isReassignmentTarget;\r
+function canHaveJsDoc(node) {\r
+    const kind = node.kind;\r
+    switch (kind) {\r
+        case ts.SyntaxKind.Parameter:\r
+        case ts.SyntaxKind.CallSignature:\r
+        case ts.SyntaxKind.ConstructSignature:\r
+        case ts.SyntaxKind.MethodSignature:\r
+        case ts.SyntaxKind.PropertySignature:\r
+        case ts.SyntaxKind.ArrowFunction:\r
+        case ts.SyntaxKind.ParenthesizedExpression:\r
+        case ts.SyntaxKind.SpreadAssignment:\r
+        case ts.SyntaxKind.ShorthandPropertyAssignment:\r
+        case ts.SyntaxKind.PropertyAssignment:\r
+        case ts.SyntaxKind.FunctionExpression:\r
+        case ts.SyntaxKind.LabeledStatement:\r
+        case ts.SyntaxKind.ExpressionStatement:\r
+        case ts.SyntaxKind.VariableStatement:\r
+        case ts.SyntaxKind.FunctionDeclaration:\r
+        case ts.SyntaxKind.Constructor:\r
+        case ts.SyntaxKind.MethodDeclaration:\r
+        case ts.SyntaxKind.PropertyDeclaration:\r
+        case ts.SyntaxKind.GetAccessor:\r
+        case ts.SyntaxKind.SetAccessor:\r
+        case ts.SyntaxKind.ClassDeclaration:\r
+        case ts.SyntaxKind.ClassExpression:\r
+        case ts.SyntaxKind.InterfaceDeclaration:\r
+        case ts.SyntaxKind.TypeAliasDeclaration:\r
+        case ts.SyntaxKind.EnumMember:\r
+        case ts.SyntaxKind.EnumDeclaration:\r
+        case ts.SyntaxKind.ModuleDeclaration:\r
+        case ts.SyntaxKind.ImportEqualsDeclaration:\r
+        case ts.SyntaxKind.ImportDeclaration:\r
+        case ts.SyntaxKind.NamespaceExportDeclaration:\r
+        case ts.SyntaxKind.ExportAssignment:\r
+        case ts.SyntaxKind.IndexSignature:\r
+        case ts.SyntaxKind.FunctionType:\r
+        case ts.SyntaxKind.ConstructorType:\r
+        case ts.SyntaxKind.JSDocFunctionType:\r
+        case ts.SyntaxKind.ExportDeclaration:\r
+        case ts.SyntaxKind.NamedTupleMember:\r
+        case ts.SyntaxKind.EndOfFileToken:\r
+            return true;\r
+        default:\r
+            return false;\r
+    }\r
+}\r
+exports.canHaveJsDoc = canHaveJsDoc;\r
+/** Gets the JSDoc of a node. For performance reasons this function should only be called when `canHaveJsDoc` returns true. */\r
+function getJsDoc(node, sourceFile) {\r
+    const result = [];\r
+    for (const child of node.getChildren(sourceFile)) {\r
+        if (!node_1.isJsDoc(child))\r
+            break;\r
+        result.push(child);\r
+    }\r
+    return result;\r
+}\r
+exports.getJsDoc = getJsDoc;\r
+/**\r
+ * Parses the JsDoc of any node. This function is made for nodes that don't get their JsDoc parsed by the TypeScript parser.\r
+ *\r
+ * @param considerTrailingComments When set to `true` this function uses the trailing comments if the node starts on the same line\r
+ *                                 as the previous node ends.\r
+ */\r
+function parseJsDocOfNode(node, considerTrailingComments, sourceFile = node.getSourceFile()) {\r
+    if (canHaveJsDoc(node) && node.kind !== ts.SyntaxKind.EndOfFileToken) {\r
+        const result = getJsDoc(node, sourceFile);\r
+        if (result.length !== 0 || !considerTrailingComments)\r
+            return result;\r
+    }\r
+    return parseJsDocWorker(node, node.getStart(sourceFile), sourceFile, considerTrailingComments);\r
+}\r
+exports.parseJsDocOfNode = parseJsDocOfNode;\r
+function parseJsDocWorker(node, nodeStart, sourceFile, considerTrailingComments) {\r
+    const start = ts[considerTrailingComments && isSameLine(sourceFile, node.pos, nodeStart)\r
+        ? 'forEachTrailingCommentRange'\r
+        : 'forEachLeadingCommentRange'](sourceFile.text, node.pos, \r
+    // return object to make `0` a truthy value\r
+    (pos, _end, kind) => kind === ts.SyntaxKind.MultiLineCommentTrivia && sourceFile.text[pos + 2] === '*' ? { pos } : undefined);\r
+    if (start === undefined)\r
+        return [];\r
+    const startPos = start.pos;\r
+    const text = sourceFile.text.slice(startPos, nodeStart);\r
+    const newSourceFile = ts.createSourceFile('jsdoc.ts', `${text}var a;`, sourceFile.languageVersion);\r
+    const result = getJsDoc(newSourceFile.statements[0], newSourceFile);\r
+    for (const doc of result)\r
+        updateNode(doc, node);\r
+    return result;\r
+    function updateNode(n, parent) {\r
+        n.pos += startPos;\r
+        n.end += startPos;\r
+        n.parent = parent;\r
+        return ts.forEachChild(n, (child) => updateNode(child, n), (children) => {\r
+            children.pos += startPos;\r
+            children.end += startPos;\r
+            for (const child of children)\r
+                updateNode(child, n);\r
+        });\r
+    }\r
+}\r
+var ImportKind;\r
+(function (ImportKind) {\r
+    ImportKind[ImportKind["ImportDeclaration"] = 1] = "ImportDeclaration";\r
+    ImportKind[ImportKind["ImportEquals"] = 2] = "ImportEquals";\r
+    ImportKind[ImportKind["ExportFrom"] = 4] = "ExportFrom";\r
+    ImportKind[ImportKind["DynamicImport"] = 8] = "DynamicImport";\r
+    ImportKind[ImportKind["Require"] = 16] = "Require";\r
+    ImportKind[ImportKind["ImportType"] = 32] = "ImportType";\r
+    ImportKind[ImportKind["All"] = 63] = "All";\r
+    ImportKind[ImportKind["AllImports"] = 59] = "AllImports";\r
+    ImportKind[ImportKind["AllStaticImports"] = 3] = "AllStaticImports";\r
+    ImportKind[ImportKind["AllImportExpressions"] = 24] = "AllImportExpressions";\r
+    ImportKind[ImportKind["AllRequireLike"] = 18] = "AllRequireLike";\r
+    // @internal\r
+    ImportKind[ImportKind["AllNestedImports"] = 56] = "AllNestedImports";\r
+    // @internal\r
+    ImportKind[ImportKind["AllTopLevelImports"] = 7] = "AllTopLevelImports";\r
+})(ImportKind = exports.ImportKind || (exports.ImportKind = {}));\r
+function findImports(sourceFile, kinds, ignoreFileName = true) {\r
+    const result = [];\r
+    for (const node of findImportLikeNodes(sourceFile, kinds, ignoreFileName)) {\r
+        switch (node.kind) {\r
+            case ts.SyntaxKind.ImportDeclaration:\r
+                addIfTextualLiteral(node.moduleSpecifier);\r
+                break;\r
+            case ts.SyntaxKind.ImportEqualsDeclaration:\r
+                addIfTextualLiteral(node.moduleReference.expression);\r
+                break;\r
+            case ts.SyntaxKind.ExportDeclaration:\r
+                addIfTextualLiteral(node.moduleSpecifier);\r
+                break;\r
+            case ts.SyntaxKind.CallExpression:\r
+                addIfTextualLiteral(node.arguments[0]);\r
+                break;\r
+            case ts.SyntaxKind.ImportType:\r
+                if (node_1.isLiteralTypeNode(node.argument))\r
+                    addIfTextualLiteral(node.argument.literal);\r
+                break;\r
+            default:\r
+                throw new Error('unexpected node');\r
+        }\r
+    }\r
+    return result;\r
+    function addIfTextualLiteral(node) {\r
+        if (node_1.isTextualLiteral(node))\r
+            result.push(node);\r
+    }\r
+}\r
+exports.findImports = findImports;\r
+function findImportLikeNodes(sourceFile, kinds, ignoreFileName = true) {\r
+    return new ImportFinder(sourceFile, kinds, ignoreFileName).find();\r
+}\r
+exports.findImportLikeNodes = findImportLikeNodes;\r
+class ImportFinder {\r
+    constructor(_sourceFile, _options, _ignoreFileName) {\r
+        this._sourceFile = _sourceFile;\r
+        this._options = _options;\r
+        this._ignoreFileName = _ignoreFileName;\r
+        this._result = [];\r
+    }\r
+    find() {\r
+        if (this._sourceFile.isDeclarationFile)\r
+            this._options &= ~24 /* AllImportExpressions */;\r
+        if (this._options & 7 /* AllTopLevelImports */)\r
+            this._findImports(this._sourceFile.statements);\r
+        if (this._options & 56 /* AllNestedImports */)\r
+            this._findNestedImports();\r
+        return this._result;\r
+    }\r
+    _findImports(statements) {\r
+        for (const statement of statements) {\r
+            if (node_1.isImportDeclaration(statement)) {\r
+                if (this._options & 1 /* ImportDeclaration */)\r
+                    this._result.push(statement);\r
+            }\r
+            else if (node_1.isImportEqualsDeclaration(statement)) {\r
+                if (this._options & 2 /* ImportEquals */ &&\r
+                    statement.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference)\r
+                    this._result.push(statement);\r
+            }\r
+            else if (node_1.isExportDeclaration(statement)) {\r
+                if (statement.moduleSpecifier !== undefined && this._options & 4 /* ExportFrom */)\r
+                    this._result.push(statement);\r
+            }\r
+            else if (node_1.isModuleDeclaration(statement)) {\r
+                this._findImportsInModule(statement);\r
+            }\r
+        }\r
+    }\r
+    _findImportsInModule(declaration) {\r
+        if (declaration.body === undefined)\r
+            return;\r
+        if (declaration.body.kind === ts.SyntaxKind.ModuleDeclaration)\r
+            return this._findImportsInModule(declaration.body);\r
+        this._findImports(declaration.body.statements);\r
+    }\r
+    _findNestedImports() {\r
+        const isJavaScriptFile = this._ignoreFileName || (this._sourceFile.flags & ts.NodeFlags.JavaScriptFile) !== 0;\r
+        let re;\r
+        let includeJsDoc;\r
+        if ((this._options & 56 /* AllNestedImports */) === 16 /* Require */) {\r
+            if (!isJavaScriptFile)\r
+                return; // don't look for 'require' in TS files\r
+            re = /\brequire\s*[</(]/g;\r
+            includeJsDoc = false;\r
+        }\r
+        else if (this._options & 16 /* Require */ && isJavaScriptFile) {\r
+            re = /\b(?:import|require)\s*[</(]/g;\r
+            includeJsDoc = (this._options & 32 /* ImportType */) !== 0;\r
+        }\r
+        else {\r
+            re = /\bimport\s*[</(]/g;\r
+            includeJsDoc = isJavaScriptFile && (this._options & 32 /* ImportType */) !== 0;\r
+        }\r
+        for (let match = re.exec(this._sourceFile.text); match !== null; match = re.exec(this._sourceFile.text)) {\r
+            const token = getTokenAtPositionWorker(this._sourceFile, match.index, this._sourceFile, \r
+            // only look for ImportTypeNode within JSDoc in JS files\r
+            match[0][0] === 'i' && includeJsDoc);\r
+            if (token.kind === ts.SyntaxKind.ImportKeyword) {\r
+                if (token.end - 'import'.length !== match.index)\r
+                    continue;\r
+                switch (token.parent.kind) {\r
+                    case ts.SyntaxKind.ImportType:\r
+                        this._result.push(token.parent);\r
+                        break;\r
+                    case ts.SyntaxKind.CallExpression:\r
+                        if (token.parent.arguments.length > 1)\r
+                            this._result.push(token.parent);\r
+                }\r
+            }\r
+            else if (token.kind === ts.SyntaxKind.Identifier &&\r
+                token.end - 'require'.length === match.index &&\r
+                token.parent.kind === ts.SyntaxKind.CallExpression &&\r
+                token.parent.expression === token &&\r
+                token.parent.arguments.length === 1) {\r
+                this._result.push(token.parent);\r
+            }\r
+        }\r
+    }\r
+}\r
+/**\r
+ * Ambient context means the statement itself has the `declare` keyword\r
+ * or is inside a `declare namespace`,  `delcare module` or `declare global`.\r
+ */\r
+function isStatementInAmbientContext(node) {\r
+    while (node.flags & ts.NodeFlags.NestedNamespace)\r
+        node = node.parent;\r
+    return hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword) || isAmbientModuleBlock(node.parent);\r
+}\r
+exports.isStatementInAmbientContext = isStatementInAmbientContext;\r
+/** Includes `declare namespace`, `declare module` and `declare global` and namespace nested in one of the aforementioned. */\r
+function isAmbientModuleBlock(node) {\r
+    while (node.kind === ts.SyntaxKind.ModuleBlock) {\r
+        do\r
+            node = node.parent;\r
+        while (node.flags & ts.NodeFlags.NestedNamespace);\r
+        if (hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword))\r
+            return true;\r
+        node = node.parent;\r
+    }\r
+    return false;\r
+}\r
+exports.isAmbientModuleBlock = isAmbientModuleBlock;\r
+function getIIFE(func) {\r
+    let node = func.parent;\r
+    while (node.kind === ts.SyntaxKind.ParenthesizedExpression)\r
+        node = node.parent;\r
+    return node_1.isCallExpression(node) && func.end <= node.expression.end ? node : undefined;\r
+}\r
+exports.getIIFE = getIIFE;\r
+function isStrictCompilerOptionEnabled(options, option) {\r
+    return (options.strict ? options[option] !== false : options[option] === true) &&\r
+        (option !== 'strictPropertyInitialization' || isStrictCompilerOptionEnabled(options, 'strictNullChecks'));\r
+}\r
+exports.isStrictCompilerOptionEnabled = isStrictCompilerOptionEnabled;\r
+// https://github.com/ajafff/tslint-consistent-codestyle/issues/85\r
+/**\r
+ * Checks if a given compiler option is enabled.\r
+ * It handles dependencies of options, e.g. `declaration` is implicitly enabled by `composite` or `strictNullChecks` is enabled by `strict`.\r
+ * However, it does not check dependencies that are already checked and reported as errors, e.g. `checkJs` without `allowJs`.\r
+ * This function only handles boolean flags.\r
+ */\r
+function isCompilerOptionEnabled(options, option) {\r
+    switch (option) {\r
+        case 'stripInternal':\r
+        case 'declarationMap':\r
+        case 'emitDeclarationOnly':\r
+            return options[option] === true && isCompilerOptionEnabled(options, 'declaration');\r
+        case 'declaration':\r
+            return options.declaration || isCompilerOptionEnabled(options, 'composite');\r
+        case 'incremental':\r
+            return options.incremental === undefined ? isCompilerOptionEnabled(options, 'composite') : options.incremental;\r
+        case 'skipDefaultLibCheck':\r
+            return options.skipDefaultLibCheck || isCompilerOptionEnabled(options, 'skipLibCheck');\r
+        case 'suppressImplicitAnyIndexErrors':\r
+            return options.suppressImplicitAnyIndexErrors === true && isCompilerOptionEnabled(options, 'noImplicitAny');\r
+        case 'allowSyntheticDefaultImports':\r
+            return options.allowSyntheticDefaultImports !== undefined\r
+                ? options.allowSyntheticDefaultImports\r
+                : isCompilerOptionEnabled(options, 'esModuleInterop') || options.module === ts.ModuleKind.System;\r
+        case 'noUncheckedIndexedAccess':\r
+            return options.noUncheckedIndexedAccess === true && isCompilerOptionEnabled(options, 'strictNullChecks');\r
+        case 'allowJs':\r
+            return options.allowJs === undefined ? isCompilerOptionEnabled(options, 'checkJs') : options.allowJs;\r
+        case 'noImplicitAny':\r
+        case 'noImplicitThis':\r
+        case 'strictNullChecks':\r
+        case 'strictFunctionTypes':\r
+        case 'strictPropertyInitialization':\r
+        case 'alwaysStrict':\r
+        case 'strictBindCallApply':\r
+            return isStrictCompilerOptionEnabled(options, option);\r
+    }\r
+    return options[option] === true;\r
+}\r
+exports.isCompilerOptionEnabled = isCompilerOptionEnabled;\r
+/**\r
+ * Has nothing to do with `isAmbientModuleBlock`.\r
+ *\r
+ * @returns `true` if it's a global augmentation or has a string name.\r
+ */\r
+function isAmbientModule(node) {\r
+    return node.name.kind === ts.SyntaxKind.StringLiteral || (node.flags & ts.NodeFlags.GlobalAugmentation) !== 0;\r
+}\r
+exports.isAmbientModule = isAmbientModule;\r
+/**\r
+ * @deprecated use `getTsCheckDirective` instead since `// @ts-nocheck` is no longer restricted to JS files.\r
+ * @returns the last `// @ts-check` or `// @ts-nocheck` directive in the given file.\r
+ */\r
+function getCheckJsDirective(source) {\r
+    return getTsCheckDirective(source);\r
+}\r
+exports.getCheckJsDirective = getCheckJsDirective;\r
+/** @returns the last `// @ts-check` or `// @ts-nocheck` directive in the given file. */\r
+function getTsCheckDirective(source) {\r
+    let directive;\r
+    // needs to work around a shebang issue until https://github.com/Microsoft/TypeScript/issues/28477 is resolved\r
+    ts.forEachLeadingCommentRange(source, (ts.getShebang(source) || '').length, (pos, end, kind) => {\r
+        if (kind === ts.SyntaxKind.SingleLineCommentTrivia) {\r
+            const text = source.slice(pos, end);\r
+            const match = /^\/{2,3}\s*@ts-(no)?check(?:\s|$)/i.exec(text);\r
+            if (match !== null)\r
+                directive = { pos, end, enabled: match[1] === undefined };\r
+        }\r
+    });\r
+    return directive;\r
+}\r
+exports.getTsCheckDirective = getTsCheckDirective;\r
+function isConstAssertion(node) {\r
+    return node_1.isTypeReferenceNode(node.type) &&\r
+        node.type.typeName.kind === ts.SyntaxKind.Identifier &&\r
+        node.type.typeName.escapedText === 'const';\r
+}\r
+exports.isConstAssertion = isConstAssertion;\r
+/** Detects whether an expression is affected by an enclosing 'as const' assertion and therefore treated literally. */\r
+function isInConstContext(node) {\r
+    let current = node;\r
+    while (true) {\r
+        const parent = current.parent;\r
+        outer: switch (parent.kind) {\r
+            case ts.SyntaxKind.TypeAssertionExpression:\r
+            case ts.SyntaxKind.AsExpression:\r
+                return isConstAssertion(parent);\r
+            case ts.SyntaxKind.PrefixUnaryExpression:\r
+                if (current.kind !== ts.SyntaxKind.NumericLiteral)\r
+                    return false;\r
+                switch (parent.operator) {\r
+                    case ts.SyntaxKind.PlusToken:\r
+                    case ts.SyntaxKind.MinusToken:\r
+                        current = parent;\r
+                        break outer;\r
+                    default:\r
+                        return false;\r
+                }\r
+            case ts.SyntaxKind.PropertyAssignment:\r
+                if (parent.initializer !== current)\r
+                    return false;\r
+                current = parent.parent;\r
+                break;\r
+            case ts.SyntaxKind.ShorthandPropertyAssignment:\r
+                current = parent.parent;\r
+                break;\r
+            case ts.SyntaxKind.ParenthesizedExpression:\r
+            case ts.SyntaxKind.ArrayLiteralExpression:\r
+            case ts.SyntaxKind.ObjectLiteralExpression:\r
+            case ts.SyntaxKind.TemplateExpression:\r
+                current = parent;\r
+                break;\r
+            default:\r
+                return false;\r
+        }\r
+    }\r
+}\r
+exports.isInConstContext = isInConstContext;\r
+/** Returns true for `Object.defineProperty(o, 'prop', {value, writable: false})` and  `Object.defineProperty(o, 'prop', {get: () => 1})`*/\r
+function isReadonlyAssignmentDeclaration(node, checker) {\r
+    if (!isBindableObjectDefinePropertyCall(node))\r
+        return false;\r
+    const descriptorType = checker.getTypeAtLocation(node.arguments[2]);\r
+    if (descriptorType.getProperty('value') === undefined)\r
+        return descriptorType.getProperty('set') === undefined;\r
+    const writableProp = descriptorType.getProperty('writable');\r
+    if (writableProp === undefined)\r
+        return false;\r
+    const writableType = writableProp.valueDeclaration !== undefined && node_1.isPropertyAssignment(writableProp.valueDeclaration)\r
+        ? checker.getTypeAtLocation(writableProp.valueDeclaration.initializer)\r
+        : checker.getTypeOfSymbolAtLocation(writableProp, node.arguments[2]);\r
+    return type_1.isBooleanLiteralType(writableType, false);\r
+}\r
+exports.isReadonlyAssignmentDeclaration = isReadonlyAssignmentDeclaration;\r
+/** Determines whether a call to `Object.defineProperty` is statically analyzable. */\r
+function isBindableObjectDefinePropertyCall(node) {\r
+    return node.arguments.length === 3 &&\r
+        node_1.isEntityNameExpression(node.arguments[0]) &&\r
+        node_1.isNumericOrStringLikeLiteral(node.arguments[1]) &&\r
+        node_1.isPropertyAccessExpression(node.expression) &&\r
+        node.expression.name.escapedText === 'defineProperty' &&\r
+        node_1.isIdentifier(node.expression.expression) &&\r
+        node.expression.expression.escapedText === 'Object';\r
+}\r
+exports.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall;\r
+function isWellKnownSymbolLiterally(node) {\r
+    return ts.isPropertyAccessExpression(node) &&\r
+        ts.isIdentifier(node.expression) &&\r
+        node.expression.escapedText === 'Symbol';\r
+}\r
+exports.isWellKnownSymbolLiterally = isWellKnownSymbolLiterally;\r
+/** @deprecated typescript 4.3 removed the concept of literal well known symbols. Use `getPropertyNameFromType` instead. */\r
+function getPropertyNameOfWellKnownSymbol(node) {\r
+    return {\r
+        displayName: `[Symbol.${node.name.text}]`,\r
+        symbolName: ('__@' + node.name.text),\r
+    };\r
+}\r
+exports.getPropertyNameOfWellKnownSymbol = getPropertyNameOfWellKnownSymbol;\r
+const isTsBefore43 = (([major, minor]) => major < '4' || major === '4' && minor < '3')(ts.versionMajorMinor.split('.'));\r
+function getLateBoundPropertyNames(node, checker) {\r
+    const result = {\r
+        known: true,\r
+        names: [],\r
+    };\r
+    node = unwrapParentheses(node);\r
+    if (isTsBefore43 && isWellKnownSymbolLiterally(node)) {\r
+        result.names.push(getPropertyNameOfWellKnownSymbol(node)); // wotan-disable-line no-unstable-api-use\r
+    }\r
+    else {\r
+        const type = checker.getTypeAtLocation(node);\r
+        for (const key of type_1.unionTypeParts(checker.getBaseConstraintOfType(type) || type)) {\r
+            const propertyName = type_1.getPropertyNameFromType(key);\r
+            if (propertyName) {\r
+                result.names.push(propertyName);\r
+            }\r
+            else {\r
+                result.known = false;\r
+            }\r
+        }\r
+    }\r
+    return result;\r
+}\r
+exports.getLateBoundPropertyNames = getLateBoundPropertyNames;\r
+function getLateBoundPropertyNamesOfPropertyName(node, checker) {\r
+    const staticName = getPropertyName(node);\r
+    return staticName !== undefined\r
+        ? { known: true, names: [{ displayName: staticName, symbolName: ts.escapeLeadingUnderscores(staticName) }] }\r
+        : node.kind === ts.SyntaxKind.PrivateIdentifier\r
+            ? { known: true, names: [{ displayName: node.text, symbolName: checker.getSymbolAtLocation(node).escapedName }] }\r
+            : getLateBoundPropertyNames(node.expression, checker);\r
+}\r
+exports.getLateBoundPropertyNamesOfPropertyName = getLateBoundPropertyNamesOfPropertyName;\r
+/** Most declarations demand there to be only one statically known name, e.g. class members with computed name. */\r
+function getSingleLateBoundPropertyNameOfPropertyName(node, checker) {\r
+    const staticName = getPropertyName(node);\r
+    if (staticName !== undefined)\r
+        return { displayName: staticName, symbolName: ts.escapeLeadingUnderscores(staticName) };\r
+    if (node.kind === ts.SyntaxKind.PrivateIdentifier)\r
+        return { displayName: node.text, symbolName: checker.getSymbolAtLocation(node).escapedName };\r
+    const { expression } = node;\r
+    return isTsBefore43 && isWellKnownSymbolLiterally(expression)\r
+        ? getPropertyNameOfWellKnownSymbol(expression) // wotan-disable-line no-unstable-api-use\r
+        : type_1.getPropertyNameFromType(checker.getTypeAtLocation(expression));\r
+}\r
+exports.getSingleLateBoundPropertyNameOfPropertyName = getSingleLateBoundPropertyNameOfPropertyName;\r
+function unwrapParentheses(node) {\r
+    while (node.kind === ts.SyntaxKind.ParenthesizedExpression)\r
+        node = node.expression;\r
+    return node;\r
+}\r
+exports.unwrapParentheses = unwrapParentheses;\r
+function formatPseudoBigInt(v) {\r
+    return `${v.negative ? '-' : ''}${v.base10Value}n`;\r
+}\r
+exports.formatPseudoBigInt = formatPseudoBigInt;\r
+/**\r
+ * Determines whether the given `SwitchStatement`'s `case` clauses cover every possible value of the switched expression.\r
+ * The logic is the same as TypeScript's control flow analysis.\r
+ * This does **not** check whether all `case` clauses do a certain action like assign a variable or return a value.\r
+ * This function ignores the `default` clause if present.\r
+ */\r
+function hasExhaustiveCaseClauses(node, checker) {\r
+    const caseClauses = node.caseBlock.clauses.filter(node_1.isCaseClause);\r
+    if (caseClauses.length === 0)\r
+        return false;\r
+    const typeParts = type_1.unionTypeParts(checker.getTypeAtLocation(node.expression));\r
+    if (typeParts.length > caseClauses.length)\r
+        return false;\r
+    const types = new Set(typeParts.map(getPrimitiveLiteralFromType));\r
+    if (types.has(undefined))\r
+        return false;\r
+    const seen = new Set();\r
+    for (const clause of caseClauses) {\r
+        const expressionType = checker.getTypeAtLocation(clause.expression);\r
+        if (exports.isTypeFlagSet(expressionType, ts.TypeFlags.Never))\r
+            continue; // additional case clause with 'never' is always allowed\r
+        const type = getPrimitiveLiteralFromType(expressionType);\r
+        if (types.has(type)) {\r
+            seen.add(type);\r
+        }\r
+        else if (type !== 'null' && type !== 'undefined') { // additional case clauses with 'null' and 'undefined' are always allowed\r
+            return false;\r
+        }\r
+    }\r
+    return types.size === seen.size;\r
+}\r
+exports.hasExhaustiveCaseClauses = hasExhaustiveCaseClauses;\r
+function getPrimitiveLiteralFromType(t) {\r
+    if (exports.isTypeFlagSet(t, ts.TypeFlags.Null))\r
+        return 'null';\r
+    if (exports.isTypeFlagSet(t, ts.TypeFlags.Undefined))\r
+        return 'undefined';\r
+    if (exports.isTypeFlagSet(t, ts.TypeFlags.NumberLiteral))\r
+        return `${exports.isTypeFlagSet(t, ts.TypeFlags.EnumLiteral) ? 'enum:' : ''}${t.value}`;\r
+    if (exports.isTypeFlagSet(t, ts.TypeFlags.StringLiteral))\r
+        return `${exports.isTypeFlagSet(t, ts.TypeFlags.EnumLiteral) ? 'enum:' : ''}string:${t.value}`;\r
+    if (exports.isTypeFlagSet(t, ts.TypeFlags.BigIntLiteral))\r
+        return formatPseudoBigInt(t.value);\r
+    if (_3_2_1.isUniqueESSymbolType(t))\r
+        return t.escapedName;\r
+    if (type_1.isBooleanLiteralType(t, true))\r
+        return 'true';\r
+    if (type_1.isBooleanLiteralType(t, false))\r
+        return 'false';\r
+}\r
+function getBaseOfClassLikeExpression(node) {\r
+    var _a;\r
+    if (((_a = node.heritageClauses) === null || _a === void 0 ? void 0 : _a[0].token) === ts.SyntaxKind.ExtendsKeyword)\r
+        return node.heritageClauses[0].types[0];\r
+}\r
+exports.getBaseOfClassLikeExpression = getBaseOfClassLikeExpression;\r
+//# sourceMappingURL=util.js.map
\ No newline at end of file