mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 06:41:59 -06:00
Add 'clear' helper (#17209)
This commit is contained in:
parent
194c2bc2ca
commit
08a57d82cd
@ -22266,8 +22266,8 @@ namespace ts {
|
||||
// Grammar checking
|
||||
checkGrammarSourceFile(node);
|
||||
|
||||
potentialThisCollisions.length = 0;
|
||||
potentialNewTargetCollisions.length = 0;
|
||||
clear(potentialThisCollisions);
|
||||
clear(potentialNewTargetCollisions);
|
||||
|
||||
deferredNodes = [];
|
||||
deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined;
|
||||
@ -22293,12 +22293,12 @@ namespace ts {
|
||||
|
||||
if (potentialThisCollisions.length) {
|
||||
forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
|
||||
potentialThisCollisions.length = 0;
|
||||
clear(potentialThisCollisions);
|
||||
}
|
||||
|
||||
if (potentialNewTargetCollisions.length) {
|
||||
forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope);
|
||||
potentialNewTargetCollisions.length = 0;
|
||||
clear(potentialNewTargetCollisions);
|
||||
}
|
||||
|
||||
links.flags |= NodeCheckFlags.TypeChecked;
|
||||
|
||||
@ -384,6 +384,10 @@ namespace ts {
|
||||
array.length = outIndex;
|
||||
}
|
||||
|
||||
export function clear(array: {}[]): void {
|
||||
array.length = 0;
|
||||
}
|
||||
|
||||
export function map<T, U>(array: ReadonlyArray<T>, f: (x: T, i: number) => U): U[] {
|
||||
let result: U[];
|
||||
if (array) {
|
||||
|
||||
@ -561,7 +561,7 @@ namespace ts.projectSystem {
|
||||
}
|
||||
|
||||
clearOutput() {
|
||||
this.output.length = 0;
|
||||
clear(this.output);
|
||||
}
|
||||
|
||||
readonly readFile = (s: string) => (<File>this.fs.get(this.toPath(s))).content;
|
||||
|
||||
@ -223,7 +223,7 @@ namespace ts.server {
|
||||
for (const reference of this.references) {
|
||||
reference.removeReferencedBy(this);
|
||||
}
|
||||
this.references = createSortedArray<ModuleBuilderFileInfo>();
|
||||
clear(this.references);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -242,7 +242,7 @@ namespace ts.server {
|
||||
// detach is unnecessary since we'll clean the list of containing projects anyways
|
||||
p.removeFile(this, /*detachFromProjects*/ false);
|
||||
}
|
||||
this.containingProjects.length = 0;
|
||||
clear(this.containingProjects);
|
||||
}
|
||||
|
||||
getDefaultProject() {
|
||||
|
||||
@ -1176,7 +1176,7 @@ namespace ts {
|
||||
|
||||
public close(): void {
|
||||
// Forget all the registered shims
|
||||
this._shims = [];
|
||||
clear(this._shims);
|
||||
this.documentRegistry = undefined;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user