From bcc608657a71f227e2130212c9fac7b47e24b3cc Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 5 Jan 2023 13:35:54 -0800 Subject: [PATCH] Remove Push from public API --- src/compiler/commandLineParser.ts | 6 +++--- src/compiler/corePublic.ts | 8 ++++++-- src/compiler/utilitiesPublic.ts | 2 +- tests/baselines/reference/api/tsserverlibrary.d.ts | 8 ++------ tests/baselines/reference/api/typescript.d.ts | 8 ++------ 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index ceb980ebcd3b0..afbbb90dde9ed 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -2288,7 +2288,7 @@ function convertConfigFileToObject(sourceFile: JsonSourceFile, errors: Push): any { +export function convertToObject(sourceFile: JsonSourceFile, errors: Diagnostic[]): any { return convertToObjectWorker(sourceFile, sourceFile.statements[0]?.expression, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); } @@ -3177,7 +3177,7 @@ function parseConfig( basePath: string, configFileName: string | undefined, resolutionStack: string[], - errors: Push, + errors: Diagnostic[], extendedConfigCache?: Map ): ParsedTsconfig { basePath = normalizeSlashes(basePath); @@ -3432,7 +3432,7 @@ function getExtendedConfig( extendedConfigPath: string, host: ParseConfigHost, resolutionStack: string[], - errors: Push, + errors: Diagnostic[], extendedConfigCache: Map | undefined, result: ExtendsResult ): ParsedTsconfig | undefined { diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index acf0519d4e87b..10645e779d6bf 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -44,10 +44,14 @@ export interface Collection extends ReadonlyCollection { clear(): void; } -/** Array that is only intended to be pushed to, never read. */ +/** + * Array that is only intended to be pushed to, never read. + * + * @internal + */ export interface Push { push(...values: T[]): void; - /** @internal */ readonly length: number; + readonly length: number; } /** @internal */ diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 43a52da22f7dc..7bb784a3a57bd 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -602,7 +602,7 @@ export const supportedLocaleDirectories = ["cs", "de", "es", "fr", "it", "ja", " export function validateLocaleAndSetLanguage( locale: string, sys: { getExecutingFilePath(): string, resolvePath(path: string): string, fileExists(fileName: string): boolean, readFile(fileName: string): string | undefined }, - errors?: Push) { + errors?: Diagnostic[]) { const lowerCaseLocale = locale.toLowerCase(); const matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(lowerCaseLocale); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 9a9d1f7bebd7e..44e2e6143aba9 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3966,10 +3966,6 @@ declare namespace ts { interface SortedArray extends Array { " __sortedArrayBrand": any; } - /** Array that is only intended to be pushed to, never read. */ - interface Push { - push(...values: T[]): void; - } type Path = string & { __pathBrand: any; }; @@ -8558,7 +8554,7 @@ declare namespace ts { resolvePath(path: string): string; fileExists(fileName: string): boolean; readFile(fileName: string): string | undefined; - }, errors?: Push): void; + }, errors?: Diagnostic[]): void; function getOriginalNode(node: Node): Node; function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; function getOriginalNode(node: Node | undefined): Node | undefined; @@ -9138,7 +9134,7 @@ declare namespace ts { /** * Convert the json syntax tree into the json value */ - function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; + function convertToObject(sourceFile: JsonSourceFile, errors: Diagnostic[]): any; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 611633da9f02b..e29bb395fe5f4 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -31,10 +31,6 @@ declare namespace ts { interface SortedArray extends Array { " __sortedArrayBrand": any; } - /** Array that is only intended to be pushed to, never read. */ - interface Push { - push(...values: T[]): void; - } type Path = string & { __pathBrand: any; }; @@ -4623,7 +4619,7 @@ declare namespace ts { resolvePath(path: string): string; fileExists(fileName: string): boolean; readFile(fileName: string): string | undefined; - }, errors?: Push): void; + }, errors?: Diagnostic[]): void; function getOriginalNode(node: Node): Node; function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; function getOriginalNode(node: Node | undefined): Node | undefined; @@ -5203,7 +5199,7 @@ declare namespace ts { /** * Convert the json syntax tree into the json value */ - function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; + function convertToObject(sourceFile: JsonSourceFile, errors: Diagnostic[]): any; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse