How to use the typescript.isPropertyAccessExpression function in typescript

To help you get started, we’ve selected a few typescript 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 denoland / deno_website2 / src / util / doc_parser.ts View on Github external
this.visitMethod(node, symbol.getName());
    } else if (ts.isFunctionTypeNode(node)) {
      log("- FunctionTypeNode.. ?");
    } else if (ts.isFunctionExpression(node)) {
      const sym = this.checker.getSymbolAtLocation(node.name);
      const name = sym ? sym.getName() : "";
      log("- FunctionExpression", name);
    } else if (ts.isInterfaceDeclaration(node)) {
      this.visitClass(node);
    } else if (ts.isObjectLiteralExpression(node)) {
      // TODO Ignoring for now.
      log("- ObjectLiteralExpression");
    } else if (ts.isTypeLiteralNode(node)) {
      // TODO Ignoring for now.
      log("- TypeLiteral");
    } else if (ts.isPropertyAccessExpression(node)) {
      log("- PropertyAccessExpression");
      //const symbol = this.checker.getSymbolAtLocation(node.name);
      //this.visitMethod(node, symbol.getName());
    } else if (ts.isEnumDeclaration(node)) {
      const sym = this.checker.getSymbolAtLocation(node.name);
      const name = sym ? sym.getName() : "";
      log("- EnumDeclaration", name);
      const docstr = this.getFlatDocstr(sym);
      this.output.push({
        name,
        kind: "enum",
        docstr
      });
      for (let m of node.members) {
        const sym = this.checker.getSymbolAtLocation(m.name);
        const memberName = sym ? sym.getName() : "";
github propelml / propel / tools / gendoc.ts View on Github external
function classElementName(m: ts.ClassElement | ts.TypeElement): string {
    if (m.name) {
      if (ts.isIdentifier(m.name)) {
        return ts.idText(m.name);
      }
      if (ts.isComputedPropertyName(m.name)) {
        const e = m.name.expression;
        if (ts.isPropertyAccessExpression(e)) {
          // This is for [Symbol.iterator]() { }
          assert(ts.isIdentifier(e.name));
          return `[Symbol.${e.name.text}]`;
        }
      }
    }
    return "";
  }
github angular / angular-cli / packages / ngtools / webpack / src / transformers / replace_resources.ts View on Github external
function getDecoratorOrigin(
  decorator: ts.Decorator,
  typeChecker: ts.TypeChecker,
): DecoratorOrigin | null {
  if (!ts.isCallExpression(decorator.expression)) {
    return null;
  }

  let identifier: ts.Node;
  let name = '';

  if (ts.isPropertyAccessExpression(decorator.expression.expression)) {
    identifier = decorator.expression.expression.expression;
    name = decorator.expression.expression.name.text;
  } else if (ts.isIdentifier(decorator.expression.expression)) {
    identifier = decorator.expression.expression;
  } else {
    return null;
  }

  // NOTE: resolver.getReferencedImportDeclaration would work as well but is internal
  const symbol = typeChecker.getSymbolAtLocation(identifier);
  if (symbol && symbol.declarations && symbol.declarations.length > 0) {
    const declaration = symbol.declarations[0];
    let module: string;

    if (ts.isImportSpecifier(declaration)) {
      name = (declaration.propertyName || declaration.name).text;
github Gelio / tslint-react-hooks / src / react-hooks-nesting-walker / is-hook-call.ts View on Github external
export function isHookCall(
  { expression }: CallExpression,
  ruleOptions: RuleOptions,
) {
  if (isIdentifier(expression) && isHookIdentifier(expression)) {
    return true;
  } else if (
    isPropertyAccessExpression(expression) &&
    isHookIdentifier(expression.name)
  ) {
    if (ruleOptions[detectHooksFromNonReactNamespaceOptionName]) {
      return true;
    }

    /**
     * The expression from which the property is accessed.
     *
     * @example for `React.useState`, this would be the `React` identifier
     */
    const sourceExpression = expression.expression;

    return isReactIdentifier(sourceExpression);
  }
github neo-one-suite / neo-one / packages / neo-one-typescript-concatenator / src / Concatenator.ts View on Github external
public readonly substituteNode = (_hint: ts.EmitHint, node: ts.Node) => {
    if (ts.isIdentifier(node)) {
      const parent = tsUtils.node.getParent(node) as ts.Node | undefined;
      if (parent !== undefined && ts.isPropertyAccessExpression(parent) && tsUtils.node.getNameNode(parent) === node) {
        return node;
      }

      return this.getIdentifierForIdentifier(node);
    }

    if (ts.isImportDeclaration(node)) {
      if (this.isExternalFileImportExport(node)) {
        return this.getCombinedImport(node);
      }

      const importFile = tsUtils.importExport.getModuleSpecifierSourceFile(this.context.typeChecker, node);
      const namespaceIdentifier = tsUtils.importDeclaration.getNamespaceImportIdentifier(node);
      if (importFile !== undefined && namespaceIdentifier !== undefined) {
        const exportedSymbols = tsUtils.file.getExportedSymbols(this.context.typeChecker, importFile);
github angular / tsickle / src / googmodule.ts View on Github external
function isPropertyAccess(node: ts.Node, parent: string, child: string): boolean {
  if (!ts.isPropertyAccessExpression(node)) return false;
  return ts.isIdentifier(node.expression) && node.expression.escapedText === parent &&
      node.name.escapedText === child;
}
github urish / ng-lift / src / template-expression.ts View on Github external
function visitor(node: ts.Node): ts.Node {
            if (ts.isPropertyAccessExpression(node)
                && ts.isIdentifier(node.expression)
                && controllerVars.indexOf(node.expression.text) >= 0) {
                node = node.name;
            }
            if (ts.isElementAccessExpression(node)
                && ts.isIdentifier(node.expression)
                && controllerVars.indexOf(node.expression.text) >= 0
                && node.argumentExpression
                && ts.isStringLiteral(node.argumentExpression)) {
                node = ts.createIdentifier(node.argumentExpression.text);
            }
            return ts.visitEachChild(node, visitor, context);
        }
        return ts.visitNode(root, visitor);
github DonJayamanne / pythonVSCode / build / tslint-rules / messagesMustBeLocalizedRule.js View on Github external
shouldIgnoreNode(node) {
        if (this.shouldIgnoreCurrentFile(node)) {
            return true;
        }
        if (!ts.isPropertyAccessExpression(node.expression)) {
            return true;
        }
        const prop = node.expression;
        if (methodNames.indexOf(prop.name.text) < 0) {
            return true;
        }
        return false;
    }
}
github Glavin001 / tslint-clean-code / src / noMapWithoutUsageRule.ts View on Github external
private parentUsesNode(parent?: ts.Node) {
        return (
            parent &&
            (ts.isPropertyAccessExpression(parent) ||
                ts.isPropertyDeclaration(parent) ||
                ts.isReturnStatement(parent) ||
                ts.isCallOrNewExpression(parent) ||
                ts.isSpreadElement(parent) ||
                ts.isJsxExpression(parent) ||
                ts.isConditionalExpression(parent) ||
                ts.isArrayLiteralExpression(parent) ||
                ts.isBinaryExpression(parent) ||
                ts.isArrowFunction(parent))
        );
    }
}
github nrwl / nx / packages / schematics / migrations / update-7-6-0 / update-7-6-0.ts View on Github external
effects.forEach(effect => {
    if (
      ts.isCallExpression(effect.initializer) &&
      ts.isPropertyAccessExpression(effect.initializer.expression) &&
      effect.initializer.expression.name.text === 'pipe' &&
      ts.isCallExpression(effect.initializer.expression.expression) &&
      ts.isPropertyAccessExpression(
        effect.initializer.expression.expression.expression
      ) &&
      effect.initializer.expression.expression.expression.name.text === 'ofType'
    ) {
      const originalText = effect.initializer.getText(sourceFile);

      const ofTypeExpression = ts.createCall(
        ts.createIdentifier('ofType'),
        effect.initializer.expression.expression.typeArguments,
        effect.initializer.expression.expression.arguments
      );

      const node = ts.createCall(
        ts.createPropertyAccess(
          effect.initializer.expression.expression.expression.expression,
          'pipe'