@@ -17,6 +17,8 @@ namespace ts { // eslint-disable-line one-namespace-per-file
1717
1818 let mode : Mode ;
1919
20+ const typeCatalog : Type [ ] = [ ] ; // NB: id is index + 1
21+
2022 let legendPath : string | undefined ;
2123 const legend : TraceRecord [ ] = [ ] ;
2224
@@ -39,6 +41,7 @@ namespace ts { // eslint-disable-line one-namespace-per-file
3941 }
4042
4143 mode = tracingMode ;
44+ typeCatalog . length = 0 ;
4245
4346 if ( legendPath === undefined ) {
4447 legendPath = combinePaths ( traceDir , "legend.json" ) ;
@@ -76,15 +79,15 @@ namespace ts { // eslint-disable-line one-namespace-per-file
7679 }
7780
7881 /** Stops tracing for the in-progress project and dumps the type catalog. */
79- export function stopTracing ( typeCatalog ?: readonly Type [ ] ) {
82+ export function stopTracing ( ) {
8083 Debug . assert ( tracing , "Tracing is not in progress" ) ;
81- Debug . assert ( ! ! typeCatalog === ( mode !== "server" ) ) ; // Have a type catalog iff not in server mode
84+ Debug . assert ( ! ! typeCatalog . length === ( mode !== "server" ) ) ; // Have a type catalog iff not in server mode
8285
8386 fs . writeSync ( traceFd , `\n]\n` ) ;
8487 fs . closeSync ( traceFd ) ;
8588 tracing = undefined ;
8689
87- if ( typeCatalog ) {
90+ if ( typeCatalog . length ) {
8891 dumpTypes ( typeCatalog ) ;
8992 }
9093 else {
@@ -94,6 +97,12 @@ namespace ts { // eslint-disable-line one-namespace-per-file
9497 }
9598 }
9699
100+ export function recordType ( type : Type ) : void {
101+ if ( mode !== "server" ) {
102+ typeCatalog . push ( type ) ;
103+ }
104+ }
105+
97106 export const enum Phase {
98107 Parse = "parse" ,
99108 Program = "program" ,
0 commit comments