File

libs/nx/src/executors/shared/introspection/types.ts

Index

Properties

Properties

context
Type BuilderContext
files
Type string[]
logger
Type Logger
root
Type string
import { BuilderContext } from '@angular-devkit/architect';
import { Logger } from '@angular-devkit/core/src/logger';
import ts from 'typescript';

export interface IntrospectionContextRequirements {
  root: string;
  files: string[];
  context: BuilderContext;
  logger: Logger;
}

export interface IntrospectionContext {
  program: ts.Program;
  checker: ts.TypeChecker;
  context: BuilderContext;
  logger: Logger;
}

export interface IntrospectionContractType {
  name: string;
  properties?: IntrospectionContractType[];
  type: string;
}

/**
 * Given a TypeArgument node.
 * We won't accept anything that is not a type reference (e.g. literals: `Class<number, string>`).
 * If a value is not a type reference we want to coerce it into null
 * to prevent the analysis of code we are not expecting here.
 */
export function getCoercedTypeNode(typeArgumentData: ts.TypeNode) {
  const isTypeReference = (item: ts.TypeNode) => item?.kind === ts.SyntaxKind.TypeReference;

  if (isTypeReference(typeArgumentData)) {
    return typeArgumentData;
  } else {
    return null;
  }
}

results matching ""

    No results matching ""