@@ -24,6 +24,7 @@ import {
2424import { readFileSync } from 'fs' ;
2525import path from 'path' ;
2626import ts from 'typescript' ;
27+ import { globSync } from 'tinyglobby' ;
2728
2829import {
2930 absoluteFrom ,
@@ -153,19 +154,19 @@ export function typescriptLibDts(): TestFile {
153154 } ;
154155}
155156
157+ let _angularCoreDts : TestFile [ ] | null = null ;
156158export function angularCoreDtsFiles ( ) : TestFile [ ] {
159+ if ( _angularCoreDts !== null ) {
160+ return _angularCoreDts ;
161+ }
162+
157163 const directory = resolveFromRunfiles ( 'angular/packages/core/npm_package' ) ;
164+ const dtsFiles = globSync ( '**/*.d.ts' , { cwd : directory } ) ;
158165
159- return [
160- {
161- name : absoluteFrom ( '/node_modules/@angular/core/index.d.ts' ) ,
162- contents : readFileSync ( path . join ( directory , 'index.d.ts' ) , 'utf8' ) ,
163- } ,
164- {
165- name : absoluteFrom ( '/node_modules/@angular/core/primitives/signals/index.d.ts' ) ,
166- contents : readFileSync ( path . join ( directory , 'primitives/signals/index.d.ts' ) , 'utf8' ) ,
167- } ,
168- ] ;
166+ return ( _angularCoreDts = dtsFiles . map ( ( fileName ) => ( {
167+ name : absoluteFrom ( `/node_modules/@angular/core/${ fileName } ` ) ,
168+ contents : readFileSync ( path . join ( directory , fileName ) , 'utf8' ) ,
169+ } ) ) ) ;
169170}
170171
171172export function angularAnimationsDts ( ) : TestFile {
@@ -248,12 +249,7 @@ export function ngForDts(): TestFile {
248249
249250export function ngForTypeCheckTarget ( ) : TypeCheckingTarget {
250251 const dts = ngForDts ( ) ;
251- return {
252- ...dts ,
253- fileName : dts . name ,
254- source : dts . contents ,
255- templates : { } ,
256- } ;
252+ return { ...dts , fileName : dts . name , source : dts . contents , templates : { } } ;
257253}
258254
259255export const ALL_ENABLED_CONFIG : Readonly < TypeCheckingConfig > = {
@@ -427,9 +423,7 @@ export function tcb(
427423 checkTwoWayBoundEvents : true ,
428424 ...config ,
429425 } ;
430- options = options || {
431- emitSpans : false ,
432- } ;
426+ options = options || { emitSpans : false } ;
433427
434428 const fileName = absoluteFrom ( '/type-check-file.ts' ) ;
435429
@@ -520,18 +514,12 @@ export function setup(
520514 }
521515 }
522516
523- files . push ( {
524- name : target . fileName ,
525- contents,
526- } ) ;
517+ files . push ( { name : target . fileName , contents} ) ;
527518
528519 if ( ! target . fileName . endsWith ( '.d.ts' ) ) {
529520 const shimName = TypeCheckShimGenerator . shimFor ( target . fileName ) ;
530521 shims . set ( target . fileName , shimName ) ;
531- files . push ( {
532- name : shimName ,
533- contents : 'export const MODULE = true;' ,
534- } ) ;
522+ files . push ( { name : shimName , contents : 'export const MODULE = true;' } ) ;
535523 }
536524 }
537525
@@ -540,12 +528,7 @@ export function setup(
540528
541529 const { program, host, options} = makeProgram (
542530 files ,
543- {
544- strictNullChecks : true ,
545- skipLibCheck : true ,
546- noImplicitAny : true ,
547- ...opts ,
548- } ,
531+ { strictNullChecks : true , skipLibCheck : true , noImplicitAny : true , ...opts } ,
549532 /* host */ undefined ,
550533 /* checkForErrors */ false ,
551534 ) ;
@@ -587,10 +570,7 @@ export function setup(
587570 if ( shims . has ( target . fileName ) ) {
588571 const shimFileName = shims . get ( target . fileName ) ! ;
589572 const shimSf = getSourceFileOrError ( program , shimFileName ) ;
590- sfExtensionData ( shimSf ) . fileShim = {
591- extension : 'ngtypecheck' ,
592- generatedFrom : target . fileName ,
593- } ;
573+ sfExtensionData ( shimSf ) . fileShim = { extension : 'ngtypecheck' , generatedFrom : target . fileName } ;
594574 }
595575
596576 for ( const className of Object . keys ( target . templates ) ) {
@@ -671,10 +651,7 @@ export function setup(
671651 if ( ! scopeMap . has ( clazz ) ) {
672652 // This class wasn't part of the target set of components with templates, but is
673653 // probably a declaration used in one of them. Return an empty scope.
674- const emptyScope : ScopeData = {
675- dependencies : [ ] ,
676- isPoisoned : false ,
677- } ;
654+ const emptyScope : ScopeData = { dependencies : [ ] , isPoisoned : false } ;
678655 return {
679656 kind : ComponentScopeKind . NgModule ,
680657 ngModule,
@@ -725,11 +702,7 @@ export function setup(
725702 typeCheckScopeRegistry ,
726703 NOOP_PERF_RECORDER ,
727704 ) ;
728- return {
729- templateTypeChecker,
730- program,
731- programStrategy,
732- } ;
705+ return { templateTypeChecker, program, programStrategy} ;
733706}
734707
735708/**
@@ -748,14 +721,7 @@ export function diagnose(
748721 const sfPath = absoluteFrom ( '/main.ts' ) ;
749722 const { program, templateTypeChecker} = setup (
750723 [
751- {
752- fileName : sfPath ,
753- templates : {
754- 'TestComponent' : template ,
755- } ,
756- source,
757- declarations,
758- } ,
724+ { fileName : sfPath , templates : { 'TestComponent' : template } , source, declarations} ,
759725 ...additionalSources . map ( ( testFile ) => ( {
760726 fileName : testFile . name ,
761727 source : testFile . contents ,
@@ -910,10 +876,7 @@ function getDirectiveMetaFromDeclaration(
910876 * Synthesize `ScopeData` metadata from an array of `TestDeclaration`s.
911877 */
912878function makeScope ( program : ts . Program , sf : ts . SourceFile , decls : TestDeclaration [ ] ) : ScopeData {
913- const scope : ScopeData = {
914- dependencies : [ ] ,
915- isPoisoned : false ,
916- } ;
879+ const scope : ScopeData = { dependencies : [ ] , isPoisoned : false } ;
917880
918881 for ( const decl of decls ) {
919882 let declSf = sf ;
0 commit comments