Keen Yee Liau 183fb7e7b9 fix(language-service): return all typecheck files via getExternalFiles (#40162)
We need a means to preserve typecheck files when a project is reloaded,
otherwise the Ivy compiler will throw an error when it's unable to find
them. This commit implements `getExternalFiles()` called by the langauge
server to achieve this goal.

For more info see https://github.com/angular/vscode-ng-language-service/issues/1030

PR Close #40162
2021-01-06 11:34:15 -08:00

30 lines
1.0 KiB
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {LanguageService} from '../../language_service';
import {getExternalFiles} from '../../ts_plugin';
import {APP_COMPONENT, setup} from './mock_host';
describe('getExternalFiles()', () => {
it('should return all typecheck files', () => {
const {project, tsLS} = setup();
let externalFiles = getExternalFiles(project);
// Initially there are no external files because Ivy compiler hasn't done
// a global analysis
expect(externalFiles).toEqual([]);
// Trigger global analysis
const ngLS = new LanguageService(project, tsLS);
ngLS.getSemanticDiagnostics(APP_COMPONENT);
// Now that global analysis is run, we should have all the typecheck files
externalFiles = getExternalFiles(project);
expect(externalFiles.length).toBe(1);
expect(externalFiles[0].endsWith('app.component.ngtypecheck.ts')).toBeTrue();
});
});