How to use the tsutils.isSymbolFlagSet function in tsutils

To help you get started, we’ve selected a few tsutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fossasia / susper.com / node_modules / tslint / lib / rules / noUnusedVariableRule.js View on Github external
function isImportUsed(importSpecifier, sourceFile, checker) {
    var importedSymbol = checker.getSymbolAtLocation(importSpecifier);
    if (importedSymbol === undefined) {
        return false;
    }
    var symbol = checker.getAliasedSymbol(importedSymbol);
    if (!utils.isSymbolFlagSet(symbol, ts.SymbolFlags.Type)) {
        return false;
    }
    return (ts.forEachChild(sourceFile, function cb(child) {
        if (isImportLike(child)) {
            return false;
        }
        var type = getImplicitType(child, checker);
        // TODO: checker.typeEquals https://github.com/Microsoft/TypeScript/issues/13502
        if (type !== undefined &&
            checker.typeToString(type) === checker.symbolToString(symbol)) {
            return true;
        }
        return ts.forEachChild(child, cb);
    }) === true);
}
function getImplicitType(node, checker) {
github fossasia / susper.com / node_modules / tslint / lib / rules / noUnsafeAnyRule.js View on Github external
function isNodeAny(node, checker) {
    var symbol = checker.getSymbolAtLocation(node);
    if (symbol !== undefined && tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)) {
        symbol = checker.getAliasedSymbol(symbol);
    }
    if (symbol !== undefined) {
        // NamespaceModule is a type-only namespace without runtime value, its type is 'any' when used as 'ns.Type' -> avoid error
        if (tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.NamespaceModule)) {
            return false;
        }
        if (tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.Type)) {
            return isAny(checker.getDeclaredTypeOfSymbol(symbol));
        }
    }
    // Lowercase JSX elements are assumed to be allowed by design
    if (isJsxNativeElement(node)) {
        return false;
    }
    return isAny(checker.getTypeAtLocation(node));
}
var jsxElementTypes = new Set([
github palantir / tslint / src / rules / deprecationRule.ts View on Github external
let symbol: ts.Symbol | undefined;
    const parent = node.parent;
    if (parent.kind === ts.SyntaxKind.BindingElement) {
        symbol = tc.getTypeAtLocation(parent.parent).getProperty(node.text);
    } else if (
        (isPropertyAssignment(parent) && parent.name === node) ||
        (isShorthandPropertyAssignment(parent) &&
            parent.name === node &&
            isReassignmentTarget(node))
    ) {
        symbol = tc.getPropertySymbolOfDestructuringAssignment(node);
    } else {
        symbol = tc.getSymbolAtLocation(node);
    }

    if (symbol !== undefined && isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)) {
        symbol = tc.getAliasedSymbol(symbol);
    }
    if (
        symbol === undefined ||
        // if this is a CallExpression and the declaration is a function or method,
        // stop here to avoid collecting JsDoc of all overload signatures
        (callExpression !== undefined && isFunctionOrMethod(symbol.declarations))
    ) {
        return undefined;
    }
    return getSymbolDeprecation(symbol);
}
github nativescript-rtl / ui / node_modules / tslint / lib / rules / noUnsafeAnyRule.js View on Github external
function isNodeAny(node, checker, orUnknown) {
    if (orUnknown === void 0) { orUnknown = false; }
    var symbol = checker.getSymbolAtLocation(node);
    if (symbol !== undefined && tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)) {
        symbol = checker.getAliasedSymbol(symbol);
    }
    if (symbol !== undefined) {
        // NamespaceModule is a type-only namespace without runtime value, its type is 'any' when used as 'ns.Type' -> avoid error
        if (tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.NamespaceModule)) {
            return false;
        }
        if (tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.Type)) {
            return isAny(checker.getDeclaredTypeOfSymbol(symbol), orUnknown);
        }
    }
    // Lowercase JSX elements are assumed to be allowed by design
    if (isJsxNativeElement(node)) {
        return false;
    }
    return isAny(checker.getTypeAtLocation(node), orUnknown);
github nativescript-rtl / ui / node_modules / tslint / lib / rules / noUnusedVariableRule.js View on Github external
function isImportUsed(importSpecifier, sourceFile, checker) {
    var importedSymbol = checker.getSymbolAtLocation(importSpecifier);
    if (importedSymbol === undefined) {
        return false;
    }
    var symbol = checker.getAliasedSymbol(importedSymbol);
    if (!utils.isSymbolFlagSet(symbol, ts.SymbolFlags.Type)) {
        return false;
    }
    return (ts.forEachChild(sourceFile, function cb(child) {
        if (isImportLike(child)) {
            return false;
        }
        var type = getImplicitType(child, checker);
        // TODO: checker.typeEquals https://github.com/Microsoft/TypeScript/issues/13502
        if (type !== undefined &&
            checker.typeToString(type) === checker.symbolToString(symbol)) {
            return true;
        }
        return ts.forEachChild(child, cb);
    }) === true);
}
function getImplicitType(node, checker) {
github palantir / tslint / src / rules / noUnnecessaryQualifierRule.ts View on Github external
function tryGetAliasedSymbol(symbol: ts.Symbol, checker: ts.TypeChecker): ts.Symbol | undefined {
    return utils.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)
        ? checker.getAliasedSymbol(symbol)
        : undefined;
}
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / no-unnecessary-qualifier.ts View on Github external
function tryGetAliasedSymbol(
      symbol: ts.Symbol,
      checker: ts.TypeChecker,
    ): ts.Symbol | null {
      return tsutils.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)
        ? checker.getAliasedSymbol(symbol)
        : null;
    }