MCPcopy Create free account
hub / github.com/angular/angular / setup

Function setup

packages/compiler-cli/src/ngtsc/typecheck/testing/index.ts:541–781  ·  view source on GitHub ↗
(
  targets: TypeCheckingTarget[],
  overrides: {
    config?: Partial<TypeCheckingConfig>;
    options?: ts.CompilerOptions;
    inlining?: boolean;
    inliningMode?: InliningMode;
    parseOptions?: ParseTemplateOptions;
    referenceEmitter?: ReferenceEmitter;
  } = {},
  load: {
    forms?: boolean;
  } = {},
)

Source from the content-addressed store, hash-verified

539 * that can be auto-generated based on the provided target configuration.
540 */
541export function setup(
542 targets: TypeCheckingTarget[],
543 overrides: {
544 config?: Partial<TypeCheckingConfig>;
545 options?: ts.CompilerOptions;
546 inlining?: boolean;
547 inliningMode?: InliningMode;
548 parseOptions?: ParseTemplateOptions;
549 referenceEmitter?: ReferenceEmitter;
550 } = {},
551 load: {
552 forms?: boolean;
553 } = {},
554): {
555 templateTypeChecker: TemplateTypeChecker;
556 program: ts.Program;
557 programStrategy: TsCreateProgramDriver;
558} {
559 const files = [
560 typescriptLibDts(),
561 ...angularCoreDtsFiles(),
562 angularAnimationsDts(),
563 ...(load.forms ? angularFormsDtsFiles() : []),
564 ];
565 const fakeMetadataRegistry = new Map();
566 const shims = new Map<AbsoluteFsPath, AbsoluteFsPath>();
567
568 for (const target of targets) {
569 let contents: string;
570 if (target.source !== undefined) {
571 contents = target.source;
572 } else {
573 contents = `// generated from templates\n\nexport const MODULE = true;\n\n`;
574 if (target.templates) {
575 for (const className of Object.keys(target.templates)) {
576 contents += `export class ${className} {}\n`;
577 }
578 }
579 }
580
581 files.push({name: target.fileName, contents});
582
583 if (!target.fileName.endsWith('.d.ts')) {
584 const shimName = TypeCheckShimGenerator.shimFor(target.fileName);
585 shims.set(target.fileName, shimName);
586 files.push({name: shimName, contents: 'export const MODULE = true;'});
587 }
588 }
589
590 const opts = overrides.options ?? {};
591 const config = overrides.config ?? {};
592
593 const {program, host, options} = makeProgram(
594 files,
595 {strictNullChecks: true, skipLibCheck: true, noImplicitAny: true, ...opts},
596 /* host */ undefined,
597 /* checkForErrors */ false,
598 );

Calls 15

makeProgramFunction · 0.90
getRootDirsFunction · 0.90
getSourceFileOrErrorFunction · 0.90
sfExtensionDataFunction · 0.90
parseTemplateFunction · 0.90
typescriptLibDtsFunction · 0.85
angularCoreDtsFilesFunction · 0.85
angularAnimationsDtsFunction · 0.85
angularFormsDtsFilesFunction · 0.85
makeScopeFunction · 0.85
createTypeCheckAdapterFunction · 0.85
prepareDeclarationsFunction · 0.85

Tested by 1

diagnoseTestComponentFunction · 0.72