diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 629063de29808..ab3909d8e2385 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -98,7 +98,6 @@ import { PrefixUnaryExpression, ProjectReference, PropertyName, - Push, removeTrailingDirectorySeparator, returnTrue, ScriptTarget, @@ -1699,12 +1698,12 @@ function createDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType } /** @internal */ -export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Push) { +export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); } /** @internal */ -export function parseListTypeOption(opt: CommandLineOptionOfListType, value = "", errors: Push): string | (string | number)[] | undefined { +export function parseListTypeOption(opt: CommandLineOptionOfListType, value = "", errors: Diagnostic[]): string | (string | number)[] | undefined { value = trimString(value); if (startsWith(value, "-")) { return undefined; @@ -2254,7 +2253,7 @@ export interface JsonConversionNotifier { onSetUnknownOptionKeyValueInRoot(key: string, keyNode: PropertyName, value: CompilerOptionsValue, valueNode: Expression): void; } -function convertConfigFileToObject(sourceFile: JsonSourceFile, errors: Push, reportOptionsErrors: boolean, optionsIterator: JsonConversionNotifier | undefined): any { +function convertConfigFileToObject(sourceFile: JsonSourceFile, errors: Diagnostic[], reportOptionsErrors: boolean, optionsIterator: JsonConversionNotifier | undefined): any { const rootExpression: Expression | undefined = sourceFile.statements[0]?.expression; const knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; if (rootExpression && rootExpression.kind !== SyntaxKind.ObjectLiteralExpression) { @@ -2295,7 +2294,7 @@ export function convertToObject(sourceFile: JsonSourceFile, errors: Diagnostic[] export function convertToObjectWorker( sourceFile: JsonSourceFile, rootExpression: Expression | undefined, - errors: Push, + errors: Diagnostic[], returnValue: boolean, knownRootOptions: CommandLineOption | undefined, jsonConversionNotifier: JsonConversionNotifier | undefined): any { @@ -3248,7 +3247,7 @@ function parseOwnConfigOfJson( host: ParseConfigHost, basePath: string, configFileName: string | undefined, - errors: Push + errors: Diagnostic[] ): ParsedTsconfig { if (hasProperty(json, "excludes")) { errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); @@ -3290,7 +3289,7 @@ function parseOwnConfigOfJsonSourceFile( host: ParseConfigHost, basePath: string, configFileName: string | undefined, - errors: Push + errors: Diagnostic[] ): ParsedTsconfig { const options = getDefaultCompilerOptions(configFileName); let typeAcquisition: TypeAcquisition | undefined; @@ -3376,7 +3375,7 @@ function getExtendsConfigPath( extendedConfig: string, host: ParseConfigHost, basePath: string, - errors: Push, + errors: Diagnostic[], createDiagnostic: (message: DiagnosticMessage, arg1?: string) => Diagnostic) { extendedConfig = normalizeSlashes(extendedConfig); if (isRootedDiskPath(extendedConfig) || startsWith(extendedConfig, "./") || startsWith(extendedConfig, "../")) { @@ -3450,7 +3449,7 @@ function getExtendedConfig( return extendedConfig!; } -function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Push): boolean { +function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean { if (!hasProperty(jsonOption, compileOnSaveCommandLineOption.name)) { return false; } @@ -3478,7 +3477,7 @@ function getDefaultCompilerOptions(configFileName?: string) { } function convertCompilerOptionsFromJsonWorker(jsonOptions: any, - basePath: string, errors: Push, configFileName?: string): CompilerOptions { + basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions { const options = getDefaultCompilerOptions(configFileName); convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, compilerOptionsDidYouMeanDiagnostics, errors); @@ -3493,23 +3492,23 @@ function getDefaultTypeAcquisition(configFileName?: string): TypeAcquisition { } function convertTypeAcquisitionFromJsonWorker(jsonOptions: any, - basePath: string, errors: Push, configFileName?: string): TypeAcquisition { + basePath: string, errors: Diagnostic[], configFileName?: string): TypeAcquisition { const options = getDefaultTypeAcquisition(configFileName); convertOptionsFromJson(getCommandLineTypeAcquisitionMap(), jsonOptions, basePath, options, typeAcquisitionDidYouMeanDiagnostics, errors); return options; } -function convertWatchOptionsFromJsonWorker(jsonOptions: any, basePath: string, errors: Push): WatchOptions | undefined { +function convertWatchOptionsFromJsonWorker(jsonOptions: any, basePath: string, errors: Diagnostic[]): WatchOptions | undefined { return convertOptionsFromJson(getCommandLineWatchOptionsMap(), jsonOptions, basePath, /*defaultOptions*/ undefined, watchOptionsDidYouMeanDiagnostics, errors); } function convertOptionsFromJson(optionsNameMap: Map, jsonOptions: any, basePath: string, - defaultOptions: undefined, diagnostics: DidYouMeanOptionsDiagnostics, errors: Push): WatchOptions | undefined; + defaultOptions: undefined, diagnostics: DidYouMeanOptionsDiagnostics, errors: Diagnostic[]): WatchOptions | undefined; function convertOptionsFromJson(optionsNameMap: Map, jsonOptions: any, basePath: string, - defaultOptions: CompilerOptions | TypeAcquisition, diagnostics: DidYouMeanOptionsDiagnostics, errors: Push): CompilerOptions | TypeAcquisition; + defaultOptions: CompilerOptions | TypeAcquisition, diagnostics: DidYouMeanOptionsDiagnostics, errors: Diagnostic[]): CompilerOptions | TypeAcquisition; function convertOptionsFromJson(optionsNameMap: Map, jsonOptions: any, basePath: string, - defaultOptions: CompilerOptions | TypeAcquisition | WatchOptions | undefined, diagnostics: DidYouMeanOptionsDiagnostics, errors: Push) { + defaultOptions: CompilerOptions | TypeAcquisition | WatchOptions | undefined, diagnostics: DidYouMeanOptionsDiagnostics, errors: Diagnostic[]) { if (!jsonOptions) { return; @@ -3528,7 +3527,7 @@ function convertOptionsFromJson(optionsNameMap: Map, } /** @internal */ -export function convertJsonOption(opt: CommandLineOption, value: any, basePath: string, errors: Push): CompilerOptionsValue { +export function convertJsonOption(opt: CommandLineOption, value: any, basePath: string, errors: Diagnostic[]): CompilerOptionsValue { if (isCompilerOptionsValue(opt, value)) { const optType = opt.type; if ((optType === "list") && isArray(value)) { @@ -3576,7 +3575,7 @@ function normalizeNonListOptionValue(option: CommandLineOption, basePath: string return value; } -function validateJsonOptionValue(opt: CommandLineOption, value: T, errors: Push): T | undefined { +function validateJsonOptionValue(opt: CommandLineOption, value: T, errors: Diagnostic[]): T | undefined { if (isNullOrUndefined(value)) return undefined; const d = opt.extraValidation?.(value); if (!d) return value; @@ -3584,7 +3583,7 @@ function validateJsonOptionValue(opt: CommandLin return undefined; } -function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value: string, errors: Push) { +function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { if (isNullOrUndefined(value)) return undefined; const key = value.toLowerCase(); const val = opt.type.get(key); @@ -3596,7 +3595,7 @@ function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value } } -function convertJsonOptionOfListType(option: CommandLineOptionOfListType, values: readonly any[], basePath: string, errors: Push): any[] { +function convertJsonOptionOfListType(option: CommandLineOptionOfListType, values: readonly any[], basePath: string, errors: Diagnostic[]): any[] { return filter(map(values, v => convertJsonOption(option.element, v, basePath, errors)), v => option.listPreserveFalsyValues ? true : !!v); } @@ -3793,7 +3792,7 @@ function matchesExcludeWorker( return !hasExtension(pathToCheck) && excludeRegex.test(ensureTrailingDirectorySeparator(pathToCheck)); } -function validateSpecs(specs: readonly string[], errors: Push, disallowTrailingRecursion: boolean, jsonSourceFile: TsConfigSourceFile | undefined, specKey: string): readonly string[] { +function validateSpecs(specs: readonly string[], errors: Diagnostic[], disallowTrailingRecursion: boolean, jsonSourceFile: TsConfigSourceFile | undefined, specKey: string): readonly string[] { return specs.filter(spec => { if (!isString(spec)) return false; const diag = specToDiagnostic(spec, disallowTrailingRecursion); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index e24f79ef6281a..17bb70c596de9 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -7,7 +7,6 @@ import { EqualityComparer, isWhiteSpaceLike, MapLike, - Push, Queue, SortedArray, SortedReadonlyArray, @@ -1001,14 +1000,13 @@ export function append(to: T[] | undefined, value: T): T[]; /** @internal */ export function append(to: T[] | undefined, value: T | undefined): T[] | undefined; /** @internal */ -export function append(to: Push, value: T | undefined): void; +export function append(to: T[], value: T | undefined): void; /** @internal */ -export function append(to: Push | T[] | undefined, value: T | undefined): T[] | undefined { - // If to is Push, return value is void, so safe to cast to T[]. +export function append(to: T[] | undefined, value: T | undefined): T[] | undefined { if (value === undefined) return to as T[]; if (to === undefined) return [value]; to.push(value); - return to as T[]; + return to; } /** @@ -1887,12 +1885,6 @@ export function cast(value: TIn | undefined, test: */ export function noop(_?: unknown): void { } -/** @internal */ -export const noopPush: Push = { - push: noop, - length: 0 -}; - /** * Do nothing and return false * diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index 7bb20b5008a45..6542d1086e9a1 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -44,16 +44,6 @@ export interface Collection extends ReadonlyCollection { clear(): void; } -/** - * Array that is only intended to be pushed to, never read. - * - * @internal - */ -export interface Push { - push(...values: T[]): void; - readonly length: number; -} - /** @internal */ export type EqualityComparer = (a: T, b: T) => boolean; diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index f767514146920..3886ca8d4318d 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -372,7 +372,6 @@ import { pseudoBigIntToString, PunctuationSyntaxKind, PunctuationToken, - Push, QualifiedName, QuestionDotToken, QuestionToken, @@ -6439,7 +6438,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode return createGlobalMethodCall("Reflect", "set", receiver ? [target, propertyKey, value, receiver] : [target, propertyKey, value]); } - function tryAddPropertyAssignment(properties: Push, propertyName: string, expression: Expression | undefined) { + function tryAddPropertyAssignment(properties: PropertyAssignment[], propertyName: string, expression: Expression | undefined) { if (expression) { properties.push(createPropertyAssignment(propertyName, expression)); return true; @@ -6760,7 +6759,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode * @param ensureUseStrict boolean determining whether the function need to add prologue-directives * @param visitor Optional callback used to visit any custom prologue directives. */ - function copyPrologue(source: readonly Statement[], target: Push, ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number { + function copyPrologue(source: readonly Statement[], target: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number { const offset = copyStandardPrologue(source, target, 0, ensureUseStrict); return copyCustomPrologue(source, target, offset, visitor); } @@ -6781,7 +6780,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode * @param ensureUseStrict boolean determining whether the function need to add prologue-directives * @returns Count of how many directive statements were copied. */ - function copyStandardPrologue(source: readonly Statement[], target: Push, statementOffset = 0, ensureUseStrict?: boolean): number { + function copyStandardPrologue(source: readonly Statement[], target: Statement[], statementOffset = 0, ensureUseStrict?: boolean): number { Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); let foundUseStrict = false; const numStatements = source.length; @@ -6811,9 +6810,9 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode * @param statementOffset The offset at which to begin the copy. * @param visitor Optional callback used to visit any custom prologue directives. */ - function copyCustomPrologue(source: readonly Statement[], target: Push, statementOffset: number, visitor?: (node: Node) => VisitResult, filter?: (node: Statement) => boolean): number; - function copyCustomPrologue(source: readonly Statement[], target: Push, statementOffset: number | undefined, visitor?: (node: Node) => VisitResult, filter?: (node: Statement) => boolean): number | undefined; - function copyCustomPrologue(source: readonly Statement[], target: Push, statementOffset: number | undefined, visitor?: (node: Node) => VisitResult, filter: (node: Statement) => boolean = returnTrue): number | undefined { + function copyCustomPrologue(source: readonly Statement[], target: Statement[], statementOffset: number, visitor?: (node: Node) => VisitResult, filter?: (node: Statement) => boolean): number; + function copyCustomPrologue(source: readonly Statement[], target: Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult, filter?: (node: Statement) => boolean): number | undefined; + function copyCustomPrologue(source: readonly Statement[], target: Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult, filter: (node: Statement) => boolean = returnTrue): number | undefined { const numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { const statement = source[statementOffset]; diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index e24f647c99c2f..bf81a917d68f1 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -72,7 +72,6 @@ import { moduleResolutionOptionDeclarations, moduleResolutionSupportsPackageJsonExportsAndImports, noop, - noopPush, normalizePath, normalizeSlashes, PackageId, @@ -82,7 +81,6 @@ import { Pattern, patternText, perfLogger, - Push, readJson, removeExtension, removeFileExtension, @@ -285,8 +283,8 @@ export interface ModuleResolutionState { host: ModuleResolutionHost; compilerOptions: CompilerOptions; traceEnabled: boolean; - failedLookupLocations: Push; - affectingLocations: Push; + failedLookupLocations: string[] | undefined; + affectingLocations: string[] | undefined; resultFromCache?: ResolvedModuleWithFailedLookupLocations; packageJsonInfoCache: PackageJsonInfoCache | undefined; features: NodeResolutionFeatures; @@ -2045,7 +2043,7 @@ function tryFileLookup(fileName: string, onlyRecordFailures: boolean, state: Mod } } } - state.failedLookupLocations.push(fileName); + state.failedLookupLocations?.push(fileName); return undefined; } @@ -2171,8 +2169,8 @@ export function getTemporaryModuleResolutionState(packageJsonInfoCache: PackageJ host, compilerOptions: options, traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: noopPush, - affectingLocations: noopPush, + failedLookupLocations: undefined, + affectingLocations: undefined, packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: emptyArray, @@ -2227,7 +2225,7 @@ export function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: const { host, traceEnabled } = state; const packageJsonPath = combinePaths(packageDirectory, "package.json"); if (onlyRecordFailures) { - state.failedLookupLocations.push(packageJsonPath); + state.failedLookupLocations?.push(packageJsonPath); return undefined; } @@ -2235,14 +2233,14 @@ export function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: if (existing !== undefined) { if (typeof existing !== "boolean") { if (traceEnabled) trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath); - state.affectingLocations.push(packageJsonPath); + state.affectingLocations?.push(packageJsonPath); return existing.packageDirectory === packageDirectory ? existing : { packageDirectory, contents: existing.contents }; } else { if (existing && traceEnabled) trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath); - state.failedLookupLocations.push(packageJsonPath); + state.failedLookupLocations?.push(packageJsonPath); return undefined; } } @@ -2254,7 +2252,7 @@ export function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: } const result: PackageJsonInfo = { packageDirectory, contents: { packageJsonContent, versionPaths: undefined, resolvedEntrypoints: undefined } }; state.packageJsonInfoCache?.setPackageJsonInfo(packageJsonPath, result); - state.affectingLocations.push(packageJsonPath); + state.affectingLocations?.push(packageJsonPath); return result; } else { @@ -2263,7 +2261,7 @@ export function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: } state.packageJsonInfoCache?.setPackageJsonInfo(packageJsonPath, directoryExists); // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - state.failedLookupLocations.push(packageJsonPath); + state.failedLookupLocations?.push(packageJsonPath); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7bae07044f7a1..55f85bacf6133 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -14,7 +14,6 @@ import { PackageJsonInfoCache, Pattern, ProgramBuildInfo, - Push, SymlinkCache, ThisContainer, } from "./_namespaces/ts"; @@ -8893,7 +8892,7 @@ export interface NodeFactory { * * @internal */ - copyPrologue(source: readonly Statement[], target: Push, ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number; + copyPrologue(source: readonly Statement[], target: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number; /** * Copies only the standard (string-expression) prologue-directives into the target statement-array. * @param source origin statements array @@ -8903,7 +8902,7 @@ export interface NodeFactory { * * @internal */ - copyStandardPrologue(source: readonly Statement[], target: Push, statementOffset: number | undefined, ensureUseStrict?: boolean): number; + copyStandardPrologue(source: readonly Statement[], target: Statement[], statementOffset: number | undefined, ensureUseStrict?: boolean): number; /** * Copies only the custom prologue-directives into target statement-array. * @param source origin statements array @@ -8913,8 +8912,8 @@ export interface NodeFactory { * * @internal */ - copyCustomPrologue(source: readonly Statement[], target: Push, statementOffset: number, visitor?: (node: Node) => VisitResult, filter?: (node: Statement) => boolean): number; - /** @internal */ copyCustomPrologue(source: readonly Statement[], target: Push, statementOffset: number | undefined, visitor?: (node: Node) => VisitResult, filter?: (node: Statement) => boolean): number | undefined; + copyCustomPrologue(source: readonly Statement[], target: Statement[], statementOffset: number, visitor?: (node: Node) => VisitResult, filter?: (node: Statement) => boolean): number; + /** @internal */ copyCustomPrologue(source: readonly Statement[], target: Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult, filter?: (node: Statement) => boolean): number | undefined; /** @internal */ ensureUseStrict(statements: NodeArray): NodeArray; /** @internal */ liftToBlock(nodes: readonly Node[]): Statement; /** diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 8a11f5f0f97f4..25114f2b96feb 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -243,7 +243,6 @@ import { PropertyAccessExpression, PropertyDeclaration, PropertyName, - Push, QualifiedName, ScriptTarget, SetAccessorDeclaration, @@ -641,7 +640,7 @@ export function validateLocaleAndSetLanguage( // Set the UI locale for string collation setUILocale(locale); - function trySetLanguageAndTerritory(language: string, territory: string | undefined, errors?: Push): boolean { + function trySetLanguageAndTerritory(language: string, territory: string | undefined, errors?: Diagnostic[]): boolean { const compilerFilePath = normalizePath(sys.getExecutingFilePath()); const containingDirectoryPath = getDirectoryPath(compilerFilePath); diff --git a/src/services/classifier.ts b/src/services/classifier.ts index 74450102e3476..2d7c9b558875f 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -61,7 +61,6 @@ import { nodeIsMissing, ParameterDeclaration, parseIsolatedJSDocComment, - Push, Scanner, ScriptTarget, SemanticMeaning, @@ -312,7 +311,7 @@ function getNewEndOfLineState(scanner: Scanner, token: SyntaxKind, lastOnTemplat } } -function pushEncodedClassification(start: number, end: number, offset: number, classification: ClassificationType, result: Push): void { +function pushEncodedClassification(start: number, end: number, offset: number, classification: ClassificationType, result: number[]): void { if (classification === ClassificationType.whiteSpace) { // Don't bother with whitespace classifications. They're not needed. return; diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index de923d7242433..4ea877ea1d95e 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -20,7 +20,6 @@ import { flatMap, isString, map, - Push, TextChange, textChanges, } from "./_namespaces/ts"; @@ -106,7 +105,7 @@ export function createFileTextChanges(fileName: string, textChanges: TextChange[ export function codeFixAll( context: CodeFixAllContext, errorCodes: number[], - use: (changes: textChanges.ChangeTracker, error: DiagnosticWithLocation, commands: Push) => void, + use: (changes: textChanges.ChangeTracker, error: DiagnosticWithLocation, commands: CodeActionCommand[]) => void, ): CombinedCodeActions { const commands: CodeActionCommand[] = []; const changes = textChanges.ChangeTracker.with(context, t => eachDiagnostic(context, errorCodes, diag => use(t, diag, commands))); diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index ab021d575aaf7..1d4848c641851 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -72,7 +72,6 @@ import { ObjectLiteralExpression, ObjectTypeDeclaration, Program, - Push, ReturnStatement, SourceFile, SwitchStatement, @@ -340,7 +339,7 @@ export namespace DocumentHighlights { } } - function pushKeywordIf(keywordList: Push, token: Node | undefined, ...expected: SyntaxKind[]): boolean { + function pushKeywordIf(keywordList: Node[], token: Node | undefined, ...expected: SyntaxKind[]): boolean { if (token && contains(expected, token.kind)) { keywordList.push(token); return true; diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index e8fe0f2a71f03..e189ce87caec1 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -201,7 +201,6 @@ import { PropertyAssignment, PropertyDeclaration, punctuationPart, - Push, rangeIsOnSingleLine, ReferencedSymbol, ReferencedSymbolDefinitionInfo, @@ -1380,7 +1379,7 @@ export namespace Core { readonly cancellationToken: CancellationToken, readonly searchMeaning: SemanticMeaning, readonly options: Options, - private readonly result: Push) { + private readonly result: SymbolAndEntries[]) { } includesSourceFile(sourceFile: SourceFile): boolean { diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index aa57b808e9f99..873bba76e9278 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -22,7 +22,6 @@ import { Node, PatternMatcher, PatternMatchKind, - Push, ScriptElementKind, SourceFile, SyntaxKind, @@ -60,7 +59,7 @@ export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); } -function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: readonly Declaration[], checker: TypeChecker, fileName: string, rawItems: Push): void { +function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: readonly Declaration[], checker: TypeChecker, fileName: string, rawItems: RawNavigateToItem[]): void { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. const match = patternMatcher.getMatchForLastSegmentOfPattern(name); @@ -97,7 +96,7 @@ function shouldKeepItem(declaration: Declaration, checker: TypeChecker): boolean } } -function tryAddSingleDeclarationName(declaration: Declaration, containers: Push): boolean { +function tryAddSingleDeclarationName(declaration: Declaration, containers: string[]): boolean { const name = getNameOfDeclaration(declaration); return !!name && (pushLiteral(name, containers) || name.kind === SyntaxKind.ComputedPropertyName && tryAddComputedPropertyName(name.expression, containers)); } @@ -105,12 +104,12 @@ function tryAddSingleDeclarationName(declaration: Declaration, containers: Push< // Only added the names of computed properties if they're simple dotted expressions, like: // // [X.Y.Z]() { } -function tryAddComputedPropertyName(expression: Expression, containers: Push): boolean { +function tryAddComputedPropertyName(expression: Expression, containers: string[]): boolean { return pushLiteral(expression, containers) || isPropertyAccessExpression(expression) && (containers.push(expression.name.text), true) && tryAddComputedPropertyName(expression.expression, containers); } -function pushLiteral(node: Node, containers: Push): boolean { +function pushLiteral(node: Node, containers: string[]): boolean { return isPropertyNameLiteral(node) && (containers.push(getTextOfIdentifierOrLiteral(node)), true); } diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 7bb51576b5214..4d74425ed15c1 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -46,7 +46,6 @@ import { OutliningSpanKind, ParenthesizedExpression, positionsAreOnSameLine, - Push, SignatureDeclaration, SourceFile, startsWith, @@ -66,7 +65,7 @@ export function collectElements(sourceFile: SourceFile, cancellationToken: Cance return res.sort((span1, span2) => span1.textSpan.start - span2.textSpan.start); } -function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: CancellationToken, out: Push): void { +function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: CancellationToken, out: OutliningSpan[]): void { let depthRemaining = 40; let current = 0; // Includes the EOF Token so that comments which aren't attached to statements are included @@ -135,7 +134,7 @@ function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: Cancel } } -function addRegionOutliningSpans(sourceFile: SourceFile, out: Push): void { +function addRegionOutliningSpans(sourceFile: SourceFile, out: OutliningSpan[]): void { const regions: OutliningSpan[] = []; const lineStarts = sourceFile.getLineStarts(); for (const currentLineStart of lineStarts) { @@ -173,7 +172,7 @@ function isRegionDelimiter(lineText: string) { return regionDelimiterRegExp.exec(lineText); } -function addOutliningForLeadingCommentsForPos(pos: number, sourceFile: SourceFile, cancellationToken: CancellationToken, out: Push): void { +function addOutliningForLeadingCommentsForPos(pos: number, sourceFile: SourceFile, cancellationToken: CancellationToken, out: OutliningSpan[]): void { const comments = getLeadingCommentRanges(sourceFile.text, pos); if (!comments) return; @@ -220,7 +219,7 @@ function addOutliningForLeadingCommentsForPos(pos: number, sourceFile: SourceFil } } -function addOutliningForLeadingCommentsForNode(n: Node, sourceFile: SourceFile, cancellationToken: CancellationToken, out: Push): void { +function addOutliningForLeadingCommentsForNode(n: Node, sourceFile: SourceFile, cancellationToken: CancellationToken, out: OutliningSpan[]): void { if (isJsxText(n)) return; addOutliningForLeadingCommentsForPos(n.pos, sourceFile, cancellationToken, out); } diff --git a/src/services/services.ts b/src/services/services.ts index f5bba46bdbca7..bc40a4c6d603c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -238,7 +238,6 @@ import { PrivateIdentifier, Program, PropertyName, - Push, QuickInfo, refactor, RefactorContext, @@ -489,7 +488,7 @@ function createChildren(node: Node, sourceFile: SourceFileLike | undefined): Nod return children; } -function addSyntheticNodes(nodes: Push, pos: number, end: number, parent: Node): void { +function addSyntheticNodes(nodes: Node[], pos: number, end: number, parent: Node): void { scanner.setTextPos(pos); while (pos < end) { const token = scanner.scan(); diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index 87cf371041f37..e68be5184df48 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -52,7 +52,6 @@ import { Program, programContainsEsModules, PropertyAccessExpression, - Push, ReturnStatement, skipAlias, some, @@ -166,7 +165,7 @@ function importNameForConvertToDefaultImport(node: AnyValidImportOrReExport): Id } } -function addConvertToAsyncFunctionDiagnostics(node: FunctionLikeDeclaration, checker: TypeChecker, diags: Push): void { +function addConvertToAsyncFunctionDiagnostics(node: FunctionLikeDeclaration, checker: TypeChecker, diags: DiagnosticWithLocation[]): void { // need to check function before checking map so that deeper levels of nested callbacks are checked if (isConvertibleFunction(node, checker) && !visitedNestedConvertibleFunctions.has(getKeyFromNode(node))) { diags.push(createDiagnosticForNode(