Skip to content

Commit f723beb

Browse files
committed
More updates per PR feedback
1 parent 02b8a7d commit f723beb

5 files changed

Lines changed: 286 additions & 256 deletions

File tree

src/compiler/core.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,19 @@ namespace ts {
534534
return result;
535535
}
536536

537+
export function mapDefinedIter<T, U>(iter: Iterator<T>, mapFn: (x: T) => U | undefined): U[] {
538+
const result: U[] = [];
539+
while (true) {
540+
const { value, done } = iter.next();
541+
if (done) break;
542+
const res = mapFn(value);
543+
if (res !== undefined) {
544+
result.push(res);
545+
}
546+
}
547+
return result;
548+
}
549+
537550
/**
538551
* Computes the first matching span of elements and returns a tuple of the first span
539552
* and the remaining elements.

src/harness/unittests/cachingInServerLSHost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace ts {
7474
const projectService = new server.ProjectService(svcOpts);
7575
const rootScriptInfo = projectService.getOrCreateScriptInfo(rootFile, /* openedByClient */ true, /*containingProject*/ undefined);
7676

77-
const project = projectService.createInferredProjectWithRootFileIfNecessary(rootScriptInfo);
77+
const project = projectService.assignScriptInfoToInferredProject(rootScriptInfo);
7878
project.setCompilerOptions({ module: ts.ModuleKind.AMD, noLib: true } );
7979
return {
8080
project,

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ namespace ts.projectSystem {
263263

264264
function invokeWatcherCallbacks<T>(callbacks: T[], invokeCallback: (cb: T) => void): void {
265265
if (callbacks) {
266+
// The array copy is made to ensure that even if one of the callback removes the callbacks,
267+
// we dont miss any callbacks following it
266268
const cbs = callbacks.slice();
267269
for (const cb of cbs) {
268270
invokeCallback(cb);

0 commit comments

Comments
 (0)