File
context
|
Type
|
ExecutorContext
|
import { ExecutorContext } from '@nx/devkit';
import ts from 'typescript';
import { ExecutorLogger } from '../logger';
export interface IntrospectionContextRequirements {
root: string;
files: string[];
context: ExecutorContext;
logger: ExecutorLogger;
}
export interface IntrospectionContext {
program: ts.Program;
checker: ts.TypeChecker;
context: ExecutorContext;
logger: ExecutorLogger;
}
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;
}
}