@@ -1511,10 +1511,14 @@ export function createProgram(createProgramOptions: CreateProgramOptions): Progr
15111511 * @returns A 'Program' object.
15121512 */
15131513export function createProgram ( rootNames : readonly string [ ] , options : CompilerOptions , host ?: CompilerHost , oldProgram ?: Program , configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : Program ;
1514- export function createProgram ( rootNamesOrOptions : readonly string [ ] | CreateProgramOptions , _options ?: CompilerOptions , _host ?: CompilerHost , _oldProgram ?: Program , _configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : Program {
1515- const createProgramOptions = isArray ( rootNamesOrOptions ) ? createCreateProgramOptions ( rootNamesOrOptions , _options ! , _host , _oldProgram , _configFileParsingDiagnostics ) : rootNamesOrOptions ; // TODO: GH#18217
1516- const { rootNames, options, configFileParsingDiagnostics, projectReferences, typeScriptVersion } = createProgramOptions ;
1517- let { oldProgram } = createProgramOptions ;
1514+ export function createProgram ( _rootNamesOrOptions : readonly string [ ] | CreateProgramOptions , _options ?: CompilerOptions , _host ?: CompilerHost , _oldProgram ?: Program , _configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : Program {
1515+ let _createProgramOptions = isArray ( _rootNamesOrOptions ) ? createCreateProgramOptions ( _rootNamesOrOptions , _options ! , _host , _oldProgram , _configFileParsingDiagnostics ) : _rootNamesOrOptions ; // TODO: GH#18217
1516+ const { rootNames, options, configFileParsingDiagnostics, projectReferences, typeScriptVersion, host : createProgramOptionsHost } = _createProgramOptions ;
1517+ let { oldProgram } = _createProgramOptions ;
1518+ // Stop referencing these objects to ensure GC collects them.
1519+ _createProgramOptions = undefined ! ;
1520+ _rootNamesOrOptions = undefined ! ;
1521+
15181522 for ( const option of commandLineOptionOfCustomType ) {
15191523 if ( hasProperty ( options , option . name ) ) {
15201524 if ( typeof options [ option . name ] === "string" ) {
@@ -1569,7 +1573,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
15691573 tracing ?. push ( tracing . Phase . Program , "createProgram" , { configFilePath : options . configFilePath , rootDir : options . rootDir } , /*separateBeginAndEnd*/ true ) ;
15701574 performance . mark ( "beforeProgram" ) ;
15711575
1572- const host = createProgramOptions . host || createCompilerHost ( options ) ;
1576+ const host = createProgramOptionsHost || createCompilerHost ( options ) ;
15731577 const configParsingHost = parseConfigHostFromCompilerHostLike ( host ) ;
15741578
15751579 let skipDefaultLib = options . noLib ;
0 commit comments