mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
array-type: [ default: array, generic: array ]
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/adjacent-overload-signatures": "error",
|
||||
"@typescript-eslint/array-type": ["error", { "default": "array", "readonly": "generic" }],
|
||||
"@typescript-eslint/array-type": "error",
|
||||
"camelcase": "off",
|
||||
"@typescript-eslint/camelcase": ["error", { "properties": "never", "allow": ["^[A-Za-z][a-zA-Za-z]+_[A-Za-z]+$"] }],
|
||||
"@typescript-eslint/class-name-casing": "error",
|
||||
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ declare class FailedTestsReporter extends Mocha.reporters.Base {
|
||||
reporterOptions: FailedTestsReporter.ReporterOptions;
|
||||
reporter?: Mocha.reporters.Base;
|
||||
constructor(runner: Mocha.Runner, options?: { reporterOptions?: FailedTestsReporter.ReporterOptions });
|
||||
static writeFailures(file: string, passes: ReadonlyArray<Mocha.Test>, failures: ReadonlyArray<Mocha.Test>, keepFailed: boolean, done: (err?: NodeJS.ErrnoException) => void): void;
|
||||
static writeFailures(file: string, passes: readonly Mocha.Test[], failures: readonly Mocha.Test[], keepFailed: boolean, done: (err?: NodeJS.ErrnoException) => void): void;
|
||||
done(failures: number, fn?: (failures: number) => void): void;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -19,7 +19,7 @@ declare module "vinyl" {
|
||||
cwd: string;
|
||||
base: string;
|
||||
path: string;
|
||||
readonly history: ReadonlyArray<string>;
|
||||
readonly history: readonly string[];
|
||||
contents: T;
|
||||
relative: string;
|
||||
dirname: string;
|
||||
@@ -45,7 +45,7 @@ declare module "vinyl" {
|
||||
cwd?: string;
|
||||
base?: string;
|
||||
path?: string;
|
||||
history?: ReadonlyArray<string>;
|
||||
history?: readonly string[];
|
||||
stat?: import("fs").Stats;
|
||||
contents?: T;
|
||||
sourceMap?: import("./sourcemaps").RawSourceMap | string;
|
||||
|
||||
+42
-42
@@ -22,7 +22,7 @@ namespace ts {
|
||||
/**
|
||||
* Cache of semantic diagnostics for files with their Path being the key
|
||||
*/
|
||||
semanticDiagnosticsPerFile?: ReadonlyMap<ReadonlyArray<ReusableDiagnostic> | ReadonlyArray<Diagnostic>> | undefined;
|
||||
semanticDiagnosticsPerFile?: ReadonlyMap<readonly ReusableDiagnostic[] | readonly Diagnostic[]> | undefined;
|
||||
/**
|
||||
* The map has key by source file's path that has been changed
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ namespace ts {
|
||||
/**
|
||||
* Set of affected files being iterated
|
||||
*/
|
||||
affectedFiles?: ReadonlyArray<SourceFile> | undefined;
|
||||
affectedFiles?: readonly SourceFile[] | undefined;
|
||||
/**
|
||||
* Current changed file for iterating over affected files
|
||||
*/
|
||||
@@ -59,7 +59,7 @@ namespace ts {
|
||||
/**
|
||||
* Files pending to be emitted
|
||||
*/
|
||||
affectedFilesPendingEmit?: ReadonlyArray<Path> | undefined;
|
||||
affectedFilesPendingEmit?: readonly Path[] | undefined;
|
||||
/**
|
||||
* Current index to retrieve pending affected file
|
||||
*/
|
||||
@@ -78,7 +78,7 @@ namespace ts {
|
||||
/**
|
||||
* Cache of semantic diagnostics for files with their Path being the key
|
||||
*/
|
||||
semanticDiagnosticsPerFile: Map<ReadonlyArray<Diagnostic>> | undefined;
|
||||
semanticDiagnosticsPerFile: Map<readonly Diagnostic[]> | undefined;
|
||||
/**
|
||||
* The map has key by source file's path that has been changed
|
||||
*/
|
||||
@@ -86,7 +86,7 @@ namespace ts {
|
||||
/**
|
||||
* Set of affected files being iterated
|
||||
*/
|
||||
affectedFiles: ReadonlyArray<SourceFile> | undefined;
|
||||
affectedFiles: readonly SourceFile[] | undefined;
|
||||
/**
|
||||
* Current index to retrieve affected file from
|
||||
*/
|
||||
@@ -127,7 +127,7 @@ namespace ts {
|
||||
/**
|
||||
* Files pending to be emitted
|
||||
*/
|
||||
affectedFilesPendingEmit: ReadonlyArray<Path> | undefined;
|
||||
affectedFilesPendingEmit: readonly Path[] | undefined;
|
||||
/**
|
||||
* Current index to retrieve pending affected file
|
||||
*/
|
||||
@@ -162,7 +162,7 @@ namespace ts {
|
||||
// With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
|
||||
// With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors
|
||||
if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) {
|
||||
state.semanticDiagnosticsPerFile = createMap<ReadonlyArray<Diagnostic>>();
|
||||
state.semanticDiagnosticsPerFile = createMap<readonly Diagnostic[]>();
|
||||
}
|
||||
state.changedFilesSet = createMap<true>();
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace ts {
|
||||
// Unchanged file copy diagnostics
|
||||
const diagnostics = oldState!.semanticDiagnosticsPerFile!.get(sourceFilePath);
|
||||
if (diagnostics) {
|
||||
state.semanticDiagnosticsPerFile!.set(sourceFilePath, oldState!.hasReusableDiagnostic ? convertToDiagnostics(diagnostics as ReadonlyArray<ReusableDiagnostic>, newProgram, getCanonicalFileName) : diagnostics as ReadonlyArray<Diagnostic>);
|
||||
state.semanticDiagnosticsPerFile!.set(sourceFilePath, oldState!.hasReusableDiagnostic ? convertToDiagnostics(diagnostics as readonly ReusableDiagnostic[], newProgram, getCanonicalFileName) : diagnostics as readonly Diagnostic[]);
|
||||
if (!state.semanticDiagnosticsFromOldState) {
|
||||
state.semanticDiagnosticsFromOldState = createMap<true>();
|
||||
}
|
||||
@@ -241,7 +241,7 @@ namespace ts {
|
||||
return state;
|
||||
}
|
||||
|
||||
function convertToDiagnostics(diagnostics: ReadonlyArray<ReusableDiagnostic>, newProgram: Program, getCanonicalFileName: GetCanonicalFileName): ReadonlyArray<Diagnostic> {
|
||||
function convertToDiagnostics(diagnostics: readonly ReusableDiagnostic[], newProgram: Program, getCanonicalFileName: GetCanonicalFileName): readonly Diagnostic[] {
|
||||
if (!diagnostics.length) return emptyArray;
|
||||
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getOutputPathForBuildInfo(newProgram.getCompilerOptions())!, newProgram.getCurrentDirectory()));
|
||||
return diagnostics.map(diagnostic => {
|
||||
@@ -580,7 +580,7 @@ namespace ts {
|
||||
* Gets the semantic diagnostics either from cache if present, or otherwise from program and caches it
|
||||
* Note that it is assumed that the when asked about semantic diagnostics, the file has been taken out of affected files/changed file set
|
||||
*/
|
||||
function getSemanticDiagnosticsOfFile(state: BuilderProgramState, sourceFile: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic> {
|
||||
function getSemanticDiagnosticsOfFile(state: BuilderProgramState, sourceFile: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[] {
|
||||
const path = sourceFile.path;
|
||||
if (state.semanticDiagnosticsPerFile) {
|
||||
const cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
|
||||
@@ -598,7 +598,7 @@ namespace ts {
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
export type ProgramBuildInfoDiagnostic = string | [string, ReadonlyArray<ReusableDiagnostic>];
|
||||
export type ProgramBuildInfoDiagnostic = string | [string, readonly ReusableDiagnostic[]];
|
||||
export interface ProgramBuildInfo {
|
||||
fileInfos: MapLike<BuilderState.FileInfo>;
|
||||
options: CompilerOptions;
|
||||
@@ -652,8 +652,8 @@ namespace ts {
|
||||
[
|
||||
relativeToBuildInfo(key),
|
||||
state.hasReusableDiagnostic ?
|
||||
value as ReadonlyArray<ReusableDiagnostic> :
|
||||
convertToReusableDiagnostics(value as ReadonlyArray<Diagnostic>, relativeToBuildInfo)
|
||||
value as readonly ReusableDiagnostic[] :
|
||||
convertToReusableDiagnostics(value as readonly Diagnostic[], relativeToBuildInfo)
|
||||
] :
|
||||
relativeToBuildInfo(key)
|
||||
));
|
||||
@@ -693,7 +693,7 @@ namespace ts {
|
||||
function convertToReusableCompilerOptionValue(option: CommandLineOption | undefined, value: CompilerOptionsValue, relativeToBuildInfo: (path: string) => string) {
|
||||
if (option) {
|
||||
if (option.type === "list") {
|
||||
const values = value as ReadonlyArray<string | number>;
|
||||
const values = value as readonly (string | number)[];
|
||||
if (option.element.isFilePath && values.length) {
|
||||
return values.map(relativeToBuildInfo);
|
||||
}
|
||||
@@ -705,7 +705,7 @@ namespace ts {
|
||||
return value;
|
||||
}
|
||||
|
||||
function convertToReusableDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, relativeToBuildInfo: (path: string) => string): ReadonlyArray<ReusableDiagnostic> {
|
||||
function convertToReusableDiagnostics(diagnostics: readonly Diagnostic[], relativeToBuildInfo: (path: string) => string): readonly ReusableDiagnostic[] {
|
||||
Debug.assert(!!diagnostics.length);
|
||||
return diagnostics.map(diagnostic => {
|
||||
const result: ReusableDiagnostic = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
|
||||
@@ -738,10 +738,10 @@ namespace ts {
|
||||
newProgram: Program;
|
||||
host: BuilderProgramHost;
|
||||
oldProgram: BuilderProgram | undefined;
|
||||
configFileParsingDiagnostics: ReadonlyArray<Diagnostic>;
|
||||
configFileParsingDiagnostics: readonly Diagnostic[];
|
||||
}
|
||||
|
||||
export function getBuilderCreationParameters(newProgramOrRootNames: Program | ReadonlyArray<string> | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: BuilderProgram | CompilerHost, configFileParsingDiagnosticsOrOldProgram?: ReadonlyArray<Diagnostic> | BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>, projectReferences?: ReadonlyArray<ProjectReference>): BuilderCreationParameters {
|
||||
export function getBuilderCreationParameters(newProgramOrRootNames: Program | readonly string[] | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: BuilderProgram | CompilerHost, configFileParsingDiagnosticsOrOldProgram?: readonly Diagnostic[] | BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderCreationParameters {
|
||||
let host: BuilderProgramHost;
|
||||
let newProgram: Program;
|
||||
let oldProgram: BuilderProgram;
|
||||
@@ -768,7 +768,7 @@ namespace ts {
|
||||
newProgram = newProgramOrRootNames;
|
||||
host = hostOrOptions as BuilderProgramHost;
|
||||
oldProgram = oldProgramOrHost as BuilderProgram;
|
||||
configFileParsingDiagnostics = configFileParsingDiagnosticsOrOldProgram as ReadonlyArray<Diagnostic>;
|
||||
configFileParsingDiagnostics = configFileParsingDiagnosticsOrOldProgram as readonly Diagnostic[];
|
||||
}
|
||||
return { host, newProgram, oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || emptyArray };
|
||||
}
|
||||
@@ -925,7 +925,7 @@ namespace ts {
|
||||
* Return the semantic diagnostics for the next affected file or undefined if iteration is complete
|
||||
* If provided ignoreSourceFile would be called before getting the diagnostics and would ignore the sourceFile if the returned value was true
|
||||
*/
|
||||
function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult<ReadonlyArray<Diagnostic>> {
|
||||
function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult<readonly Diagnostic[]> {
|
||||
while (true) {
|
||||
const affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
||||
if (!affected) {
|
||||
@@ -969,7 +969,7 @@ namespace ts {
|
||||
* In case of SemanticDiagnosticsBuilderProgram if the source file is not provided,
|
||||
* it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics
|
||||
*/
|
||||
function getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic> {
|
||||
function getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[] {
|
||||
assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
|
||||
const compilerOptions = Debug.assertDefined(state.program).getCompilerOptions();
|
||||
if (compilerOptions.outFile || compilerOptions.out) {
|
||||
@@ -996,7 +996,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFilesPendingEmit: ReadonlyArray<Path>) {
|
||||
function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFilesPendingEmit: readonly Path[]) {
|
||||
state.affectedFilesPendingEmit = concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit);
|
||||
// affectedFilesPendingEmitIndex === undefined
|
||||
// - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files
|
||||
@@ -1007,7 +1007,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getMapOfReferencedSet(mapLike: MapLike<ReadonlyArray<string>> | undefined, toPath: (path: string) => Path): ReadonlyMap<BuilderState.ReferencedSet> | undefined {
|
||||
function getMapOfReferencedSet(mapLike: MapLike<readonly string[]> | undefined, toPath: (path: string) => Path): ReadonlyMap<BuilderState.ReferencedSet> | undefined {
|
||||
if (!mapLike) return undefined;
|
||||
const map = createMap<BuilderState.ReferencedSet>();
|
||||
// Copies keys/values from template. Note that for..in will not throw if
|
||||
@@ -1093,7 +1093,7 @@ namespace ts {
|
||||
function convertFromReusableCompilerOptionValue(option: CommandLineOption | undefined, value: CompilerOptionsValue, toAbsolutePath: (path: string) => string) {
|
||||
if (option) {
|
||||
if (option.type === "list") {
|
||||
const values = value as ReadonlyArray<string | number>;
|
||||
const values = value as readonly (string | number)[];
|
||||
if (option.element.isFilePath && values.length) {
|
||||
return values.map(toAbsolutePath);
|
||||
}
|
||||
@@ -1105,7 +1105,7 @@ namespace ts {
|
||||
return value;
|
||||
}
|
||||
|
||||
export function createRedirectedBuilderProgram(state: { program: Program | undefined; compilerOptions: CompilerOptions; }, configFileParsingDiagnostics: ReadonlyArray<Diagnostic>): BuilderProgram {
|
||||
export function createRedirectedBuilderProgram(state: { program: Program | undefined; compilerOptions: CompilerOptions; }, configFileParsingDiagnostics: readonly Diagnostic[]): BuilderProgram {
|
||||
return {
|
||||
getState: notImplemented,
|
||||
backupState: noop,
|
||||
@@ -1188,31 +1188,31 @@ namespace ts {
|
||||
/**
|
||||
* Get a list of files in the program
|
||||
*/
|
||||
getSourceFiles(): ReadonlyArray<SourceFile>;
|
||||
getSourceFiles(): readonly SourceFile[];
|
||||
/**
|
||||
* Get the diagnostics for compiler options
|
||||
*/
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
/**
|
||||
* Get the diagnostics that dont belong to any file
|
||||
*/
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
/**
|
||||
* Get the diagnostics from config file parsing
|
||||
*/
|
||||
getConfigFileParsingDiagnostics(): ReadonlyArray<Diagnostic>;
|
||||
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
|
||||
/**
|
||||
* Get the syntax diagnostics, for all source files if source file is not supplied
|
||||
*/
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
/**
|
||||
* Get the declaration diagnostics, for all source files if source file is not supplied
|
||||
*/
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<DiagnosticWithLocation>;
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
|
||||
/**
|
||||
* Get all the dependencies of the file
|
||||
*/
|
||||
getAllDependencies(sourceFile: SourceFile): ReadonlyArray<string>;
|
||||
getAllDependencies(sourceFile: SourceFile): readonly string[];
|
||||
|
||||
/**
|
||||
* Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program
|
||||
@@ -1222,7 +1222,7 @@ namespace ts {
|
||||
* In case of SemanticDiagnosticsBuilderProgram if the source file is not provided,
|
||||
* it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics
|
||||
*/
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
/**
|
||||
* Emits the JavaScript and declaration files.
|
||||
* When targetSource file is specified, emits the files corresponding to that source file,
|
||||
@@ -1249,7 +1249,7 @@ namespace ts {
|
||||
* Gets the semantic diagnostics from the program for the next affected file and caches it
|
||||
* Returns undefined if the iteration is complete
|
||||
*/
|
||||
getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult<ReadonlyArray<Diagnostic>>;
|
||||
getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult<readonly Diagnostic[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1268,9 +1268,9 @@ namespace ts {
|
||||
/**
|
||||
* Create the builder to manage semantic diagnostics and cache them
|
||||
*/
|
||||
export function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>): SemanticDiagnosticsBuilderProgram;
|
||||
export function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray<string> | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>, projectReferences?: ReadonlyArray<ProjectReference>): SemanticDiagnosticsBuilderProgram;
|
||||
export function createSemanticDiagnosticsBuilderProgram(newProgramOrRootNames: Program | ReadonlyArray<string> | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: CompilerHost | SemanticDiagnosticsBuilderProgram, configFileParsingDiagnosticsOrOldProgram?: ReadonlyArray<Diagnostic> | SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>, projectReferences?: ReadonlyArray<ProjectReference>) {
|
||||
export function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram;
|
||||
export function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram;
|
||||
export function createSemanticDiagnosticsBuilderProgram(newProgramOrRootNames: Program | readonly string[] | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: CompilerHost | SemanticDiagnosticsBuilderProgram, configFileParsingDiagnosticsOrOldProgram?: readonly Diagnostic[] | SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]) {
|
||||
return createBuilderProgram(BuilderProgramKind.SemanticDiagnosticsBuilderProgram, getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
|
||||
}
|
||||
|
||||
@@ -1278,18 +1278,18 @@ namespace ts {
|
||||
* Create the builder that can handle the changes in program and iterate through changed files
|
||||
* to emit the those files and manage semantic diagnostics cache as well
|
||||
*/
|
||||
export function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>): EmitAndSemanticDiagnosticsBuilderProgram;
|
||||
export function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray<string> | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>, projectReferences?: ReadonlyArray<ProjectReference>): EmitAndSemanticDiagnosticsBuilderProgram;
|
||||
export function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames: Program | ReadonlyArray<string> | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: CompilerHost | EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnosticsOrOldProgram?: ReadonlyArray<Diagnostic> | EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>, projectReferences?: ReadonlyArray<ProjectReference>) {
|
||||
export function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram;
|
||||
export function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram;
|
||||
export function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames: Program | readonly string[] | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: CompilerHost | EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnosticsOrOldProgram?: readonly Diagnostic[] | EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]) {
|
||||
return createBuilderProgram(BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a builder thats just abstraction over program and can be used with watch
|
||||
*/
|
||||
export function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>): BuilderProgram;
|
||||
export function createAbstractBuilder(rootNames: ReadonlyArray<string> | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>, projectReferences?: ReadonlyArray<ProjectReference>): BuilderProgram;
|
||||
export function createAbstractBuilder(newProgramOrRootNames: Program | ReadonlyArray<string> | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: CompilerHost | BuilderProgram, configFileParsingDiagnosticsOrOldProgram?: ReadonlyArray<Diagnostic> | BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>, projectReferences?: ReadonlyArray<ProjectReference>): BuilderProgram {
|
||||
export function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram;
|
||||
export function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram;
|
||||
export function createAbstractBuilder(newProgramOrRootNames: Program | readonly string[] | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: CompilerHost | BuilderProgram, configFileParsingDiagnosticsOrOldProgram?: readonly Diagnostic[] | BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram {
|
||||
const { newProgram, configFileParsingDiagnostics: newConfigFileParsingDiagnostics } = getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences);
|
||||
return createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics);
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ namespace ts {
|
||||
/**
|
||||
* Cache of all files excluding default library file for the current program
|
||||
*/
|
||||
allFilesExcludingDefaultLibraryFile?: ReadonlyArray<SourceFile>;
|
||||
allFilesExcludingDefaultLibraryFile?: readonly SourceFile[];
|
||||
/**
|
||||
* Cache of all the file names
|
||||
*/
|
||||
allFileNames?: ReadonlyArray<string>;
|
||||
allFileNames?: readonly string[];
|
||||
}
|
||||
|
||||
export function cloneMapOrUndefined<T>(map: ReadonlyMap<T> | undefined) {
|
||||
@@ -286,7 +286,7 @@ namespace ts.BuilderState {
|
||||
/**
|
||||
* Gets the files affected by the path from the program
|
||||
*/
|
||||
export function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, cacheToUpdateSignature?: Map<string>, exportedModulesMapCache?: ComputingExportedModulesMap): ReadonlyArray<SourceFile> {
|
||||
export function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, cacheToUpdateSignature?: Map<string>, exportedModulesMapCache?: ComputingExportedModulesMap): readonly SourceFile[] {
|
||||
// Since the operation could be cancelled, the signatures are always stored in the cache
|
||||
// They will be committed once it is safe to use them
|
||||
// eg when calling this api from tsserver, if there is no cancellation of the operation
|
||||
@@ -407,7 +407,7 @@ namespace ts.BuilderState {
|
||||
/**
|
||||
* Get all the dependencies of the sourceFile
|
||||
*/
|
||||
export function getAllDependencies(state: BuilderState, programOfThisState: Program, sourceFile: SourceFile): ReadonlyArray<string> {
|
||||
export function getAllDependencies(state: BuilderState, programOfThisState: Program, sourceFile: SourceFile): readonly string[] {
|
||||
const compilerOptions = programOfThisState.getCompilerOptions();
|
||||
// With --out or --outFile all outputs go into single file, all files depend on each other
|
||||
if (compilerOptions.outFile || compilerOptions.out) {
|
||||
@@ -445,7 +445,7 @@ namespace ts.BuilderState {
|
||||
/**
|
||||
* Gets the names of all files from the program
|
||||
*/
|
||||
function getAllFileNames(state: BuilderState, programOfThisState: Program): ReadonlyArray<string> {
|
||||
function getAllFileNames(state: BuilderState, programOfThisState: Program): readonly string[] {
|
||||
if (!state.allFileNames) {
|
||||
const sourceFiles = programOfThisState.getSourceFiles();
|
||||
state.allFileNames = sourceFiles === emptyArray ? emptyArray : sourceFiles.map(file => file.fileName);
|
||||
@@ -496,7 +496,7 @@ namespace ts.BuilderState {
|
||||
/**
|
||||
* Gets all files of the program excluding the default library file
|
||||
*/
|
||||
function getAllFilesExcludingDefaultLibraryFile(state: BuilderState, programOfThisState: Program, firstSourceFile: SourceFile): ReadonlyArray<SourceFile> {
|
||||
function getAllFilesExcludingDefaultLibraryFile(state: BuilderState, programOfThisState: Program, firstSourceFile: SourceFile): readonly SourceFile[] {
|
||||
// Use cached result
|
||||
if (state.allFilesExcludingDefaultLibraryFile) {
|
||||
return state.allFilesExcludingDefaultLibraryFile;
|
||||
|
||||
+109
-109
@@ -1106,7 +1106,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function addDuplicateDeclarationError(errorNode: Node, message: DiagnosticMessage, symbolName: string, relatedNodes: ReadonlyArray<Node> | undefined) {
|
||||
function addDuplicateDeclarationError(errorNode: Node, message: DiagnosticMessage, symbolName: string, relatedNodes: readonly Node[] | undefined) {
|
||||
const err = lookupOrIssueError(errorNode, message, symbolName);
|
||||
for (const relatedNode of relatedNodes || emptyArray) {
|
||||
err.relatedInformation = err.relatedInformation || [];
|
||||
@@ -3034,7 +3034,7 @@ namespace ts {
|
||||
return type;
|
||||
}
|
||||
|
||||
function createBooleanType(trueFalseTypes: ReadonlyArray<Type>): IntrinsicType & UnionType {
|
||||
function createBooleanType(trueFalseTypes: readonly Type[]): IntrinsicType & UnionType {
|
||||
const type = <IntrinsicType & UnionType>getUnionType(trueFalseTypes);
|
||||
type.flags |= TypeFlags.Boolean;
|
||||
type.intrinsicName = "boolean";
|
||||
@@ -3085,7 +3085,7 @@ namespace ts {
|
||||
return result || emptyArray;
|
||||
}
|
||||
|
||||
function setStructuredTypeMembers(type: StructuredType, members: SymbolTable, callSignatures: ReadonlyArray<Signature>, constructSignatures: ReadonlyArray<Signature>, stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): ResolvedType {
|
||||
function setStructuredTypeMembers(type: StructuredType, members: SymbolTable, callSignatures: readonly Signature[], constructSignatures: readonly Signature[], stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): ResolvedType {
|
||||
(<ResolvedType>type).members = members;
|
||||
(<ResolvedType>type).properties = members === emptySymbols ? emptyArray : getNamedMembers(members);
|
||||
(<ResolvedType>type).callSignatures = callSignatures;
|
||||
@@ -3095,7 +3095,7 @@ namespace ts {
|
||||
return <ResolvedType>type;
|
||||
}
|
||||
|
||||
function createAnonymousType(symbol: Symbol | undefined, members: SymbolTable, callSignatures: ReadonlyArray<Signature>, constructSignatures: ReadonlyArray<Signature>, stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): ResolvedType {
|
||||
function createAnonymousType(symbol: Symbol | undefined, members: SymbolTable, callSignatures: readonly Signature[], constructSignatures: readonly Signature[], stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): ResolvedType {
|
||||
return setStructuredTypeMembers(createObjectType(ObjectFlags.Anonymous, symbol),
|
||||
members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
|
||||
}
|
||||
@@ -3905,7 +3905,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function typeReferenceToTypeNode(type: TypeReference) {
|
||||
const typeArguments: ReadonlyArray<Type> = type.typeArguments || emptyArray;
|
||||
const typeArguments: readonly Type[] = type.typeArguments || emptyArray;
|
||||
if (type.target === globalArrayType || type.target === globalReadonlyArrayType) {
|
||||
if (context.flags & NodeBuilderFlags.WriteArrayAsGenericType) {
|
||||
const typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context);
|
||||
@@ -3970,7 +3970,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
let typeArgumentNodes: ReadonlyArray<TypeNode> | undefined;
|
||||
let typeArgumentNodes: readonly TypeNode[] | undefined;
|
||||
if (typeArguments.length > 0) {
|
||||
const typeParameterCount = (type.target.typeParameters || emptyArray).length;
|
||||
typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
|
||||
@@ -4146,7 +4146,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function mapToTypeNodes(types: ReadonlyArray<Type> | undefined, context: NodeBuilderContext, isBareList?: boolean): TypeNode[] | undefined {
|
||||
function mapToTypeNodes(types: readonly Type[] | undefined, context: NodeBuilderContext, isBareList?: boolean): TypeNode[] | undefined {
|
||||
if (some(types)) {
|
||||
if (checkTruncationLength(context)) {
|
||||
if (!isBareList) {
|
||||
@@ -4417,7 +4417,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
(context.typeParameterSymbolList || (context.typeParameterSymbolList = createMap())).set(symbolId, true);
|
||||
let typeParameterNodes: ReadonlyArray<TypeNode> | ReadonlyArray<TypeParameterDeclaration> | undefined;
|
||||
let typeParameterNodes: readonly TypeNode[] | readonly TypeParameterDeclaration[] | undefined;
|
||||
if (context.flags & NodeBuilderFlags.WriteTypeParametersInQualifiedName && index < (chain.length - 1)) {
|
||||
const parentSymbol = symbol;
|
||||
const nextSymbol = chain[index + 1];
|
||||
@@ -4496,7 +4496,7 @@ namespace ts {
|
||||
return specifier;
|
||||
}
|
||||
|
||||
function symbolToTypeNode(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, overrideTypeArguments?: ReadonlyArray<TypeNode>): TypeNode {
|
||||
function symbolToTypeNode(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, overrideTypeArguments?: readonly TypeNode[]): TypeNode {
|
||||
const chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope)); // If we're using aliases outside the current scope, dont bother with the module
|
||||
|
||||
const isTypeOf = meaning === SymbolFlags.Value;
|
||||
@@ -4521,12 +4521,12 @@ namespace ts {
|
||||
const lastId = isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
|
||||
lastId.typeArguments = undefined;
|
||||
}
|
||||
return createImportTypeNode(lit, nonRootParts as EntityName, typeParameterNodes as ReadonlyArray<TypeNode>, isTypeOf);
|
||||
return createImportTypeNode(lit, nonRootParts as EntityName, typeParameterNodes as readonly TypeNode[], isTypeOf);
|
||||
}
|
||||
else {
|
||||
const splitNode = getTopmostIndexedAccessType(nonRootParts);
|
||||
const qualifier = (splitNode.objectType as TypeReferenceNode).typeName;
|
||||
return createIndexedAccessTypeNode(createImportTypeNode(lit, qualifier, typeParameterNodes as ReadonlyArray<TypeNode>, isTypeOf), splitNode.indexType);
|
||||
return createIndexedAccessTypeNode(createImportTypeNode(lit, qualifier, typeParameterNodes as readonly TypeNode[], isTypeOf), splitNode.indexType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4565,7 +4565,7 @@ namespace ts {
|
||||
return createIndexedAccessTypeNode(LHS, createLiteralTypeNode(createLiteral(symbolName)));
|
||||
}
|
||||
else {
|
||||
return createIndexedAccessTypeNode(createTypeReferenceNode(LHS, typeParameterNodes as ReadonlyArray<TypeNode>), createLiteralTypeNode(createLiteral(symbolName)));
|
||||
return createIndexedAccessTypeNode(createTypeReferenceNode(LHS, typeParameterNodes as readonly TypeNode[]), createLiteralTypeNode(createLiteral(symbolName)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4708,7 +4708,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function formatUnionTypes(types: ReadonlyArray<Type>): Type[] {
|
||||
function formatUnionTypes(types: readonly Type[]): Type[] {
|
||||
const result: Type[] = [];
|
||||
let flags: TypeFlags = 0;
|
||||
for (let i = 0; i < types.length; i++) {
|
||||
@@ -6144,7 +6144,7 @@ namespace ts {
|
||||
// Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set.
|
||||
// The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set
|
||||
// in-place and returns the same array.
|
||||
function appendTypeParameters(typeParameters: TypeParameter[] | undefined, declarations: ReadonlyArray<TypeParameterDeclaration>): TypeParameter[] | undefined {
|
||||
function appendTypeParameters(typeParameters: TypeParameter[] | undefined, declarations: readonly TypeParameterDeclaration[]): TypeParameter[] | undefined {
|
||||
for (const declaration of declarations) {
|
||||
typeParameters = appendIfUnique(typeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)));
|
||||
}
|
||||
@@ -6249,14 +6249,14 @@ namespace ts {
|
||||
return getEffectiveBaseTypeNode(type.symbol.valueDeclaration as ClassLikeDeclaration);
|
||||
}
|
||||
|
||||
function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray<TypeNode> | undefined, location: Node): ReadonlyArray<Signature> {
|
||||
function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: readonly TypeNode[] | undefined, location: Node): readonly Signature[] {
|
||||
const typeArgCount = length(typeArgumentNodes);
|
||||
const isJavascript = isInJSFile(location);
|
||||
return filter(getSignaturesOfType(type, SignatureKind.Construct),
|
||||
sig => (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= length(sig.typeParameters));
|
||||
}
|
||||
|
||||
function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray<TypeNode> | undefined, location: Node): ReadonlyArray<Signature> {
|
||||
function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: readonly TypeNode[] | undefined, location: Node): readonly Signature[] {
|
||||
const signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
|
||||
const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode);
|
||||
return sameMap<Signature>(signatures, sig => some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, isInJSFile(location)) : sig);
|
||||
@@ -7027,11 +7027,11 @@ namespace ts {
|
||||
return needApparentType ? getApparentType(type) : type;
|
||||
}
|
||||
|
||||
function resolveObjectTypeMembers(type: ObjectType, source: InterfaceTypeWithDeclaredMembers, typeParameters: ReadonlyArray<TypeParameter>, typeArguments: ReadonlyArray<Type>) {
|
||||
function resolveObjectTypeMembers(type: ObjectType, source: InterfaceTypeWithDeclaredMembers, typeParameters: readonly TypeParameter[], typeArguments: readonly Type[]) {
|
||||
let mapper: TypeMapper;
|
||||
let members: SymbolTable;
|
||||
let callSignatures: ReadonlyArray<Signature>;
|
||||
let constructSignatures: ReadonlyArray<Signature> | undefined;
|
||||
let callSignatures: readonly Signature[];
|
||||
let constructSignatures: readonly Signature[] | undefined;
|
||||
let stringIndexInfo: IndexInfo | undefined;
|
||||
let numberIndexInfo: IndexInfo | undefined;
|
||||
if (rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) {
|
||||
@@ -7087,9 +7087,9 @@ namespace ts {
|
||||
|
||||
function createSignature(
|
||||
declaration: SignatureDeclaration | JSDocSignature | undefined,
|
||||
typeParameters: ReadonlyArray<TypeParameter> | undefined,
|
||||
typeParameters: readonly TypeParameter[] | undefined,
|
||||
thisParameter: Symbol | undefined,
|
||||
parameters: ReadonlyArray<Symbol>,
|
||||
parameters: readonly Symbol[],
|
||||
resolvedReturnType: Type | undefined,
|
||||
resolvedTypePredicate: TypePredicate | undefined,
|
||||
minArgumentCount: number,
|
||||
@@ -7127,7 +7127,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getExpandedParameters(sig: Signature): ReadonlyArray<Symbol> {
|
||||
function getExpandedParameters(sig: Signature): readonly Symbol[] {
|
||||
if (sig.hasRestParameter) {
|
||||
const restIndex = sig.parameters.length - 1;
|
||||
const restParameter = sig.parameters[restIndex];
|
||||
@@ -7174,7 +7174,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function findMatchingSignature(signatureList: ReadonlyArray<Signature>, signature: Signature, partialMatch: boolean, ignoreThisTypes: boolean, ignoreReturnTypes: boolean): Signature | undefined {
|
||||
function findMatchingSignature(signatureList: readonly Signature[], signature: Signature, partialMatch: boolean, ignoreThisTypes: boolean, ignoreReturnTypes: boolean): Signature | undefined {
|
||||
for (const s of signatureList) {
|
||||
if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) {
|
||||
return s;
|
||||
@@ -7182,7 +7182,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function findMatchingSignatures(signatureLists: ReadonlyArray<ReadonlyArray<Signature>>, signature: Signature, listIndex: number): Signature[] | undefined {
|
||||
function findMatchingSignatures(signatureLists: readonly (readonly Signature[])[], signature: Signature, listIndex: number): Signature[] | undefined {
|
||||
if (signature.typeParameters) {
|
||||
// We require an exact match for generic signatures, so we only return signatures from the first
|
||||
// signature list and only if they have exact matches in the other signature lists.
|
||||
@@ -7213,7 +7213,7 @@ namespace ts {
|
||||
// Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional
|
||||
// parameters and may differ in return types. When signatures differ in return types, the resulting return
|
||||
// type is the union of the constituent return types.
|
||||
function getUnionSignatures(signatureLists: ReadonlyArray<ReadonlyArray<Signature>>): Signature[] {
|
||||
function getUnionSignatures(signatureLists: readonly (readonly Signature[])[]): Signature[] {
|
||||
let result: Signature[] | undefined;
|
||||
let indexWithLengthOverOne: number | undefined;
|
||||
for (let i = 0; i < signatureLists.length; i++) {
|
||||
@@ -7335,7 +7335,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getUnionIndexInfo(types: ReadonlyArray<Type>, kind: IndexKind): IndexInfo | undefined {
|
||||
function getUnionIndexInfo(types: readonly Type[], kind: IndexKind): IndexInfo | undefined {
|
||||
const indexTypes: Type[] = [];
|
||||
let isAnyReadonly = false;
|
||||
for (const type of types) {
|
||||
@@ -7375,7 +7375,7 @@ namespace ts {
|
||||
getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly);
|
||||
}
|
||||
|
||||
function findMixins(types: ReadonlyArray<Type>): ReadonlyArray<boolean> {
|
||||
function findMixins(types: readonly Type[]): readonly boolean[] {
|
||||
const constructorTypeCount = countWhere(types, (t) => getSignaturesOfType(t, SignatureKind.Construct).length > 0);
|
||||
const mixinFlags = map(types, isMixinConstructorType);
|
||||
if (constructorTypeCount > 0 && constructorTypeCount === countWhere(mixinFlags, (b) => b)) {
|
||||
@@ -7385,7 +7385,7 @@ namespace ts {
|
||||
return mixinFlags;
|
||||
}
|
||||
|
||||
function includeMixinType(type: Type, types: ReadonlyArray<Type>, mixinFlags: ReadonlyArray<boolean>, index: number): Type {
|
||||
function includeMixinType(type: Type, types: readonly Type[], mixinFlags: readonly boolean[], index: number): Type {
|
||||
const mixedTypes: Type[] = [];
|
||||
for (let i = 0; i < types.length; i++) {
|
||||
if (i === index) {
|
||||
@@ -7433,7 +7433,7 @@ namespace ts {
|
||||
setStructuredTypeMembers(type, emptySymbols, callSignatures || emptyArray, constructSignatures || emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
}
|
||||
|
||||
function appendSignatures(signatures: Signature[] | undefined, newSignatures: ReadonlyArray<Signature>) {
|
||||
function appendSignatures(signatures: Signature[] | undefined, newSignatures: readonly Signature[]) {
|
||||
for (const sig of newSignatures) {
|
||||
if (!signatures || every(signatures, s => !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical))) {
|
||||
signatures = append(signatures, sig);
|
||||
@@ -7819,7 +7819,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getAllPossiblePropertiesOfTypes(types: ReadonlyArray<Type>): Symbol[] {
|
||||
function getAllPossiblePropertiesOfTypes(types: readonly Type[]): Symbol[] {
|
||||
const unionType = getUnionType(types);
|
||||
if (!(unionType.flags & TypeFlags.Union)) {
|
||||
return getAugmentedPropertiesOfType(unionType);
|
||||
@@ -8325,7 +8325,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): ReadonlyArray<Signature> {
|
||||
function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): readonly Signature[] {
|
||||
if (type.flags & TypeFlags.StructuredType) {
|
||||
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
|
||||
return kind === SignatureKind.Call ? resolved.callSignatures : resolved.constructSignatures;
|
||||
@@ -8337,7 +8337,7 @@ namespace ts {
|
||||
* Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and
|
||||
* maps primitive types and type parameters are to their apparent types.
|
||||
*/
|
||||
function getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray<Signature> {
|
||||
function getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[] {
|
||||
return getSignaturesOfStructuredType(getApparentType(type), kind);
|
||||
}
|
||||
|
||||
@@ -8461,7 +8461,7 @@ namespace ts {
|
||||
* Gets the minimum number of type arguments needed to satisfy all non-optional type
|
||||
* parameters.
|
||||
*/
|
||||
function getMinTypeArgumentCount(typeParameters: ReadonlyArray<TypeParameter> | undefined): number {
|
||||
function getMinTypeArgumentCount(typeParameters: readonly TypeParameter[] | undefined): number {
|
||||
let minTypeArgumentCount = 0;
|
||||
if (typeParameters) {
|
||||
for (let i = 0; i < typeParameters.length; i++) {
|
||||
@@ -8481,9 +8481,9 @@ namespace ts {
|
||||
* @param typeParameters The requested type parameters.
|
||||
* @param minTypeArgumentCount The minimum number of required type arguments.
|
||||
*/
|
||||
function fillMissingTypeArguments(typeArguments: ReadonlyArray<Type>, typeParameters: ReadonlyArray<TypeParameter> | undefined, minTypeArgumentCount: number, isJavaScriptImplicitAny: boolean): Type[];
|
||||
function fillMissingTypeArguments(typeArguments: ReadonlyArray<Type> | undefined, typeParameters: ReadonlyArray<TypeParameter> | undefined, minTypeArgumentCount: number, isJavaScriptImplicitAny: boolean): Type[] | undefined;
|
||||
function fillMissingTypeArguments(typeArguments: ReadonlyArray<Type> | undefined, typeParameters: ReadonlyArray<TypeParameter> | undefined, minTypeArgumentCount: number, isJavaScriptImplicitAny: boolean) {
|
||||
function fillMissingTypeArguments(typeArguments: readonly Type[], typeParameters: readonly TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScriptImplicitAny: boolean): Type[];
|
||||
function fillMissingTypeArguments(typeArguments: readonly Type[] | undefined, typeParameters: readonly TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScriptImplicitAny: boolean): Type[] | undefined;
|
||||
function fillMissingTypeArguments(typeArguments: readonly Type[] | undefined, typeParameters: readonly TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScriptImplicitAny: boolean) {
|
||||
const numTypeParameters = length(typeParameters);
|
||||
if (!numTypeParameters) {
|
||||
return [];
|
||||
@@ -8810,7 +8810,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getSignatureInstantiation(signature: Signature, typeArguments: Type[] | undefined, isJavascript: boolean, inferredTypeParameters?: ReadonlyArray<TypeParameter>): Signature {
|
||||
function getSignatureInstantiation(signature: Signature, typeArguments: Type[] | undefined, isJavascript: boolean, inferredTypeParameters?: readonly TypeParameter[]): Signature {
|
||||
const instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript));
|
||||
if (inferredTypeParameters) {
|
||||
const returnSignature = getSingleCallOrConstructSignature(getReturnTypeOfSignature(instantiatedSignature));
|
||||
@@ -8825,7 +8825,7 @@ namespace ts {
|
||||
return instantiatedSignature;
|
||||
}
|
||||
|
||||
function getSignatureInstantiationWithoutFillingInTypeArguments(signature: Signature, typeArguments: ReadonlyArray<Type> | undefined): Signature {
|
||||
function getSignatureInstantiationWithoutFillingInTypeArguments(signature: Signature, typeArguments: readonly Type[] | undefined): Signature {
|
||||
const instantiations = signature.instantiations || (signature.instantiations = createMap<Signature>());
|
||||
const id = getTypeListId(typeArguments);
|
||||
let instantiation = instantiations.get(id);
|
||||
@@ -8835,11 +8835,11 @@ namespace ts {
|
||||
return instantiation;
|
||||
}
|
||||
|
||||
function createSignatureInstantiation(signature: Signature, typeArguments: ReadonlyArray<Type> | undefined): Signature {
|
||||
function createSignatureInstantiation(signature: Signature, typeArguments: readonly Type[] | undefined): Signature {
|
||||
return instantiateSignature(signature, createSignatureTypeMapper(signature, typeArguments), /*eraseTypeParameters*/ true);
|
||||
}
|
||||
|
||||
function createSignatureTypeMapper(signature: Signature, typeArguments: ReadonlyArray<Type> | undefined): TypeMapper {
|
||||
function createSignatureTypeMapper(signature: Signature, typeArguments: readonly Type[] | undefined): TypeMapper {
|
||||
return createTypeMapper(signature.typeParameters!, typeArguments);
|
||||
}
|
||||
|
||||
@@ -9008,7 +9008,7 @@ namespace ts {
|
||||
return host && getSymbolOfNode(host);
|
||||
}
|
||||
|
||||
function getTypeListId(types: ReadonlyArray<Type> | undefined) {
|
||||
function getTypeListId(types: readonly Type[] | undefined) {
|
||||
let result = "";
|
||||
if (types) {
|
||||
const length = types.length;
|
||||
@@ -9036,7 +9036,7 @@ namespace ts {
|
||||
// It is only necessary to do so if a constituent type might be the undefined type, the null type, the type
|
||||
// of an object literal or the anyFunctionType. This is because there are operations in the type checker
|
||||
// that care about the presence of such types at arbitrary depth in a containing type.
|
||||
function getPropagatingFlagsOfTypes(types: ReadonlyArray<Type>, excludeKinds: TypeFlags): ObjectFlags {
|
||||
function getPropagatingFlagsOfTypes(types: readonly Type[], excludeKinds: TypeFlags): ObjectFlags {
|
||||
let result: ObjectFlags = 0;
|
||||
for (const type of types) {
|
||||
if (!(type.flags & excludeKinds)) {
|
||||
@@ -9046,7 +9046,7 @@ namespace ts {
|
||||
return result & ObjectFlags.PropagatingFlags;
|
||||
}
|
||||
|
||||
function createTypeReference(target: GenericType, typeArguments: ReadonlyArray<Type> | undefined): TypeReference {
|
||||
function createTypeReference(target: GenericType, typeArguments: readonly Type[] | undefined): TypeReference {
|
||||
const id = getTypeListId(typeArguments);
|
||||
let type = target.instantiations.get(id);
|
||||
if (!type) {
|
||||
@@ -9109,7 +9109,7 @@ namespace ts {
|
||||
return checkNoTypeArguments(node, symbol) ? type : errorType;
|
||||
}
|
||||
|
||||
function getTypeAliasInstantiation(symbol: Symbol, typeArguments: ReadonlyArray<Type> | undefined): Type {
|
||||
function getTypeAliasInstantiation(symbol: Symbol, typeArguments: readonly Type[] | undefined): Type {
|
||||
const type = getDeclaredTypeOfSymbol(symbol);
|
||||
const links = getSymbolLinks(symbol);
|
||||
const typeParameters = links.typeParameters!;
|
||||
@@ -9539,7 +9539,7 @@ namespace ts {
|
||||
/**
|
||||
* Instantiates a global type that is generic with some element type, and returns that instantiation.
|
||||
*/
|
||||
function createTypeFromGenericGlobalType(genericGlobalType: GenericType, typeArguments: ReadonlyArray<Type>): ObjectType {
|
||||
function createTypeFromGenericGlobalType(genericGlobalType: GenericType, typeArguments: readonly Type[]): ObjectType {
|
||||
return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
|
||||
}
|
||||
|
||||
@@ -9627,7 +9627,7 @@ namespace ts {
|
||||
return type;
|
||||
}
|
||||
|
||||
function createTupleType(elementTypes: ReadonlyArray<Type>, minLength = elementTypes.length, hasRestElement = false, readonly = false, associatedNames?: __String[]) {
|
||||
function createTupleType(elementTypes: readonly Type[], minLength = elementTypes.length, hasRestElement = false, readonly = false, associatedNames?: __String[]) {
|
||||
const arity = elementTypes.length;
|
||||
if (arity === 1 && hasRestElement) {
|
||||
return createArrayType(elementTypes[0], readonly);
|
||||
@@ -9675,7 +9675,7 @@ namespace ts {
|
||||
return type.id;
|
||||
}
|
||||
|
||||
function containsType(types: ReadonlyArray<Type>, type: Type): boolean {
|
||||
function containsType(types: readonly Type[], type: Type): boolean {
|
||||
return binarySearch(types, type, getTypeId, compareValues) >= 0;
|
||||
}
|
||||
|
||||
@@ -9714,14 +9714,14 @@ namespace ts {
|
||||
|
||||
// Add the given types to the given type set. Order is preserved, duplicates are removed,
|
||||
// and nested types of the given kind are flattened into the set.
|
||||
function addTypesToUnion(typeSet: Type[], includes: TypeFlags, types: ReadonlyArray<Type>): TypeFlags {
|
||||
function addTypesToUnion(typeSet: Type[], includes: TypeFlags, types: readonly Type[]): TypeFlags {
|
||||
for (const type of types) {
|
||||
includes = addTypeToUnion(typeSet, includes, type);
|
||||
}
|
||||
return includes;
|
||||
}
|
||||
|
||||
function isSetOfLiteralsFromSameEnum(types: ReadonlyArray<Type>): boolean {
|
||||
function isSetOfLiteralsFromSameEnum(types: readonly Type[]): boolean {
|
||||
const first = types[0];
|
||||
if (first.flags & TypeFlags.EnumLiteral) {
|
||||
const firstEnum = getParentOfSymbol(first.symbol);
|
||||
@@ -9799,7 +9799,7 @@ namespace ts {
|
||||
// expression constructs such as array literals and the || and ?: operators). Named types can
|
||||
// circularly reference themselves and therefore cannot be subtype reduced during their declaration.
|
||||
// For example, "type Item = string | (() => Item" is a named type that circularly references itself.
|
||||
function getUnionType(types: ReadonlyArray<Type>, unionReduction: UnionReduction = UnionReduction.Literal, aliasSymbol?: Symbol, aliasTypeArguments?: ReadonlyArray<Type>): Type {
|
||||
function getUnionType(types: readonly Type[], unionReduction: UnionReduction = UnionReduction.Literal, aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): Type {
|
||||
if (types.length === 0) {
|
||||
return neverType;
|
||||
}
|
||||
@@ -9833,7 +9833,7 @@ namespace ts {
|
||||
return getUnionTypeFromSortedList(typeSet, includes & TypeFlags.NotPrimitiveUnion ? 0 : ObjectFlags.PrimitiveUnion, aliasSymbol, aliasTypeArguments);
|
||||
}
|
||||
|
||||
function getUnionTypePredicate(signatures: ReadonlyArray<Signature>): TypePredicate | undefined {
|
||||
function getUnionTypePredicate(signatures: readonly Signature[]): TypePredicate | undefined {
|
||||
let first: TypePredicate | undefined;
|
||||
const types: Type[] = [];
|
||||
for (const sig of signatures) {
|
||||
@@ -9870,7 +9870,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// This function assumes the constituent type list is sorted and deduplicated.
|
||||
function getUnionTypeFromSortedList(types: Type[], objectFlags: ObjectFlags, aliasSymbol?: Symbol, aliasTypeArguments?: ReadonlyArray<Type>): Type {
|
||||
function getUnionTypeFromSortedList(types: Type[], objectFlags: ObjectFlags, aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): Type {
|
||||
if (types.length === 0) {
|
||||
return neverType;
|
||||
}
|
||||
@@ -9936,7 +9936,7 @@ namespace ts {
|
||||
|
||||
// Add the given types to the given type set. Order is preserved, freshness is removed from literal
|
||||
// types, duplicates are removed, and nested types of the given kind are flattened into the set.
|
||||
function addTypesToIntersection(typeSet: Map<Type>, includes: TypeFlags, types: ReadonlyArray<Type>) {
|
||||
function addTypesToIntersection(typeSet: Map<Type>, includes: TypeFlags, types: readonly Type[]) {
|
||||
for (const type of types) {
|
||||
includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type));
|
||||
}
|
||||
@@ -10023,7 +10023,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
function createIntersectionType(types: Type[], aliasSymbol?: Symbol, aliasTypeArguments?: ReadonlyArray<Type>) {
|
||||
function createIntersectionType(types: Type[], aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]) {
|
||||
const result = <IntersectionType>createType(TypeFlags.Intersection);
|
||||
result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable);
|
||||
result.types = types;
|
||||
@@ -10042,7 +10042,7 @@ namespace ts {
|
||||
// a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
|
||||
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
|
||||
// for intersections of types with signatures can be deterministic.
|
||||
function getIntersectionType(types: ReadonlyArray<Type>, aliasSymbol?: Symbol, aliasTypeArguments?: ReadonlyArray<Type>): Type {
|
||||
function getIntersectionType(types: readonly Type[], aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): Type {
|
||||
const typeMembershipMap: Map<Type> = createMap();
|
||||
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
||||
const typeSet: Type[] = arrayFrom(typeMembershipMap.values());
|
||||
@@ -11185,9 +11185,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function instantiateList<T>(items: ReadonlyArray<T>, mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): ReadonlyArray<T>;
|
||||
function instantiateList<T>(items: ReadonlyArray<T> | undefined, mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): ReadonlyArray<T> | undefined;
|
||||
function instantiateList<T>(items: ReadonlyArray<T> | undefined, mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): ReadonlyArray<T> | undefined {
|
||||
function instantiateList<T>(items: readonly T[], mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): readonly T[];
|
||||
function instantiateList<T>(items: readonly T[] | undefined, mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): readonly T[] | undefined;
|
||||
function instantiateList<T>(items: readonly T[] | undefined, mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): readonly T[] | undefined {
|
||||
if (items && items.length) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
@@ -11205,13 +11205,13 @@ namespace ts {
|
||||
return items;
|
||||
}
|
||||
|
||||
function instantiateTypes(types: ReadonlyArray<Type>, mapper: TypeMapper): ReadonlyArray<Type>;
|
||||
function instantiateTypes(types: ReadonlyArray<Type> | undefined, mapper: TypeMapper): ReadonlyArray<Type> | undefined;
|
||||
function instantiateTypes(types: ReadonlyArray<Type> | undefined, mapper: TypeMapper): ReadonlyArray<Type> | undefined {
|
||||
function instantiateTypes(types: readonly Type[], mapper: TypeMapper): readonly Type[];
|
||||
function instantiateTypes(types: readonly Type[] | undefined, mapper: TypeMapper): readonly Type[] | undefined;
|
||||
function instantiateTypes(types: readonly Type[] | undefined, mapper: TypeMapper): readonly Type[] | undefined {
|
||||
return instantiateList<Type>(types, mapper, instantiateType);
|
||||
}
|
||||
|
||||
function instantiateSignatures(signatures: ReadonlyArray<Signature>, mapper: TypeMapper): ReadonlyArray<Signature> {
|
||||
function instantiateSignatures(signatures: readonly Signature[], mapper: TypeMapper): readonly Signature[] {
|
||||
return instantiateList<Signature>(signatures, mapper, instantiateSignature);
|
||||
}
|
||||
|
||||
@@ -11223,7 +11223,7 @@ namespace ts {
|
||||
return (t: Type) => t === source1 ? target1 : t === source2 ? target2 : t;
|
||||
}
|
||||
|
||||
function makeArrayTypeMapper(sources: ReadonlyArray<Type>, targets: ReadonlyArray<Type> | undefined) {
|
||||
function makeArrayTypeMapper(sources: readonly Type[], targets: readonly Type[] | undefined) {
|
||||
return (t: Type) => {
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
if (t === sources[i]) {
|
||||
@@ -11234,14 +11234,14 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function createTypeMapper(sources: ReadonlyArray<TypeParameter>, targets: ReadonlyArray<Type> | undefined): TypeMapper {
|
||||
function createTypeMapper(sources: readonly TypeParameter[], targets: readonly Type[] | undefined): TypeMapper {
|
||||
Debug.assert(targets === undefined || sources.length === targets.length);
|
||||
return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) :
|
||||
sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) :
|
||||
makeArrayTypeMapper(sources, targets);
|
||||
}
|
||||
|
||||
function createTypeEraser(sources: ReadonlyArray<TypeParameter>): TypeMapper {
|
||||
function createTypeEraser(sources: readonly TypeParameter[]): TypeMapper {
|
||||
return createTypeMapper(sources, /*targets*/ undefined);
|
||||
}
|
||||
|
||||
@@ -13186,7 +13186,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function typeArgumentsRelatedTo(sources: ReadonlyArray<Type> = emptyArray, targets: ReadonlyArray<Type> = emptyArray, variances: ReadonlyArray<VarianceFlags> = emptyArray, reportErrors: boolean, isIntersectionConstituent: boolean): Ternary {
|
||||
function typeArgumentsRelatedTo(sources: readonly Type[] = emptyArray, targets: readonly Type[] = emptyArray, variances: readonly VarianceFlags[] = emptyArray, reportErrors: boolean, isIntersectionConstituent: boolean): Ternary {
|
||||
if (sources.length !== targets.length && relation === identityRelation) {
|
||||
return Ternary.False;
|
||||
}
|
||||
@@ -13243,7 +13243,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function propagateSidebandVarianceFlags(typeArguments: ReadonlyArray<Type>, variances: VarianceFlags[]) {
|
||||
function propagateSidebandVarianceFlags(typeArguments: readonly Type[], variances: VarianceFlags[]) {
|
||||
for (let i = 0; i < variances.length; i++) {
|
||||
const v = variances[i];
|
||||
if (v & VarianceFlags.Unmeasurable) {
|
||||
@@ -13627,7 +13627,7 @@ namespace ts {
|
||||
}
|
||||
return Ternary.False;
|
||||
|
||||
function relateVariances(sourceTypeArguments: ReadonlyArray<Type> | undefined, targetTypeArguments: ReadonlyArray<Type> | undefined, variances: VarianceFlags[], isIntersectionConstituent: boolean) {
|
||||
function relateVariances(sourceTypeArguments: readonly Type[] | undefined, targetTypeArguments: readonly Type[] | undefined, variances: VarianceFlags[], isIntersectionConstituent: boolean) {
|
||||
if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) {
|
||||
return result;
|
||||
}
|
||||
@@ -14332,7 +14332,7 @@ namespace ts {
|
||||
// instantiations of the generic type for type arguments with known relations. The function
|
||||
// returns the emptyArray singleton if we're not in strictFunctionTypes mode or if the function
|
||||
// has been invoked recursively for the given generic type.
|
||||
function getVariancesWorker<TCache extends { variances?: VarianceFlags[] }>(typeParameters: ReadonlyArray<TypeParameter> = emptyArray, cache: TCache, createMarkerType: (input: TCache, param: TypeParameter, marker: Type) => Type): VarianceFlags[] {
|
||||
function getVariancesWorker<TCache extends { variances?: VarianceFlags[] }>(typeParameters: readonly TypeParameter[] = emptyArray, cache: TCache, createMarkerType: (input: TCache, param: TypeParameter, marker: Type) => Type): VarianceFlags[] {
|
||||
let variances = cache.variances;
|
||||
if (!variances) {
|
||||
// The emptyArray singleton is used to signal a recursive invocation.
|
||||
@@ -14383,7 +14383,7 @@ namespace ts {
|
||||
|
||||
// Return true if the given type reference has a 'void' type argument for a covariant type parameter.
|
||||
// See comment at call in recursiveTypeRelatedTo for when this case matters.
|
||||
function hasCovariantVoidArgument(typeArguments: ReadonlyArray<Type>, variances: VarianceFlags[]): boolean {
|
||||
function hasCovariantVoidArgument(typeArguments: readonly Type[], variances: VarianceFlags[]): boolean {
|
||||
for (let i = 0; i < variances.length; i++) {
|
||||
if ((variances[i] & VarianceFlags.VarianceMask) === VarianceFlags.Covariant && typeArguments[i].flags & TypeFlags.Void) {
|
||||
return true;
|
||||
@@ -15244,7 +15244,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function createInferenceContext(typeParameters: ReadonlyArray<TypeParameter>, signature: Signature | undefined, flags: InferenceFlags, compareTypes?: TypeComparer): InferenceContext {
|
||||
function createInferenceContext(typeParameters: readonly TypeParameter[], signature: Signature | undefined, flags: InferenceFlags, compareTypes?: TypeComparer): InferenceContext {
|
||||
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
|
||||
}
|
||||
|
||||
@@ -15728,7 +15728,7 @@ namespace ts {
|
||||
];
|
||||
}
|
||||
|
||||
function inferFromTypeArguments(sourceTypes: ReadonlyArray<Type>, targetTypes: ReadonlyArray<Type>, variances: ReadonlyArray<VarianceFlags>) {
|
||||
function inferFromTypeArguments(sourceTypes: readonly Type[], targetTypes: readonly Type[], variances: readonly VarianceFlags[]) {
|
||||
const count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
|
||||
for (let i = 0; i < count; i++) {
|
||||
if (i < variances.length && (variances[i] & VarianceFlags.VarianceMask) === VarianceFlags.Contravariant) {
|
||||
@@ -20198,7 +20198,7 @@ namespace ts {
|
||||
return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
|
||||
}
|
||||
|
||||
function getUninstantiatedJsxSignaturesOfType(elementType: Type, caller: JsxOpeningLikeElement): ReadonlyArray<Signature> {
|
||||
function getUninstantiatedJsxSignaturesOfType(elementType: Type, caller: JsxOpeningLikeElement): readonly Signature[] {
|
||||
if (elementType.flags & TypeFlags.String) {
|
||||
return [anySignature];
|
||||
}
|
||||
@@ -21158,7 +21158,7 @@ namespace ts {
|
||||
// interface B extends A { (x: 'foo'): string }
|
||||
// const b: B;
|
||||
// b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void]
|
||||
function reorderCandidates(signatures: ReadonlyArray<Signature>, result: Signature[]): void {
|
||||
function reorderCandidates(signatures: readonly Signature[], result: Signature[]): void {
|
||||
let lastParent: Node | undefined;
|
||||
let lastSymbol: Symbol | undefined;
|
||||
let cutoffIndex = 0;
|
||||
@@ -21208,7 +21208,7 @@ namespace ts {
|
||||
return !!arg && (arg.kind === SyntaxKind.SpreadElement || arg.kind === SyntaxKind.SyntheticExpression && (<SyntheticExpression>arg).isSpread);
|
||||
}
|
||||
|
||||
function getSpreadArgumentIndex(args: ReadonlyArray<Expression>): number {
|
||||
function getSpreadArgumentIndex(args: readonly Expression[]): number {
|
||||
return findIndex(args, isSpreadArgument);
|
||||
}
|
||||
|
||||
@@ -21216,7 +21216,7 @@ namespace ts {
|
||||
return !!(t.flags & TypeFlags.Void);
|
||||
}
|
||||
|
||||
function hasCorrectArity(node: CallLikeExpression, args: ReadonlyArray<Expression>, signature: Signature, signatureHelpTrailingComma = false) {
|
||||
function hasCorrectArity(node: CallLikeExpression, args: readonly Expression[], signature: Signature, signatureHelpTrailingComma = false) {
|
||||
let argCount: number;
|
||||
let callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments
|
||||
let effectiveParameterCount = getParameterCount(signature);
|
||||
@@ -21351,7 +21351,7 @@ namespace ts {
|
||||
return getInferredTypes(context);
|
||||
}
|
||||
|
||||
function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: ReadonlyArray<Expression>, checkMode: CheckMode, context: InferenceContext): Type[] {
|
||||
function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: readonly Expression[], checkMode: CheckMode, context: InferenceContext): Type[] {
|
||||
if (isJsxOpeningLikeElement(node)) {
|
||||
return inferJsxTypeArguments(node, signature, checkMode, context);
|
||||
}
|
||||
@@ -21427,7 +21427,7 @@ namespace ts {
|
||||
return type;
|
||||
}
|
||||
|
||||
function getSpreadArgumentType(args: ReadonlyArray<Expression>, index: number, argCount: number, restType: Type, context: InferenceContext | undefined) {
|
||||
function getSpreadArgumentType(args: readonly Expression[], index: number, argCount: number, restType: Type, context: InferenceContext | undefined) {
|
||||
if (index >= argCount - 1) {
|
||||
const arg = args[argCount - 1];
|
||||
if (isSpreadArgument(arg)) {
|
||||
@@ -21454,7 +21454,7 @@ namespace ts {
|
||||
createTupleType(append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true);
|
||||
}
|
||||
|
||||
function checkTypeArguments(signature: Signature, typeArgumentNodes: ReadonlyArray<TypeNode>, reportErrors: boolean, headMessage?: DiagnosticMessage): Type[] | undefined {
|
||||
function checkTypeArguments(signature: Signature, typeArgumentNodes: readonly TypeNode[], reportErrors: boolean, headMessage?: DiagnosticMessage): Type[] | undefined {
|
||||
const isJavascript = isInJSFile(signature.declaration);
|
||||
const typeParameters = signature.typeParameters!;
|
||||
const typeArgumentTypes = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript);
|
||||
@@ -21529,7 +21529,7 @@ namespace ts {
|
||||
|
||||
function getSignatureApplicabilityError(
|
||||
node: CallLikeExpression,
|
||||
args: ReadonlyArray<Expression>,
|
||||
args: readonly Expression[],
|
||||
signature: Signature,
|
||||
relation: Map<RelationComparisonResult>,
|
||||
checkMode: CheckMode,
|
||||
@@ -21626,7 +21626,7 @@ namespace ts {
|
||||
/**
|
||||
* Returns the effective arguments for an expression that works like a function invocation.
|
||||
*/
|
||||
function getEffectiveCallArguments(node: CallLikeExpression): ReadonlyArray<Expression> {
|
||||
function getEffectiveCallArguments(node: CallLikeExpression): readonly Expression[] {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
const template = node.template;
|
||||
const args: Expression[] = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())];
|
||||
@@ -21664,7 +21664,7 @@ namespace ts {
|
||||
/**
|
||||
* Returns the synthetic argument list for a decorator invocation.
|
||||
*/
|
||||
function getEffectiveDecoratorArguments(node: Decorator): ReadonlyArray<Expression> {
|
||||
function getEffectiveDecoratorArguments(node: Decorator): readonly Expression[] {
|
||||
const parent = node.parent;
|
||||
const expr = node.expression;
|
||||
switch (parent.kind) {
|
||||
@@ -21749,7 +21749,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getArgumentArityError(node: CallLikeExpression, signatures: ReadonlyArray<Signature>, args: ReadonlyArray<Expression>) {
|
||||
function getArgumentArityError(node: CallLikeExpression, signatures: readonly Signature[], args: readonly Expression[]) {
|
||||
let min = Number.POSITIVE_INFINITY;
|
||||
let max = Number.NEGATIVE_INFINITY;
|
||||
let belowArgCount = Number.NEGATIVE_INFINITY;
|
||||
@@ -21825,7 +21825,7 @@ namespace ts {
|
||||
return related ? addRelatedInfo(diagnostic, related) : diagnostic;
|
||||
}
|
||||
|
||||
function getTypeArgumentArityError(node: Node, signatures: ReadonlyArray<Signature>, typeArguments: NodeArray<TypeNode>) {
|
||||
function getTypeArgumentArityError(node: Node, signatures: readonly Signature[], typeArguments: NodeArray<TypeNode>) {
|
||||
const argCount = typeArguments.length;
|
||||
// No overloads exist
|
||||
if (signatures.length === 1) {
|
||||
@@ -21853,7 +21853,7 @@ namespace ts {
|
||||
return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
|
||||
}
|
||||
|
||||
function resolveCall(node: CallLikeExpression, signatures: ReadonlyArray<Signature>, candidatesOutArray: Signature[] | undefined, checkMode: CheckMode, fallbackError?: DiagnosticMessage): Signature {
|
||||
function resolveCall(node: CallLikeExpression, signatures: readonly Signature[], candidatesOutArray: Signature[] | undefined, checkMode: CheckMode, fallbackError?: DiagnosticMessage): Signature {
|
||||
const isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression;
|
||||
const isDecorator = node.kind === SyntaxKind.Decorator;
|
||||
const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
|
||||
@@ -22124,7 +22124,7 @@ namespace ts {
|
||||
function getCandidateForOverloadFailure(
|
||||
node: CallLikeExpression,
|
||||
candidates: Signature[],
|
||||
args: ReadonlyArray<Expression>,
|
||||
args: readonly Expression[],
|
||||
hasCandidatesOutArray: boolean,
|
||||
): Signature {
|
||||
Debug.assert(candidates.length > 0); // Else should not have called this.
|
||||
@@ -22136,7 +22136,7 @@ namespace ts {
|
||||
: createUnionOfSignaturesForOverloadFailure(candidates);
|
||||
}
|
||||
|
||||
function createUnionOfSignaturesForOverloadFailure(candidates: ReadonlyArray<Signature>): Signature {
|
||||
function createUnionOfSignaturesForOverloadFailure(candidates: readonly Signature[]): Signature {
|
||||
const thisParameters = mapDefined(candidates, c => c.thisParameter);
|
||||
let thisParameter: Symbol | undefined;
|
||||
if (thisParameters.length) {
|
||||
@@ -22174,16 +22174,16 @@ namespace ts {
|
||||
return signature.hasRestParameter ? numParams - 1 : numParams;
|
||||
}
|
||||
|
||||
function createCombinedSymbolFromTypes(sources: ReadonlyArray<Symbol>, types: Type[]): Symbol {
|
||||
function createCombinedSymbolFromTypes(sources: readonly Symbol[], types: Type[]): Symbol {
|
||||
return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, UnionReduction.Subtype));
|
||||
}
|
||||
|
||||
function createCombinedSymbolForOverloadFailure(sources: ReadonlyArray<Symbol>, type: Type): Symbol {
|
||||
function createCombinedSymbolForOverloadFailure(sources: readonly Symbol[], type: Type): Symbol {
|
||||
// This function is currently only used for erroneous overloads, so it's good enough to just use the first source.
|
||||
return createSymbolWithType(first(sources), type);
|
||||
}
|
||||
|
||||
function pickLongestCandidateSignature(node: CallLikeExpression, candidates: Signature[], args: ReadonlyArray<Expression>): Signature {
|
||||
function pickLongestCandidateSignature(node: CallLikeExpression, candidates: Signature[], args: readonly Expression[]): Signature {
|
||||
// Pick the longest signature. This way we can get a contextual type for cases like:
|
||||
// declare function f(a: { xa: number; xb: number; }, b: number);
|
||||
// f({ |
|
||||
@@ -22197,7 +22197,7 @@ namespace ts {
|
||||
return candidate;
|
||||
}
|
||||
|
||||
const typeArgumentNodes: ReadonlyArray<TypeNode> | undefined = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
|
||||
const typeArgumentNodes: readonly TypeNode[] | undefined = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
|
||||
const instantiated = typeArgumentNodes
|
||||
? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, isInJSFile(node)))
|
||||
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
|
||||
@@ -22205,7 +22205,7 @@ namespace ts {
|
||||
return instantiated;
|
||||
}
|
||||
|
||||
function getTypeArgumentsFromNodes(typeArgumentNodes: ReadonlyArray<TypeNode>, typeParameters: ReadonlyArray<TypeParameter>, isJs: boolean): ReadonlyArray<Type> {
|
||||
function getTypeArgumentsFromNodes(typeArgumentNodes: readonly TypeNode[], typeParameters: readonly TypeParameter[], isJs: boolean): readonly Type[] {
|
||||
const typeArguments = typeArgumentNodes.map(getTypeOfNode);
|
||||
while (typeArguments.length > typeParameters.length) {
|
||||
typeArguments.pop();
|
||||
@@ -22216,7 +22216,7 @@ namespace ts {
|
||||
return typeArguments;
|
||||
}
|
||||
|
||||
function inferSignatureInstantiationForOverloadFailure(node: CallLikeExpression, typeParameters: ReadonlyArray<TypeParameter>, candidate: Signature, args: ReadonlyArray<Expression>): Signature {
|
||||
function inferSignatureInstantiationForOverloadFailure(node: CallLikeExpression, typeParameters: readonly TypeParameter[], candidate: Signature, args: readonly Expression[]): Signature {
|
||||
const inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ isInJSFile(node) ? InferenceFlags.AnyDefault : InferenceFlags.None);
|
||||
const typeArgumentTypes = inferTypeArguments(node, candidate, args, CheckMode.SkipContextSensitive | CheckMode.SkipGenericFunctions, inferenceContext);
|
||||
return createSignatureInstantiation(candidate, typeArgumentTypes);
|
||||
@@ -22756,7 +22756,7 @@ namespace ts {
|
||||
* but is receiving too many arguments as part of the decorator invocation.
|
||||
* In those cases, a user may have meant to *call* the expression before using it as a decorator.
|
||||
*/
|
||||
function isPotentiallyUncalledDecorator(decorator: Decorator, signatures: ReadonlyArray<Signature>) {
|
||||
function isPotentiallyUncalledDecorator(decorator: Decorator, signatures: readonly Signature[]) {
|
||||
return signatures.length && every(signatures, signature =>
|
||||
signature.minArgumentCount === 0 &&
|
||||
!signature.hasRestParameter &&
|
||||
@@ -25125,7 +25125,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getUniqueTypeParameters(context: InferenceContext, typeParameters: ReadonlyArray<TypeParameter>): ReadonlyArray<TypeParameter> {
|
||||
function getUniqueTypeParameters(context: InferenceContext, typeParameters: readonly TypeParameter[]): readonly TypeParameter[] {
|
||||
const result: TypeParameter[] = [];
|
||||
let oldTypeParameters: TypeParameter[] | undefined;
|
||||
let newTypeParameters: TypeParameter[] | undefined;
|
||||
@@ -25153,11 +25153,11 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function hasTypeParameterByName(typeParameters: ReadonlyArray<TypeParameter> | undefined, name: __String) {
|
||||
function hasTypeParameterByName(typeParameters: readonly TypeParameter[] | undefined, name: __String) {
|
||||
return some(typeParameters, tp => tp.symbol.escapedName === name);
|
||||
}
|
||||
|
||||
function getUniqueTypeParameterName(typeParameters: ReadonlyArray<TypeParameter>, baseName: __String) {
|
||||
function getUniqueTypeParameterName(typeParameters: readonly TypeParameter[], baseName: __String) {
|
||||
let len = (<string>baseName).length;
|
||||
while (len > 1 && (<string>baseName).charCodeAt(len - 1) >= CharacterCodes._0 && (<string>baseName).charCodeAt(len - 1) <= CharacterCodes._9) len--;
|
||||
const s = (<string>baseName).slice(0, len);
|
||||
@@ -25924,12 +25924,12 @@ namespace ts {
|
||||
checkDecorators(node);
|
||||
}
|
||||
|
||||
function getEffectiveTypeArguments(node: TypeReferenceNode | ExpressionWithTypeArguments, typeParameters: ReadonlyArray<TypeParameter>): Type[] {
|
||||
function getEffectiveTypeArguments(node: TypeReferenceNode | ExpressionWithTypeArguments, typeParameters: readonly TypeParameter[]): Type[] {
|
||||
return fillMissingTypeArguments(map(node.typeArguments!, getTypeFromTypeNode), typeParameters,
|
||||
getMinTypeArgumentCount(typeParameters), isInJSFile(node));
|
||||
}
|
||||
|
||||
function checkTypeArgumentConstraints(node: TypeReferenceNode | ExpressionWithTypeArguments, typeParameters: ReadonlyArray<TypeParameter>): boolean {
|
||||
function checkTypeArgumentConstraints(node: TypeReferenceNode | ExpressionWithTypeArguments, typeParameters: readonly TypeParameter[]): boolean {
|
||||
let typeArguments: Type[] | undefined;
|
||||
let mapper: TypeMapper | undefined;
|
||||
let result = true;
|
||||
@@ -26859,7 +26859,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getEntityNameForDecoratorMetadataFromTypeList(types: ReadonlyArray<TypeNode>): EntityName | undefined {
|
||||
function getEntityNameForDecoratorMetadataFromTypeList(types: readonly TypeNode[]): EntityName | undefined {
|
||||
let commonEntityName: EntityName | undefined;
|
||||
for (let typeNode of types) {
|
||||
while (typeNode.kind === SyntaxKind.ParenthesizedType) {
|
||||
@@ -27171,7 +27171,7 @@ namespace ts {
|
||||
| Exclude<SignatureDeclaration, IndexSignatureDeclaration | JSDocFunctionType> | TypeAliasDeclaration
|
||||
| InferTypeNode;
|
||||
|
||||
function checkUnusedIdentifiers(potentiallyUnusedIdentifiers: ReadonlyArray<PotentiallyUnusedIdentifier>, addDiagnostic: AddUnusedDiagnostic) {
|
||||
function checkUnusedIdentifiers(potentiallyUnusedIdentifiers: readonly PotentiallyUnusedIdentifier[], addDiagnostic: AddUnusedDiagnostic) {
|
||||
for (const node of potentiallyUnusedIdentifiers) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
@@ -29024,7 +29024,7 @@ namespace ts {
|
||||
/**
|
||||
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
||||
*/
|
||||
function checkTypeParameters(typeParameterDeclarations: ReadonlyArray<TypeParameterDeclaration> | undefined) {
|
||||
function checkTypeParameters(typeParameterDeclarations: readonly TypeParameterDeclaration[] | undefined) {
|
||||
if (typeParameterDeclarations) {
|
||||
let seenDefault = false;
|
||||
for (let i = 0; i < typeParameterDeclarations.length; i++) {
|
||||
@@ -29050,7 +29050,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Check that type parameter defaults only reference previously declared type parameters */
|
||||
function checkTypeParametersNotReferenced(root: TypeNode, typeParameters: ReadonlyArray<TypeParameterDeclaration>, index: number) {
|
||||
function checkTypeParametersNotReferenced(root: TypeNode, typeParameters: readonly TypeParameterDeclaration[], index: number) {
|
||||
visit(root);
|
||||
function visit(node: Node) {
|
||||
if (node.kind === SyntaxKind.TypeReference) {
|
||||
@@ -29092,7 +29092,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function areTypeParametersIdentical(declarations: ReadonlyArray<ClassDeclaration | InterfaceDeclaration>, targetParameters: TypeParameter[]) {
|
||||
function areTypeParametersIdentical(declarations: readonly (ClassDeclaration | InterfaceDeclaration)[], targetParameters: TypeParameter[]) {
|
||||
const maxTypeArgumentCount = length(targetParameters);
|
||||
const minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
|
||||
|
||||
@@ -30598,7 +30598,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getPotentiallyUnusedIdentifiers(sourceFile: SourceFile): ReadonlyArray<PotentiallyUnusedIdentifier> {
|
||||
function getPotentiallyUnusedIdentifiers(sourceFile: SourceFile): readonly PotentiallyUnusedIdentifier[] {
|
||||
return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || emptyArray;
|
||||
}
|
||||
|
||||
@@ -31330,11 +31330,11 @@ namespace ts {
|
||||
return ts.typeHasCallOrConstructSignatures(type, checker);
|
||||
}
|
||||
|
||||
function getRootSymbols(symbol: Symbol): ReadonlyArray<Symbol> {
|
||||
function getRootSymbols(symbol: Symbol): readonly Symbol[] {
|
||||
const roots = getImmediateRootSymbols(symbol);
|
||||
return roots ? flatMap(roots, getRootSymbols) : [symbol];
|
||||
}
|
||||
function getImmediateRootSymbols(symbol: Symbol): ReadonlyArray<Symbol> | undefined {
|
||||
function getImmediateRootSymbols(symbol: Symbol): readonly Symbol[] | undefined {
|
||||
if (getCheckFlags(symbol) & CheckFlags.Synthetic) {
|
||||
return mapDefined(getSymbolLinks(symbol).containingType!.types, type => getPropertyOfType(type, symbol.escapedName));
|
||||
}
|
||||
@@ -32068,7 +32068,7 @@ namespace ts {
|
||||
amalgamatedDuplicates = createMap();
|
||||
|
||||
// Initialize global symbol table
|
||||
let augmentations: ReadonlyArray<StringLiteral | Identifier>[] | undefined;
|
||||
let augmentations: (StringLiteral | Identifier)[][] | undefined;
|
||||
for (const file of host.getSourceFiles()) {
|
||||
if (file.redirectInfo) {
|
||||
continue;
|
||||
@@ -32597,7 +32597,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getNonSimpleParameters(parameters: ReadonlyArray<ParameterDeclaration>): ReadonlyArray<ParameterDeclaration> {
|
||||
function getNonSimpleParameters(parameters: readonly ParameterDeclaration[]): readonly ParameterDeclaration[] {
|
||||
return filter(parameters, parameter => !!parameter.initializer || isBindingPattern(parameter.name) || isRestParameter(parameter));
|
||||
}
|
||||
|
||||
|
||||
@@ -865,19 +865,19 @@ namespace ts {
|
||||
];
|
||||
|
||||
/* @internal */
|
||||
export const semanticDiagnosticsOptionDeclarations: ReadonlyArray<CommandLineOption> =
|
||||
export const semanticDiagnosticsOptionDeclarations: readonly CommandLineOption[] =
|
||||
optionDeclarations.filter(option => !!option.affectsSemanticDiagnostics);
|
||||
|
||||
/* @internal */
|
||||
export const affectsEmitOptionDeclarations: ReadonlyArray<CommandLineOption> =
|
||||
export const affectsEmitOptionDeclarations: readonly CommandLineOption[] =
|
||||
optionDeclarations.filter(option => !!option.affectsEmit);
|
||||
|
||||
/* @internal */
|
||||
export const moduleResolutionOptionDeclarations: ReadonlyArray<CommandLineOption> =
|
||||
export const moduleResolutionOptionDeclarations: readonly CommandLineOption[] =
|
||||
optionDeclarations.filter(option => !!option.affectsModuleResolution);
|
||||
|
||||
/* @internal */
|
||||
export const sourceFileAffectingCompilerOptions: ReadonlyArray<CommandLineOption> = optionDeclarations.filter(option =>
|
||||
export const sourceFileAffectingCompilerOptions: readonly CommandLineOption[] = optionDeclarations.filter(option =>
|
||||
!!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics);
|
||||
|
||||
/* @internal */
|
||||
@@ -978,7 +978,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function createOptionNameMap(optionDeclarations: ReadonlyArray<CommandLineOption>): OptionNameMap {
|
||||
export function createOptionNameMap(optionDeclarations: readonly CommandLineOption[]): OptionNameMap {
|
||||
const optionNameMap = createMap<CommandLineOption>();
|
||||
const shortOptionNames = createMap<string>();
|
||||
forEach(optionDeclarations, option => {
|
||||
@@ -1036,7 +1036,7 @@ namespace ts {
|
||||
function parseCommandLineWorker(
|
||||
getOptionNameMap: () => OptionNameMap,
|
||||
[unknownOptionDiagnostic, optionTypeMismatchDiagnostic]: ParseCommandLineWorkerDiagnostics,
|
||||
commandLine: ReadonlyArray<string>,
|
||||
commandLine: readonly string[],
|
||||
readFile?: (path: string) => string | undefined) {
|
||||
const options = {} as OptionsBase;
|
||||
const fileNames: string[] = [];
|
||||
@@ -1049,7 +1049,7 @@ namespace ts {
|
||||
errors
|
||||
};
|
||||
|
||||
function parseStrings(args: ReadonlyArray<string>) {
|
||||
function parseStrings(args: readonly string[]) {
|
||||
let i = 0;
|
||||
while (i < args.length) {
|
||||
const s = args[i];
|
||||
@@ -1146,7 +1146,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function parseCommandLine(commandLine: ReadonlyArray<string>, readFile?: (path: string) => string | undefined): ParsedCommandLine {
|
||||
export function parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined): ParsedCommandLine {
|
||||
return parseCommandLineWorker(getOptionNameMap, [
|
||||
Diagnostics.Unknown_compiler_option_0,
|
||||
Diagnostics.Compiler_option_0_expects_an_argument
|
||||
@@ -1221,7 +1221,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function printHelp(optionsList: ReadonlyArray<CommandLineOption>, syntaxPrefix = "") {
|
||||
export function printHelp(optionsList: readonly CommandLineOption[], syntaxPrefix = "") {
|
||||
const output: string[] = [];
|
||||
|
||||
// We want to align our "syntax" and "examples" commands to a certain margin.
|
||||
@@ -1430,7 +1430,7 @@ namespace ts {
|
||||
return text === undefined ? createCompilerDiagnostic(Diagnostics.The_specified_path_does_not_exist_Colon_0, fileName) : text;
|
||||
}
|
||||
|
||||
function commandLineOptionsToMap(options: ReadonlyArray<CommandLineOption>) {
|
||||
function commandLineOptionsToMap(options: readonly CommandLineOption[]) {
|
||||
return arrayToMap(options, option => option.name);
|
||||
}
|
||||
|
||||
@@ -1747,10 +1747,10 @@ namespace ts {
|
||||
export interface TSConfig {
|
||||
compilerOptions: CompilerOptions;
|
||||
compileOnSave: boolean | undefined;
|
||||
exclude?: ReadonlyArray<string>;
|
||||
files: ReadonlyArray<string> | undefined;
|
||||
include?: ReadonlyArray<string>;
|
||||
references: ReadonlyArray<ProjectReference> | undefined;
|
||||
exclude?: readonly string[];
|
||||
files: readonly string[] | undefined;
|
||||
include?: readonly string[];
|
||||
references: readonly ProjectReference[] | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1799,14 +1799,14 @@ namespace ts {
|
||||
return config;
|
||||
}
|
||||
|
||||
function filterSameAsDefaultInclude(specs: ReadonlyArray<string> | undefined) {
|
||||
function filterSameAsDefaultInclude(specs: readonly string[] | undefined) {
|
||||
if (!length(specs)) return undefined;
|
||||
if (length(specs) !== 1) return specs;
|
||||
if (specs![0] === "**/*") return undefined;
|
||||
return specs;
|
||||
}
|
||||
|
||||
function matchesSpecs(path: string, includeSpecs: ReadonlyArray<string> | undefined, excludeSpecs: ReadonlyArray<string> | undefined): (path: string) => boolean {
|
||||
function matchesSpecs(path: string, includeSpecs: readonly string[] | undefined, excludeSpecs: readonly string[] | undefined): (path: string) => boolean {
|
||||
if (!includeSpecs) return _ => true;
|
||||
const patterns = getFileMatcherPatterns(path, excludeSpecs, includeSpecs, sys.useCaseSensitiveFileNames, sys.getCurrentDirectory());
|
||||
const excludeRe = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, sys.useCaseSensitiveFileNames);
|
||||
@@ -1873,7 +1873,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
if (optionDefinition.type === "list") {
|
||||
result.set(name, (value as ReadonlyArray<string | number>).map(element => getNameOfCompilerOptionValue(element, customTypeMap)!)); // TODO: GH#18217
|
||||
result.set(name, (value as readonly (string | number)[]).map(element => getNameOfCompilerOptionValue(element, customTypeMap)!)); // TODO: GH#18217
|
||||
}
|
||||
else {
|
||||
// There is a typeMap associated with this command-line option so use it to map value back to its name
|
||||
@@ -1892,7 +1892,7 @@ namespace ts {
|
||||
* @param fileNames array of filenames to be generated into tsconfig.json
|
||||
*/
|
||||
/* @internal */
|
||||
export function generateTSConfig(options: CompilerOptions, fileNames: ReadonlyArray<string>, newLine: string): string {
|
||||
export function generateTSConfig(options: CompilerOptions, fileNames: readonly string[], newLine: string): string {
|
||||
const compilerOptions = extend(options, defaultInitCompilerOptions);
|
||||
const compilerOptionsMap = serializeCompilerOptions(compilerOptions);
|
||||
return writeConfigurations();
|
||||
@@ -2000,7 +2000,7 @@ namespace ts {
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray<FileExtensionInfo>, extendedConfigCache?: Map<ExtendedConfigCacheEntry>): ParsedCommandLine {
|
||||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map<ExtendedConfigCacheEntry>): ParsedCommandLine {
|
||||
return parseJsonConfigFileContentWorker(json, /*sourceFile*/ undefined, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
|
||||
}
|
||||
|
||||
@@ -2011,7 +2011,7 @@ namespace ts {
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray<FileExtensionInfo>, extendedConfigCache?: Map<ExtendedConfigCacheEntry>): ParsedCommandLine {
|
||||
export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map<ExtendedConfigCacheEntry>): ParsedCommandLine {
|
||||
return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
|
||||
}
|
||||
|
||||
@@ -2049,7 +2049,7 @@ namespace ts {
|
||||
existingOptions: CompilerOptions = {},
|
||||
configFileName?: string,
|
||||
resolutionStack: Path[] = [],
|
||||
extraFileExtensions: ReadonlyArray<FileExtensionInfo> = [],
|
||||
extraFileExtensions: readonly FileExtensionInfo[] = [],
|
||||
extendedConfigCache?: Map<ExtendedConfigCacheEntry>
|
||||
): ParsedCommandLine {
|
||||
Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined));
|
||||
@@ -2075,10 +2075,10 @@ namespace ts {
|
||||
};
|
||||
|
||||
function getFileNames(): ExpandResult {
|
||||
let filesSpecs: ReadonlyArray<string> | undefined;
|
||||
let filesSpecs: readonly string[] | undefined;
|
||||
if (hasProperty(raw, "files") && !isNullOrUndefined(raw.files)) {
|
||||
if (isArray(raw.files)) {
|
||||
filesSpecs = <ReadonlyArray<string>>raw.files;
|
||||
filesSpecs = <readonly string[]>raw.files;
|
||||
const hasReferences = hasProperty(raw, "references") && !isNullOrUndefined(raw.references);
|
||||
const hasZeroOrNoReferences = !hasReferences || raw.references.length === 0;
|
||||
const hasExtends = hasProperty(raw, "extends");
|
||||
@@ -2102,20 +2102,20 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
let includeSpecs: ReadonlyArray<string> | undefined;
|
||||
let includeSpecs: readonly string[] | undefined;
|
||||
if (hasProperty(raw, "include") && !isNullOrUndefined(raw.include)) {
|
||||
if (isArray(raw.include)) {
|
||||
includeSpecs = <ReadonlyArray<string>>raw.include;
|
||||
includeSpecs = <readonly string[]>raw.include;
|
||||
}
|
||||
else {
|
||||
createCompilerDiagnosticOnlyIfJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array");
|
||||
}
|
||||
}
|
||||
|
||||
let excludeSpecs: ReadonlyArray<string> | undefined;
|
||||
let excludeSpecs: readonly string[] | undefined;
|
||||
if (hasProperty(raw, "exclude") && !isNullOrUndefined(raw.exclude)) {
|
||||
if (isArray(raw.exclude)) {
|
||||
excludeSpecs = <ReadonlyArray<string>>raw.exclude;
|
||||
excludeSpecs = <readonly string[]>raw.exclude;
|
||||
}
|
||||
else {
|
||||
createCompilerDiagnosticOnlyIfJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array");
|
||||
@@ -2503,7 +2503,7 @@ namespace ts {
|
||||
return options;
|
||||
}
|
||||
|
||||
function convertOptionsFromJson(optionDeclarations: ReadonlyArray<CommandLineOption>, jsonOptions: any, basePath: string,
|
||||
function convertOptionsFromJson(optionDeclarations: readonly CommandLineOption[], jsonOptions: any, basePath: string,
|
||||
defaultOptions: CompilerOptions | TypeAcquisition, diagnosticMessage: DiagnosticMessage, errors: Push<Diagnostic>) {
|
||||
|
||||
if (!jsonOptions) {
|
||||
@@ -2576,7 +2576,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function convertJsonOptionOfListType(option: CommandLineOptionOfListType, values: ReadonlyArray<any>, basePath: string, errors: Push<Diagnostic>): any[] {
|
||||
function convertJsonOptionOfListType(option: CommandLineOptionOfListType, values: readonly any[], basePath: string, errors: Push<Diagnostic>): any[] {
|
||||
return filter(map(values, v => convertJsonOption(option.element, v, basePath, errors)), v => !!v);
|
||||
}
|
||||
|
||||
@@ -2653,18 +2653,18 @@ namespace ts {
|
||||
* @param errors An array for diagnostic reporting.
|
||||
*/
|
||||
function matchFileNames(
|
||||
filesSpecs: ReadonlyArray<string> | undefined,
|
||||
includeSpecs: ReadonlyArray<string> | undefined,
|
||||
excludeSpecs: ReadonlyArray<string> | undefined,
|
||||
filesSpecs: readonly string[] | undefined,
|
||||
includeSpecs: readonly string[] | undefined,
|
||||
excludeSpecs: readonly string[] | undefined,
|
||||
basePath: string,
|
||||
options: CompilerOptions,
|
||||
host: ParseConfigHost,
|
||||
errors: Push<Diagnostic>,
|
||||
extraFileExtensions: ReadonlyArray<FileExtensionInfo>,
|
||||
extraFileExtensions: readonly FileExtensionInfo[],
|
||||
jsonSourceFile: TsConfigSourceFile | undefined
|
||||
): ExpandResult {
|
||||
basePath = normalizePath(basePath);
|
||||
let validatedIncludeSpecs: ReadonlyArray<string> | undefined, validatedExcludeSpecs: ReadonlyArray<string> | undefined;
|
||||
let validatedIncludeSpecs: readonly string[] | undefined, validatedExcludeSpecs: readonly string[] | undefined;
|
||||
|
||||
// The exclude spec list is converted into a regular expression, which allows us to quickly
|
||||
// test whether a file or directory should be excluded before recursively traversing the
|
||||
@@ -2698,7 +2698,7 @@ namespace ts {
|
||||
* @param extraFileExtensions optionaly file extra file extension information from host
|
||||
*/
|
||||
/* @internal */
|
||||
export function getFileNamesFromConfigSpecs(spec: ConfigFileSpecs, basePath: string, options: CompilerOptions, host: ParseConfigHost, extraFileExtensions: ReadonlyArray<FileExtensionInfo> = []): ExpandResult {
|
||||
export function getFileNamesFromConfigSpecs(spec: ConfigFileSpecs, basePath: string, options: CompilerOptions, host: ParseConfigHost, extraFileExtensions: readonly FileExtensionInfo[] = []): ExpandResult {
|
||||
basePath = normalizePath(basePath);
|
||||
|
||||
const keyMapper = host.useCaseSensitiveFileNames ? identity : toLowerCase;
|
||||
@@ -2733,7 +2733,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
let jsonOnlyIncludeRegexes: ReadonlyArray<RegExp> | undefined;
|
||||
let jsonOnlyIncludeRegexes: readonly RegExp[] | undefined;
|
||||
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
|
||||
for (const file of host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined)) {
|
||||
if (fileExtensionIs(file, Extension.Json)) {
|
||||
@@ -2785,7 +2785,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function validateSpecs(specs: ReadonlyArray<string>, errors: Push<Diagnostic>, allowTrailingRecursion: boolean, jsonSourceFile: TsConfigSourceFile | undefined, specKey: string): ReadonlyArray<string> {
|
||||
function validateSpecs(specs: readonly string[], errors: Push<Diagnostic>, allowTrailingRecursion: boolean, jsonSourceFile: TsConfigSourceFile | undefined, specKey: string): readonly string[] {
|
||||
return specs.filter(spec => {
|
||||
const diag = specToDiagnostic(spec, allowTrailingRecursion);
|
||||
if (diag !== undefined) {
|
||||
@@ -2814,7 +2814,7 @@ namespace ts {
|
||||
/**
|
||||
* Gets directories in a set of include patterns that should be watched for changes.
|
||||
*/
|
||||
function getWildcardDirectories(include: ReadonlyArray<string> | undefined, exclude: ReadonlyArray<string> | undefined, path: string, useCaseSensitiveFileNames: boolean): MapLike<WatchDirectoryFlags> {
|
||||
function getWildcardDirectories(include: readonly string[] | undefined, exclude: readonly string[] | undefined, path: string, useCaseSensitiveFileNames: boolean): MapLike<WatchDirectoryFlags> {
|
||||
// We watch a directory recursively if it contains a wildcard anywhere in a directory segment
|
||||
// of the pattern:
|
||||
//
|
||||
@@ -2888,7 +2888,7 @@ namespace ts {
|
||||
* @param extensionPriority The priority of the extension.
|
||||
* @param context The expansion context.
|
||||
*/
|
||||
function hasFileWithHigherPriorityExtension(file: string, literalFiles: Map<string>, wildcardFiles: Map<string>, extensions: ReadonlyArray<string>, keyMapper: (value: string) => string) {
|
||||
function hasFileWithHigherPriorityExtension(file: string, literalFiles: Map<string>, wildcardFiles: Map<string>, extensions: readonly string[], keyMapper: (value: string) => string) {
|
||||
const extensionPriority = getExtensionPriority(file, extensions);
|
||||
const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority, extensions);
|
||||
for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) {
|
||||
@@ -2910,7 +2910,7 @@ namespace ts {
|
||||
* @param extensionPriority The priority of the extension.
|
||||
* @param context The expansion context.
|
||||
*/
|
||||
function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: Map<string>, extensions: ReadonlyArray<string>, keyMapper: (value: string) => string) {
|
||||
function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: Map<string>, extensions: readonly string[], keyMapper: (value: string) => string) {
|
||||
const extensionPriority = getExtensionPriority(file, extensions);
|
||||
const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority, extensions);
|
||||
for (let i = nextExtensionPriority; i < extensions.length; i++) {
|
||||
|
||||
+99
-99
@@ -310,7 +310,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function length(array: ReadonlyArray<any> | undefined): number {
|
||||
export function length(array: readonly any[] | undefined): number {
|
||||
return array ? array.length : 0;
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ namespace ts {
|
||||
* returns a truthy value, then returns that value.
|
||||
* If no such value is found, the callback is applied to each element of array and undefined is returned.
|
||||
*/
|
||||
export function forEach<T, U>(array: ReadonlyArray<T> | undefined, callback: (element: T, index: number) => U | undefined): U | undefined {
|
||||
export function forEach<T, U>(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined {
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const result = callback(array[i], i);
|
||||
@@ -332,7 +332,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */
|
||||
export function firstDefined<T, U>(array: ReadonlyArray<T> | undefined, callback: (element: T, index: number) => U | undefined): U | undefined {
|
||||
export function firstDefined<T, U>(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined {
|
||||
if (array === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function zipWith<T, U, V>(arrayA: ReadonlyArray<T>, arrayB: ReadonlyArray<U>, callback: (a: T, b: U, index: number) => V): V[] {
|
||||
export function zipWith<T, U, V>(arrayA: readonly T[], arrayB: readonly U[], callback: (a: T, b: U, index: number) => V): V[] {
|
||||
const result: V[] = [];
|
||||
Debug.assertEqual(arrayA.length, arrayB.length);
|
||||
for (let i = 0; i < arrayA.length; i++) {
|
||||
@@ -368,7 +368,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function zipToIterator<T, U>(arrayA: ReadonlyArray<T>, arrayB: ReadonlyArray<U>): Iterator<[T, U]> {
|
||||
export function zipToIterator<T, U>(arrayA: readonly T[], arrayB: readonly U[]): Iterator<[T, U]> {
|
||||
Debug.assertEqual(arrayA.length, arrayB.length);
|
||||
let i = 0;
|
||||
return {
|
||||
@@ -382,7 +382,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function zipToMap<T>(keys: ReadonlyArray<string>, values: ReadonlyArray<T>): Map<T> {
|
||||
export function zipToMap<T>(keys: readonly string[], values: readonly T[]): Map<T> {
|
||||
Debug.assert(keys.length === values.length);
|
||||
const map = createMap<T>();
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
@@ -396,7 +396,7 @@ namespace ts {
|
||||
* returns a falsey value, then returns false.
|
||||
* If no such value is found, the callback is applied to each element of array and `true` is returned.
|
||||
*/
|
||||
export function every<T>(array: ReadonlyArray<T>, callback: (element: T, index: number) => boolean): boolean {
|
||||
export function every<T>(array: readonly T[], callback: (element: T, index: number) => boolean): boolean {
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (!callback(array[i], i)) {
|
||||
@@ -409,9 +409,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */
|
||||
export function find<T, U extends T>(array: ReadonlyArray<T>, predicate: (element: T, index: number) => element is U): U | undefined;
|
||||
export function find<T>(array: ReadonlyArray<T>, predicate: (element: T, index: number) => boolean): T | undefined;
|
||||
export function find<T>(array: ReadonlyArray<T>, predicate: (element: T, index: number) => boolean): T | undefined {
|
||||
export function find<T, U extends T>(array: readonly T[], predicate: (element: T, index: number) => element is U): U | undefined;
|
||||
export function find<T>(array: readonly T[], predicate: (element: T, index: number) => boolean): T | undefined;
|
||||
export function find<T>(array: readonly T[], predicate: (element: T, index: number) => boolean): T | undefined {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const value = array[i];
|
||||
if (predicate(value, i)) {
|
||||
@@ -421,9 +421,9 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function findLast<T, U extends T>(array: ReadonlyArray<T>, predicate: (element: T, index: number) => element is U): U | undefined;
|
||||
export function findLast<T>(array: ReadonlyArray<T>, predicate: (element: T, index: number) => boolean): T | undefined;
|
||||
export function findLast<T>(array: ReadonlyArray<T>, predicate: (element: T, index: number) => boolean): T | undefined {
|
||||
export function findLast<T, U extends T>(array: readonly T[], predicate: (element: T, index: number) => element is U): U | undefined;
|
||||
export function findLast<T>(array: readonly T[], predicate: (element: T, index: number) => boolean): T | undefined;
|
||||
export function findLast<T>(array: readonly T[], predicate: (element: T, index: number) => boolean): T | undefined {
|
||||
for (let i = array.length - 1; i >= 0; i--) {
|
||||
const value = array[i];
|
||||
if (predicate(value, i)) {
|
||||
@@ -434,7 +434,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */
|
||||
export function findIndex<T>(array: ReadonlyArray<T>, predicate: (element: T, index: number) => boolean, startIndex?: number): number {
|
||||
export function findIndex<T>(array: readonly T[], predicate: (element: T, index: number) => boolean, startIndex?: number): number {
|
||||
for (let i = startIndex || 0; i < array.length; i++) {
|
||||
if (predicate(array[i], i)) {
|
||||
return i;
|
||||
@@ -443,7 +443,7 @@ namespace ts {
|
||||
return -1;
|
||||
}
|
||||
|
||||
export function findLastIndex<T>(array: ReadonlyArray<T>, predicate: (element: T, index: number) => boolean, startIndex?: number): number {
|
||||
export function findLastIndex<T>(array: readonly T[], predicate: (element: T, index: number) => boolean, startIndex?: number): number {
|
||||
for (let i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
|
||||
if (predicate(array[i], i)) {
|
||||
return i;
|
||||
@@ -456,7 +456,7 @@ namespace ts {
|
||||
* Returns the first truthy result of `callback`, or else fails.
|
||||
* This is like `forEach`, but never returns undefined.
|
||||
*/
|
||||
export function findMap<T, U>(array: ReadonlyArray<T>, callback: (element: T, index: number) => U | undefined): U {
|
||||
export function findMap<T, U>(array: readonly T[], callback: (element: T, index: number) => U | undefined): U {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const result = callback(array[i], i);
|
||||
if (result) {
|
||||
@@ -466,7 +466,7 @@ namespace ts {
|
||||
return Debug.fail();
|
||||
}
|
||||
|
||||
export function contains<T>(array: ReadonlyArray<T> | undefined, value: T, equalityComparer: EqualityComparer<T> = equateValues): boolean {
|
||||
export function contains<T>(array: readonly T[] | undefined, value: T, equalityComparer: EqualityComparer<T> = equateValues): boolean {
|
||||
if (array) {
|
||||
for (const v of array) {
|
||||
if (equalityComparer(v, value)) {
|
||||
@@ -477,11 +477,11 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function arraysEqual<T>(a: ReadonlyArray<T>, b: ReadonlyArray<T>, equalityComparer: EqualityComparer<T> = equateValues): boolean {
|
||||
export function arraysEqual<T>(a: readonly T[], b: readonly T[], equalityComparer: EqualityComparer<T> = equateValues): boolean {
|
||||
return a.length === b.length && a.every((x, i) => equalityComparer(x, b[i]));
|
||||
}
|
||||
|
||||
export function indexOfAnyCharCode(text: string, charCodes: ReadonlyArray<number>, start?: number): number {
|
||||
export function indexOfAnyCharCode(text: string, charCodes: readonly number[], start?: number): number {
|
||||
for (let i = start || 0; i < text.length; i++) {
|
||||
if (contains(charCodes, text.charCodeAt(i))) {
|
||||
return i;
|
||||
@@ -490,7 +490,7 @@ namespace ts {
|
||||
return -1;
|
||||
}
|
||||
|
||||
export function countWhere<T>(array: ReadonlyArray<T>, predicate: (x: T, i: number) => boolean): number {
|
||||
export function countWhere<T>(array: readonly T[], predicate: (x: T, i: number) => boolean): number {
|
||||
let count = 0;
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
@@ -509,13 +509,13 @@ namespace ts {
|
||||
*/
|
||||
export function filter<T, U extends T>(array: T[], f: (x: T) => x is U): U[];
|
||||
export function filter<T>(array: T[], f: (x: T) => boolean): T[];
|
||||
export function filter<T, U extends T>(array: ReadonlyArray<T>, f: (x: T) => x is U): ReadonlyArray<U>;
|
||||
export function filter<T, U extends T>(array: ReadonlyArray<T>, f: (x: T) => boolean): ReadonlyArray<T>;
|
||||
export function filter<T, U extends T>(array: readonly T[], f: (x: T) => x is U): readonly U[];
|
||||
export function filter<T, U extends T>(array: readonly T[], f: (x: T) => boolean): readonly T[];
|
||||
export function filter<T, U extends T>(array: T[] | undefined, f: (x: T) => x is U): U[] | undefined;
|
||||
export function filter<T>(array: T[] | undefined, f: (x: T) => boolean): T[] | undefined;
|
||||
export function filter<T, U extends T>(array: ReadonlyArray<T> | undefined, f: (x: T) => x is U): ReadonlyArray<U> | undefined;
|
||||
export function filter<T, U extends T>(array: ReadonlyArray<T> | undefined, f: (x: T) => boolean): ReadonlyArray<T> | undefined;
|
||||
export function filter<T>(array: ReadonlyArray<T> | undefined, f: (x: T) => boolean): ReadonlyArray<T> | undefined {
|
||||
export function filter<T, U extends T>(array: readonly T[] | undefined, f: (x: T) => x is U): readonly U[] | undefined;
|
||||
export function filter<T, U extends T>(array: readonly T[] | undefined, f: (x: T) => boolean): readonly T[] | undefined;
|
||||
export function filter<T>(array: readonly T[] | undefined, f: (x: T) => boolean): readonly T[] | undefined {
|
||||
if (array) {
|
||||
const len = array.length;
|
||||
let i = 0;
|
||||
@@ -551,9 +551,9 @@ namespace ts {
|
||||
array.length = 0;
|
||||
}
|
||||
|
||||
export function map<T, U>(array: ReadonlyArray<T>, f: (x: T, i: number) => U): U[];
|
||||
export function map<T, U>(array: ReadonlyArray<T> | undefined, f: (x: T, i: number) => U): U[] | undefined;
|
||||
export function map<T, U>(array: ReadonlyArray<T> | undefined, f: (x: T, i: number) => U): U[] | undefined {
|
||||
export function map<T, U>(array: readonly T[], f: (x: T, i: number) => U): U[];
|
||||
export function map<T, U>(array: readonly T[] | undefined, f: (x: T, i: number) => U): U[] | undefined;
|
||||
export function map<T, U>(array: readonly T[] | undefined, f: (x: T, i: number) => U): U[] | undefined {
|
||||
let result: U[] | undefined;
|
||||
if (array) {
|
||||
result = [];
|
||||
@@ -576,10 +576,10 @@ namespace ts {
|
||||
|
||||
// Maps from T to T and avoids allocation if all elements map to themselves
|
||||
export function sameMap<T>(array: T[], f: (x: T, i: number) => T): T[];
|
||||
export function sameMap<T>(array: ReadonlyArray<T>, f: (x: T, i: number) => T): ReadonlyArray<T>;
|
||||
export function sameMap<T>(array: readonly T[], f: (x: T, i: number) => T): readonly T[];
|
||||
export function sameMap<T>(array: T[] | undefined, f: (x: T, i: number) => T): T[] | undefined;
|
||||
export function sameMap<T>(array: ReadonlyArray<T> | undefined, f: (x: T, i: number) => T): ReadonlyArray<T> | undefined;
|
||||
export function sameMap<T>(array: ReadonlyArray<T> | undefined, f: (x: T, i: number) => T): ReadonlyArray<T> | undefined {
|
||||
export function sameMap<T>(array: readonly T[] | undefined, f: (x: T, i: number) => T): readonly T[] | undefined;
|
||||
export function sameMap<T>(array: readonly T[] | undefined, f: (x: T, i: number) => T): readonly T[] | undefined {
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const item = array[i];
|
||||
@@ -602,7 +602,7 @@ namespace ts {
|
||||
*
|
||||
* @param array The array to flatten.
|
||||
*/
|
||||
export function flatten<T>(array: T[][] | ReadonlyArray<T | ReadonlyArray<T> | undefined>): T[] {
|
||||
export function flatten<T>(array: T[][] | readonly (T | readonly T[] | undefined)[]): T[] {
|
||||
const result = [];
|
||||
for (const v of array) {
|
||||
if (v) {
|
||||
@@ -623,7 +623,7 @@ namespace ts {
|
||||
* @param array The array to map.
|
||||
* @param mapfn The callback used to map the result into one or more values.
|
||||
*/
|
||||
export function flatMap<T, U>(array: ReadonlyArray<T> | undefined, mapfn: (x: T, i: number) => U | ReadonlyArray<U> | undefined): ReadonlyArray<U> {
|
||||
export function flatMap<T, U>(array: readonly T[] | undefined, mapfn: (x: T, i: number) => U | readonly U[] | undefined): readonly U[] {
|
||||
let result: U[] | undefined;
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
@@ -641,7 +641,7 @@ namespace ts {
|
||||
return result || emptyArray;
|
||||
}
|
||||
|
||||
export function flatMapToMutable<T, U>(array: ReadonlyArray<T> | undefined, mapfn: (x: T, i: number) => U | ReadonlyArray<U> | undefined): U[] {
|
||||
export function flatMapToMutable<T, U>(array: readonly T[] | undefined, mapfn: (x: T, i: number) => U | readonly U[] | undefined): U[] {
|
||||
const result: U[] = [];
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
@@ -659,7 +659,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function flatMapIterator<T, U>(iter: Iterator<T>, mapfn: (x: T) => ReadonlyArray<U> | Iterator<U> | undefined): Iterator<U> {
|
||||
export function flatMapIterator<T, U>(iter: Iterator<T>, mapfn: (x: T) => readonly U[] | Iterator<U> | undefined): Iterator<U> {
|
||||
const first = iter.next();
|
||||
if (first.done) {
|
||||
return emptyIterator;
|
||||
@@ -694,8 +694,8 @@ namespace ts {
|
||||
* @param array The array to map.
|
||||
* @param mapfn The callback used to map the result into one or more values.
|
||||
*/
|
||||
export function sameFlatMap<T>(array: T[], mapfn: (x: T, i: number) => T | ReadonlyArray<T>): T[];
|
||||
export function sameFlatMap<T>(array: ReadonlyArray<T>, mapfn: (x: T, i: number) => T | ReadonlyArray<T>): ReadonlyArray<T>;
|
||||
export function sameFlatMap<T>(array: T[], mapfn: (x: T, i: number) => T | readonly T[]): T[];
|
||||
export function sameFlatMap<T>(array: readonly T[], mapfn: (x: T, i: number) => T | readonly T[]): readonly T[];
|
||||
export function sameFlatMap<T>(array: T[], mapfn: (x: T, i: number) => T | T[]): T[] {
|
||||
let result: T[] | undefined;
|
||||
if (array) {
|
||||
@@ -718,7 +718,7 @@ namespace ts {
|
||||
return result || array;
|
||||
}
|
||||
|
||||
export function mapAllOrFail<T, U>(array: ReadonlyArray<T>, mapFn: (x: T, i: number) => U | undefined): U[] | undefined {
|
||||
export function mapAllOrFail<T, U>(array: readonly T[], mapFn: (x: T, i: number) => U | undefined): U[] | undefined {
|
||||
const result: U[] = [];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const mapped = mapFn(array[i], i);
|
||||
@@ -730,7 +730,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapDefined<T, U>(array: ReadonlyArray<T> | undefined, mapFn: (x: T, i: number) => U | undefined): U[] {
|
||||
export function mapDefined<T, U>(array: readonly T[] | undefined, mapFn: (x: T, i: number) => U | undefined): U[] {
|
||||
const result: U[] = [];
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
@@ -780,9 +780,9 @@ namespace ts {
|
||||
* @param keyfn A callback used to select the key for an element.
|
||||
* @param mapfn A callback used to map a contiguous chunk of values to a single value.
|
||||
*/
|
||||
export function spanMap<T, K, U>(array: ReadonlyArray<T>, keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[];
|
||||
export function spanMap<T, K, U>(array: ReadonlyArray<T> | undefined, keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[] | undefined;
|
||||
export function spanMap<T, K, U>(array: ReadonlyArray<T> | undefined, keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[] | undefined {
|
||||
export function spanMap<T, K, U>(array: readonly T[], keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[];
|
||||
export function spanMap<T, K, U>(array: readonly T[] | undefined, keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[] | undefined;
|
||||
export function spanMap<T, K, U>(array: readonly T[] | undefined, keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[] | undefined {
|
||||
let result: U[] | undefined;
|
||||
if (array) {
|
||||
result = [];
|
||||
@@ -836,9 +836,9 @@ namespace ts {
|
||||
});
|
||||
return result;
|
||||
}
|
||||
export function some<T>(array: ReadonlyArray<T> | undefined): array is ReadonlyArray<T>;
|
||||
export function some<T>(array: ReadonlyArray<T> | undefined, predicate: (value: T) => boolean): boolean;
|
||||
export function some<T>(array: ReadonlyArray<T> | undefined, predicate?: (value: T) => boolean): boolean {
|
||||
export function some<T>(array: readonly T[] | undefined): array is readonly T[];
|
||||
export function some<T>(array: readonly T[] | undefined, predicate: (value: T) => boolean): boolean;
|
||||
export function some<T>(array: readonly T[] | undefined, predicate?: (value: T) => boolean): boolean {
|
||||
if (array) {
|
||||
if (predicate) {
|
||||
for (const v of array) {
|
||||
@@ -855,7 +855,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Calls the callback with (start, afterEnd) index pairs for each range where 'pred' is true. */
|
||||
export function getRangesWhere<T>(arr: ReadonlyArray<T>, pred: (t: T) => boolean, cb: (start: number, afterEnd: number) => void): void {
|
||||
export function getRangesWhere<T>(arr: readonly T[], pred: (t: T) => boolean, cb: (start: number, afterEnd: number) => void): void {
|
||||
let start: number | undefined;
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (pred(arr[i])) {
|
||||
@@ -872,16 +872,16 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function concatenate<T>(array1: T[], array2: T[]): T[];
|
||||
export function concatenate<T>(array1: ReadonlyArray<T>, array2: ReadonlyArray<T>): ReadonlyArray<T>;
|
||||
export function concatenate<T>(array1: readonly T[], array2: readonly T[]): readonly T[];
|
||||
export function concatenate<T>(array1: T[] | undefined, array2: T[] | undefined): T[];
|
||||
export function concatenate<T>(array1: ReadonlyArray<T> | undefined, array2: ReadonlyArray<T> | undefined): ReadonlyArray<T>;
|
||||
export function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined): readonly T[];
|
||||
export function concatenate<T>(array1: T[], array2: T[]): T[] {
|
||||
if (!some(array2)) return array1;
|
||||
if (!some(array1)) return array2;
|
||||
return [...array1, ...array2];
|
||||
}
|
||||
|
||||
function deduplicateRelational<T>(array: ReadonlyArray<T>, equalityComparer: EqualityComparer<T>, comparer: Comparer<T>) {
|
||||
function deduplicateRelational<T>(array: readonly T[], equalityComparer: EqualityComparer<T>, comparer: Comparer<T>) {
|
||||
// Perform a stable sort of the array. This ensures the first entry in a list of
|
||||
// duplicates remains the first entry in the result.
|
||||
const indices = array.map((_, i) => i);
|
||||
@@ -903,7 +903,7 @@ namespace ts {
|
||||
return deduplicated.map(i => array[i]);
|
||||
}
|
||||
|
||||
function deduplicateEquality<T>(array: ReadonlyArray<T>, equalityComparer: EqualityComparer<T>) {
|
||||
function deduplicateEquality<T>(array: readonly T[], equalityComparer: EqualityComparer<T>) {
|
||||
const result: T[] = [];
|
||||
for (const item of array) {
|
||||
pushIfUnique(result, item, equalityComparer);
|
||||
@@ -917,7 +917,7 @@ namespace ts {
|
||||
* @param comparer An optional `Comparer` used to sort entries before comparison, though the
|
||||
* result will remain in the original order in `array`.
|
||||
*/
|
||||
export function deduplicate<T>(array: ReadonlyArray<T>, equalityComparer: EqualityComparer<T>, comparer?: Comparer<T>): T[] {
|
||||
export function deduplicate<T>(array: readonly T[], equalityComparer: EqualityComparer<T>, comparer?: Comparer<T>): T[] {
|
||||
return array.length === 0 ? [] :
|
||||
array.length === 1 ? array.slice() :
|
||||
comparer ? deduplicateRelational(array, equalityComparer, comparer) :
|
||||
@@ -966,13 +966,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function sortAndDeduplicate<T>(array: ReadonlyArray<string>): SortedReadonlyArray<string>;
|
||||
export function sortAndDeduplicate<T>(array: ReadonlyArray<T>, comparer: Comparer<T>, equalityComparer?: EqualityComparer<T>): SortedReadonlyArray<T>;
|
||||
export function sortAndDeduplicate<T>(array: ReadonlyArray<T>, comparer?: Comparer<T>, equalityComparer?: EqualityComparer<T>): SortedReadonlyArray<T> {
|
||||
export function sortAndDeduplicate<T>(array: readonly string[]): SortedReadonlyArray<string>;
|
||||
export function sortAndDeduplicate<T>(array: readonly T[], comparer: Comparer<T>, equalityComparer?: EqualityComparer<T>): SortedReadonlyArray<T>;
|
||||
export function sortAndDeduplicate<T>(array: readonly T[], comparer?: Comparer<T>, equalityComparer?: EqualityComparer<T>): SortedReadonlyArray<T> {
|
||||
return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive as any as Comparer<T>);
|
||||
}
|
||||
|
||||
export function arrayIsEqualTo<T>(array1: ReadonlyArray<T> | undefined, array2: ReadonlyArray<T> | undefined, equalityComparer: (a: T, b: T, index: number) => boolean = equateValues): boolean {
|
||||
export function arrayIsEqualTo<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined, equalityComparer: (a: T, b: T, index: number) => boolean = equateValues): boolean {
|
||||
if (!array1 || !array2) {
|
||||
return array1 === array2;
|
||||
}
|
||||
@@ -994,10 +994,10 @@ namespace ts {
|
||||
* Compacts an array, removing any falsey elements.
|
||||
*/
|
||||
export function compact<T>(array: (T | undefined | null | false | 0 | "")[]): T[];
|
||||
export function compact<T>(array: ReadonlyArray<T | undefined | null | false | 0 | "">): ReadonlyArray<T>;
|
||||
export function compact<T>(array: readonly (T | undefined | null | false | 0 | "")[]): readonly T[];
|
||||
// TSLint thinks these can be combined with the above - they cannot; they'd produce higher-priority inferences and prevent the falsey types from being stripped
|
||||
export function compact<T>(array: T[]): T[];
|
||||
export function compact<T>(array: ReadonlyArray<T>): ReadonlyArray<T>;
|
||||
export function compact<T>(array: readonly T[]): readonly T[];
|
||||
export function compact<T>(array: T[]): T[] {
|
||||
let result: T[] | undefined;
|
||||
if (array) {
|
||||
@@ -1059,7 +1059,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function sum<T extends Record<K, number>, K extends string>(array: ReadonlyArray<T>, prop: K): number {
|
||||
export function sum<T extends Record<K, number>, K extends string>(array: readonly T[], prop: K): number {
|
||||
let result = 0;
|
||||
for (const v of array) {
|
||||
result += v[prop];
|
||||
@@ -1091,7 +1091,7 @@ namespace ts {
|
||||
* Gets the actual offset into an array for a relative offset. Negative offsets indicate a
|
||||
* position offset from the end of the array.
|
||||
*/
|
||||
function toOffset(array: ReadonlyArray<any>, offset: number) {
|
||||
function toOffset(array: readonly any[], offset: number) {
|
||||
return offset < 0 ? array.length + offset : offset;
|
||||
}
|
||||
|
||||
@@ -1105,9 +1105,9 @@ namespace ts {
|
||||
* @param start The offset in `from` at which to start copying values.
|
||||
* @param end The offset in `from` at which to stop copying values (non-inclusive).
|
||||
*/
|
||||
export function addRange<T>(to: T[], from: ReadonlyArray<T> | undefined, start?: number, end?: number): T[];
|
||||
export function addRange<T>(to: T[] | undefined, from: ReadonlyArray<T> | undefined, start?: number, end?: number): T[] | undefined;
|
||||
export function addRange<T>(to: T[] | undefined, from: ReadonlyArray<T> | undefined, start?: number, end?: number): T[] | undefined {
|
||||
export function addRange<T>(to: T[], from: readonly T[] | undefined, start?: number, end?: number): T[];
|
||||
export function addRange<T>(to: T[] | undefined, from: readonly T[] | undefined, start?: number, end?: number): T[] | undefined;
|
||||
export function addRange<T>(to: T[] | undefined, from: readonly T[] | undefined, start?: number, end?: number): T[] | undefined {
|
||||
if (from === undefined || from.length === 0) return to;
|
||||
if (to === undefined) return from.slice(start, end);
|
||||
start = start === undefined ? 0 : toOffset(from, start);
|
||||
@@ -1146,7 +1146,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function stableSortIndices<T>(array: ReadonlyArray<T>, indices: number[], comparer: Comparer<T>) {
|
||||
function stableSortIndices<T>(array: readonly T[], indices: number[], comparer: Comparer<T>) {
|
||||
// sort indices by value then position
|
||||
indices.sort((x, y) => comparer(array[x], array[y]) || compareValues(x, y));
|
||||
}
|
||||
@@ -1154,11 +1154,11 @@ namespace ts {
|
||||
/**
|
||||
* Returns a new sorted array.
|
||||
*/
|
||||
export function sort<T>(array: ReadonlyArray<T>, comparer?: Comparer<T>): SortedReadonlyArray<T> {
|
||||
export function sort<T>(array: readonly T[], comparer?: Comparer<T>): SortedReadonlyArray<T> {
|
||||
return (array.length === 0 ? array : array.slice().sort(comparer)) as SortedReadonlyArray<T>;
|
||||
}
|
||||
|
||||
export function arrayIterator<T>(array: ReadonlyArray<T>): Iterator<T> {
|
||||
export function arrayIterator<T>(array: readonly T[]): Iterator<T> {
|
||||
let i = 0;
|
||||
return { next: () => {
|
||||
if (i === array.length) {
|
||||
@@ -1171,7 +1171,7 @@ namespace ts {
|
||||
}};
|
||||
}
|
||||
|
||||
export function arrayReverseIterator<T>(array: ReadonlyArray<T>): Iterator<T> {
|
||||
export function arrayReverseIterator<T>(array: readonly T[]): Iterator<T> {
|
||||
let i = array.length;
|
||||
return {
|
||||
next: () => {
|
||||
@@ -1189,13 +1189,13 @@ namespace ts {
|
||||
/**
|
||||
* Stable sort of an array. Elements equal to each other maintain their relative position in the array.
|
||||
*/
|
||||
export function stableSort<T>(array: ReadonlyArray<T>, comparer: Comparer<T>): SortedReadonlyArray<T> {
|
||||
export function stableSort<T>(array: readonly T[], comparer: Comparer<T>): SortedReadonlyArray<T> {
|
||||
const indices = array.map((_, i) => i);
|
||||
stableSortIndices(array, indices, comparer);
|
||||
return indices.map(i => array[i]) as SortedArray<T> as SortedReadonlyArray<T>;
|
||||
}
|
||||
|
||||
export function rangeEquals<T>(array1: ReadonlyArray<T>, array2: ReadonlyArray<T>, pos: number, end: number) {
|
||||
export function rangeEquals<T>(array1: readonly T[], array2: readonly T[], pos: number, end: number) {
|
||||
while (pos < end) {
|
||||
if (array1[pos] !== array2[pos]) {
|
||||
return false;
|
||||
@@ -1209,7 +1209,7 @@ namespace ts {
|
||||
* Returns the element at a specific offset in an array if non-empty, `undefined` otherwise.
|
||||
* A negative offset indicates the element should be retrieved from the end of the array.
|
||||
*/
|
||||
export function elementAt<T>(array: ReadonlyArray<T> | undefined, offset: number): T | undefined {
|
||||
export function elementAt<T>(array: readonly T[] | undefined, offset: number): T | undefined {
|
||||
if (array) {
|
||||
offset = toOffset(array, offset);
|
||||
if (offset < array.length) {
|
||||
@@ -1222,11 +1222,11 @@ namespace ts {
|
||||
/**
|
||||
* Returns the first element of an array if non-empty, `undefined` otherwise.
|
||||
*/
|
||||
export function firstOrUndefined<T>(array: ReadonlyArray<T>): T | undefined {
|
||||
export function firstOrUndefined<T>(array: readonly T[]): T | undefined {
|
||||
return array.length === 0 ? undefined : array[0];
|
||||
}
|
||||
|
||||
export function first<T>(array: ReadonlyArray<T>): T {
|
||||
export function first<T>(array: readonly T[]): T {
|
||||
Debug.assert(array.length !== 0);
|
||||
return array[0];
|
||||
}
|
||||
@@ -1234,11 +1234,11 @@ namespace ts {
|
||||
/**
|
||||
* Returns the last element of an array if non-empty, `undefined` otherwise.
|
||||
*/
|
||||
export function lastOrUndefined<T>(array: ReadonlyArray<T>): T | undefined {
|
||||
export function lastOrUndefined<T>(array: readonly T[]): T | undefined {
|
||||
return array.length === 0 ? undefined : array[array.length - 1];
|
||||
}
|
||||
|
||||
export function last<T>(array: ReadonlyArray<T>): T {
|
||||
export function last<T>(array: readonly T[]): T {
|
||||
Debug.assert(array.length !== 0);
|
||||
return array[array.length - 1];
|
||||
}
|
||||
@@ -1246,7 +1246,7 @@ namespace ts {
|
||||
/**
|
||||
* Returns the only element of an array if it contains only one element, `undefined` otherwise.
|
||||
*/
|
||||
export function singleOrUndefined<T>(array: ReadonlyArray<T> | undefined): T | undefined {
|
||||
export function singleOrUndefined<T>(array: readonly T[] | undefined): T | undefined {
|
||||
return array && array.length === 1
|
||||
? array[0]
|
||||
: undefined;
|
||||
@@ -1257,16 +1257,16 @@ namespace ts {
|
||||
* array.
|
||||
*/
|
||||
export function singleOrMany<T>(array: T[]): T | T[];
|
||||
export function singleOrMany<T>(array: ReadonlyArray<T>): T | ReadonlyArray<T>;
|
||||
export function singleOrMany<T>(array: readonly T[]): T | readonly T[];
|
||||
export function singleOrMany<T>(array: T[] | undefined): T | T[] | undefined;
|
||||
export function singleOrMany<T>(array: ReadonlyArray<T> | undefined): T | ReadonlyArray<T> | undefined;
|
||||
export function singleOrMany<T>(array: ReadonlyArray<T> | undefined): T | ReadonlyArray<T> | undefined {
|
||||
export function singleOrMany<T>(array: readonly T[] | undefined): T | readonly T[] | undefined;
|
||||
export function singleOrMany<T>(array: readonly T[] | undefined): T | readonly T[] | undefined {
|
||||
return array && array.length === 1
|
||||
? array[0]
|
||||
: array;
|
||||
}
|
||||
|
||||
export function replaceElement<T>(array: ReadonlyArray<T>, index: number, value: T): T[] {
|
||||
export function replaceElement<T>(array: readonly T[], index: number, value: T): T[] {
|
||||
const result = array.slice(0);
|
||||
result[index] = value;
|
||||
return result;
|
||||
@@ -1283,7 +1283,7 @@ namespace ts {
|
||||
* @param keyComparer A callback used to compare two keys in a sorted array.
|
||||
* @param offset An offset into `array` at which to start the search.
|
||||
*/
|
||||
export function binarySearch<T, U>(array: ReadonlyArray<T>, value: T, keySelector: (v: T) => U, keyComparer: Comparer<U>, offset?: number): number {
|
||||
export function binarySearch<T, U>(array: readonly T[], value: T, keySelector: (v: T) => U, keyComparer: Comparer<U>, offset?: number): number {
|
||||
return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset);
|
||||
}
|
||||
|
||||
@@ -1297,7 +1297,7 @@ namespace ts {
|
||||
* @param keyComparer A callback used to compare two keys in a sorted array.
|
||||
* @param offset An offset into `array` at which to start the search.
|
||||
*/
|
||||
export function binarySearchKey<T, U>(array: ReadonlyArray<T>, key: U, keySelector: (v: T) => U, keyComparer: Comparer<U>, offset?: number): number {
|
||||
export function binarySearchKey<T, U>(array: readonly T[], key: U, keySelector: (v: T) => U, keyComparer: Comparer<U>, offset?: number): number {
|
||||
if (!some(array)) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1322,8 +1322,8 @@ namespace ts {
|
||||
return ~low;
|
||||
}
|
||||
|
||||
export function reduceLeft<T, U>(array: ReadonlyArray<T> | undefined, f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U;
|
||||
export function reduceLeft<T>(array: ReadonlyArray<T>, f: (memo: T, value: T, i: number) => T): T | undefined;
|
||||
export function reduceLeft<T, U>(array: readonly T[] | undefined, f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U;
|
||||
export function reduceLeft<T>(array: readonly T[], f: (memo: T, value: T, i: number) => T): T | undefined;
|
||||
export function reduceLeft<T>(array: T[], f: (memo: T, value: T, i: number) => T, initial?: T, start?: number, count?: number): T | undefined {
|
||||
if (array && array.length > 0) {
|
||||
const size = array.length;
|
||||
@@ -1465,9 +1465,9 @@ namespace ts {
|
||||
* the same key with the given 'makeKey' function, then the element with the higher
|
||||
* index in the array will be the one associated with the produced key.
|
||||
*/
|
||||
export function arrayToMap<T>(array: ReadonlyArray<T>, makeKey: (value: T) => string | undefined): Map<T>;
|
||||
export function arrayToMap<T, U>(array: ReadonlyArray<T>, makeKey: (value: T) => string | undefined, makeValue: (value: T) => U): Map<U>;
|
||||
export function arrayToMap<T, U>(array: ReadonlyArray<T>, makeKey: (value: T) => string | undefined, makeValue: (value: T) => T | U = identity): Map<T | U> {
|
||||
export function arrayToMap<T>(array: readonly T[], makeKey: (value: T) => string | undefined): Map<T>;
|
||||
export function arrayToMap<T, U>(array: readonly T[], makeKey: (value: T) => string | undefined, makeValue: (value: T) => U): Map<U>;
|
||||
export function arrayToMap<T, U>(array: readonly T[], makeKey: (value: T) => string | undefined, makeValue: (value: T) => T | U = identity): Map<T | U> {
|
||||
const result = createMap<T | U>();
|
||||
for (const value of array) {
|
||||
const key = makeKey(value);
|
||||
@@ -1476,9 +1476,9 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function arrayToNumericMap<T>(array: ReadonlyArray<T>, makeKey: (value: T) => number): T[];
|
||||
export function arrayToNumericMap<T, U>(array: ReadonlyArray<T>, makeKey: (value: T) => number, makeValue: (value: T) => U): U[];
|
||||
export function arrayToNumericMap<T, U>(array: ReadonlyArray<T>, makeKey: (value: T) => number, makeValue: (value: T) => T | U = identity): (T | U)[] {
|
||||
export function arrayToNumericMap<T>(array: readonly T[], makeKey: (value: T) => number): T[];
|
||||
export function arrayToNumericMap<T, U>(array: readonly T[], makeKey: (value: T) => number, makeValue: (value: T) => U): U[];
|
||||
export function arrayToNumericMap<T, U>(array: readonly T[], makeKey: (value: T) => number, makeValue: (value: T) => T | U = identity): (T | U)[] {
|
||||
const result: (T | U)[] = [];
|
||||
for (const value of array) {
|
||||
result[makeKey(value)] = makeValue(value);
|
||||
@@ -1486,9 +1486,9 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function arrayToMultiMap<T>(values: ReadonlyArray<T>, makeKey: (value: T) => string): MultiMap<T>;
|
||||
export function arrayToMultiMap<T, U>(values: ReadonlyArray<T>, makeKey: (value: T) => string, makeValue: (value: T) => U): MultiMap<U>;
|
||||
export function arrayToMultiMap<T, U>(values: ReadonlyArray<T>, makeKey: (value: T) => string, makeValue: (value: T) => T | U = identity): MultiMap<T | U> {
|
||||
export function arrayToMultiMap<T>(values: readonly T[], makeKey: (value: T) => string): MultiMap<T>;
|
||||
export function arrayToMultiMap<T, U>(values: readonly T[], makeKey: (value: T) => string, makeValue: (value: T) => U): MultiMap<U>;
|
||||
export function arrayToMultiMap<T, U>(values: readonly T[], makeKey: (value: T) => string, makeValue: (value: T) => T | U = identity): MultiMap<T | U> {
|
||||
const result = createMultiMap<T | U>();
|
||||
for (const value of values) {
|
||||
result.add(makeKey(value), makeValue(value));
|
||||
@@ -1496,7 +1496,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function group<T>(values: ReadonlyArray<T>, getGroupId: (value: T) => string): ReadonlyArray<ReadonlyArray<T>> {
|
||||
export function group<T>(values: readonly T[], getGroupId: (value: T) => string): readonly (readonly T[])[] {
|
||||
return arrayFrom(arrayToMultiMap(values, getGroupId).values());
|
||||
}
|
||||
|
||||
@@ -1582,12 +1582,12 @@ namespace ts {
|
||||
/**
|
||||
* Tests whether a value is an array.
|
||||
*/
|
||||
export function isArray(value: any): value is ReadonlyArray<{}> {
|
||||
export function isArray(value: any): value is readonly {}[] {
|
||||
return Array.isArray ? Array.isArray(value) : value instanceof Array;
|
||||
}
|
||||
|
||||
export function toArray<T>(value: T | T[]): T[];
|
||||
export function toArray<T>(value: T | ReadonlyArray<T>): ReadonlyArray<T>;
|
||||
export function toArray<T>(value: T | readonly T[]): readonly T[];
|
||||
export function toArray<T>(value: T | T[]): T[] {
|
||||
return isArray(value) ? value : [value];
|
||||
}
|
||||
@@ -2035,7 +2035,7 @@ namespace ts {
|
||||
return path.length > extension.length && endsWith(path, extension);
|
||||
}
|
||||
|
||||
export function fileExtensionIsOneOf(path: string, extensions: ReadonlyArray<string>): boolean {
|
||||
export function fileExtensionIsOneOf(path: string, extensions: readonly string[]): boolean {
|
||||
for (const extension of extensions) {
|
||||
if (fileExtensionIs(path, extension)) {
|
||||
return true;
|
||||
@@ -2123,7 +2123,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Return the object corresponding to the best pattern to match `candidate`. */
|
||||
export function findBestPatternMatch<T>(values: ReadonlyArray<T>, getPattern: (value: T) => Pattern, candidate: string): T | undefined {
|
||||
export function findBestPatternMatch<T>(values: readonly T[], getPattern: (value: T) => Pattern, candidate: string): T | undefined {
|
||||
let matchedValue: T | undefined;
|
||||
// use length of prefix as betterness criteria
|
||||
let longestMatchPrefixLength = -1;
|
||||
@@ -2171,7 +2171,7 @@ namespace ts {
|
||||
return t === undefined ? undefined : [t];
|
||||
}
|
||||
|
||||
export function enumerateInsertsAndDeletes<T, U>(newItems: ReadonlyArray<T>, oldItems: ReadonlyArray<U>, comparer: (a: T, b: U) => Comparison, inserted: (newItem: T) => void, deleted: (oldItem: U) => void, unchanged?: (oldItem: U, newItem: T) => void) {
|
||||
export function enumerateInsertsAndDeletes<T, U>(newItems: readonly T[], oldItems: readonly U[], comparer: (a: T, b: U) => Comparison, inserted: (newItem: T) => void, deleted: (oldItem: U) => void, unchanged?: (oldItem: U, newItem: T) => void) {
|
||||
unchanged = unchanged || noop;
|
||||
let newIndex = 0;
|
||||
let oldIndex = 0;
|
||||
@@ -2211,13 +2211,13 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function cartesianProduct<T>(arrays: ReadonlyArray<T>[]) {
|
||||
export function cartesianProduct<T>(arrays: readonly T[][]) {
|
||||
const result: T[][] = [];
|
||||
cartesianProductWorker(arrays, result, /*outer*/ undefined, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
function cartesianProductWorker<T>(arrays: ReadonlyArray<ReadonlyArray<T>>, result: (ReadonlyArray<T>)[], outer: ReadonlyArray<T> | undefined, index: number) {
|
||||
function cartesianProductWorker<T>(arrays: readonly (readonly T[])[], result: (readonly T[])[], outer: readonly T[] | undefined, index: number) {
|
||||
for (const element of arrays[index]) {
|
||||
let inner: T[];
|
||||
if (outer) {
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace ts {
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertEachDefined<T, A extends ReadonlyArray<T>>(value: A, message?: string): A {
|
||||
export function assertEachDefined<T, A extends readonly T[]>(value: A, message?: string): A {
|
||||
for (const v of value) {
|
||||
assertDefined(v, message);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace ts {
|
||||
*/
|
||||
export function forEachEmittedFile<T>(
|
||||
host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle | undefined) => T,
|
||||
sourceFilesOrTargetSourceFile?: ReadonlyArray<SourceFile> | SourceFile,
|
||||
sourceFilesOrTargetSourceFile?: readonly SourceFile[] | SourceFile,
|
||||
emitOnlyDtsFiles = false,
|
||||
onlyBuildInfo?: boolean,
|
||||
includeBuildInfo?: boolean) {
|
||||
@@ -170,7 +170,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getAllProjectOutputs(configFile: ParsedCommandLine, ignoreCase: boolean): ReadonlyArray<string> {
|
||||
export function getAllProjectOutputs(configFile: ParsedCommandLine, ignoreCase: boolean): readonly string[] {
|
||||
let outputs: string[] | undefined;
|
||||
const addOutput = (path: string | undefined) => path && (outputs || (outputs = [])).push(path);
|
||||
if (configFile.options.outFile || configFile.options.out) {
|
||||
@@ -623,7 +623,7 @@ namespace ts {
|
||||
|
||||
/*@internal*/
|
||||
/** File that isnt present resulting in error or output files */
|
||||
export type EmitUsingBuildInfoResult = string | ReadonlyArray<OutputFile>;
|
||||
export type EmitUsingBuildInfoResult = string | readonly OutputFile[];
|
||||
|
||||
/*@internal*/
|
||||
export interface EmitUsingBuildInfoHost extends ModuleResolutionHost {
|
||||
@@ -633,7 +633,7 @@ namespace ts {
|
||||
getNewLine(): string;
|
||||
}
|
||||
|
||||
function createSourceFilesFromBundleBuildInfo(bundle: BundleBuildInfo, buildInfoDirectory: string, host: EmitUsingBuildInfoHost): ReadonlyArray<SourceFile> {
|
||||
function createSourceFilesFromBundleBuildInfo(bundle: BundleBuildInfo, buildInfoDirectory: string, host: EmitUsingBuildInfoHost): readonly SourceFile[] {
|
||||
const sourceFiles = bundle.sourceFiles.map(fileName => {
|
||||
const sourceFile = createNode(SyntaxKind.SourceFile, 0, 0) as SourceFile;
|
||||
sourceFile.fileName = getRelativePathFromDirectory(
|
||||
@@ -815,7 +815,7 @@ namespace ts {
|
||||
let containerPos = -1;
|
||||
let containerEnd = -1;
|
||||
let declarationListContainerEnd = -1;
|
||||
let currentLineMap: ReadonlyArray<number> | undefined;
|
||||
let currentLineMap: readonly number[] | undefined;
|
||||
let detachedCommentsInfo: { nodePos: number, detachedCommentEndPos: number}[] | undefined;
|
||||
let hasWrittenComment = false;
|
||||
let commentsDisabled = !!printerOptions.removeComments;
|
||||
@@ -3446,7 +3446,7 @@ namespace ts {
|
||||
if (node.isDeclarationFile) emitTripleSlashDirectives(node.hasNoDefaultLib, node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
|
||||
}
|
||||
|
||||
function emitTripleSlashDirectives(hasNoDefaultLib: boolean, files: ReadonlyArray<FileReference>, types: ReadonlyArray<FileReference>, libs: ReadonlyArray<FileReference>) {
|
||||
function emitTripleSlashDirectives(hasNoDefaultLib: boolean, files: readonly FileReference[], types: readonly FileReference[], libs: readonly FileReference[]) {
|
||||
if (hasNoDefaultLib) {
|
||||
const pos = writer.getTextPos();
|
||||
writeComment(`/// <reference no-default-lib="true"/>`);
|
||||
@@ -3513,7 +3513,7 @@ namespace ts {
|
||||
* Emits any prologue directives at the start of a Statement list, returning the
|
||||
* number of prologue directives written to the output.
|
||||
*/
|
||||
function emitPrologueDirectives(statements: ReadonlyArray<Node>, sourceFile?: SourceFile, seenPrologueDirectives?: Map<true>, recordBundleFileSection?: true): number {
|
||||
function emitPrologueDirectives(statements: readonly Node[], sourceFile?: SourceFile, seenPrologueDirectives?: Map<true>, recordBundleFileSection?: true): number {
|
||||
let needsToSetSourceFile = !!sourceFile;
|
||||
for (let i = 0; i < statements.length; i++) {
|
||||
const statement = statements[i];
|
||||
@@ -3542,7 +3542,7 @@ namespace ts {
|
||||
return statements.length;
|
||||
}
|
||||
|
||||
function emitUnparsedPrologues(prologues: ReadonlyArray<UnparsedPrologue>, seenPrologueDirectives: Map<true>) {
|
||||
function emitUnparsedPrologues(prologues: readonly UnparsedPrologue[], seenPrologueDirectives: Map<true>) {
|
||||
for (const prologue of prologues) {
|
||||
if (!seenPrologueDirectives.has(prologue.data)) {
|
||||
writeLine();
|
||||
|
||||
+220
-220
File diff suppressed because it is too large
Load Diff
@@ -41,7 +41,7 @@ namespace ts.moduleSpecifiers {
|
||||
importingSourceFileName: Path,
|
||||
toFileName: string,
|
||||
host: ModuleSpecifierResolutionHost,
|
||||
files: ReadonlyArray<SourceFile>,
|
||||
files: readonly SourceFile[],
|
||||
redirectTargetsMap: RedirectTargetsMap,
|
||||
oldImportSpecifier: string,
|
||||
): string | undefined {
|
||||
@@ -57,7 +57,7 @@ namespace ts.moduleSpecifiers {
|
||||
importingSourceFileName: Path,
|
||||
toFileName: string,
|
||||
host: ModuleSpecifierResolutionHost,
|
||||
files: ReadonlyArray<SourceFile>,
|
||||
files: readonly SourceFile[],
|
||||
preferences: UserPreferences = {},
|
||||
redirectTargetsMap: RedirectTargetsMap,
|
||||
): string {
|
||||
@@ -69,7 +69,7 @@ namespace ts.moduleSpecifiers {
|
||||
importingSourceFileName: Path,
|
||||
toFileName: string,
|
||||
host: ModuleSpecifierResolutionHost,
|
||||
files: ReadonlyArray<SourceFile>,
|
||||
files: readonly SourceFile[],
|
||||
redirectTargetsMap: RedirectTargetsMap,
|
||||
preferences: Preferences
|
||||
): string {
|
||||
@@ -85,10 +85,10 @@ namespace ts.moduleSpecifiers {
|
||||
compilerOptions: CompilerOptions,
|
||||
importingSourceFile: SourceFile,
|
||||
host: ModuleSpecifierResolutionHost,
|
||||
files: ReadonlyArray<SourceFile>,
|
||||
files: readonly SourceFile[],
|
||||
userPreferences: UserPreferences,
|
||||
redirectTargetsMap: RedirectTargetsMap,
|
||||
): ReadonlyArray<string> {
|
||||
): readonly string[] {
|
||||
const ambient = tryGetModuleNameFromAmbientModule(moduleSymbol);
|
||||
if (ambient) return [ambient];
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace ts.moduleSpecifiers {
|
||||
return [getPathFromPathComponents(aParts), getPathFromPathComponents(bParts)];
|
||||
}
|
||||
|
||||
function discoverProbableSymlinks(files: ReadonlyArray<SourceFile>, getCanonicalFileName: GetCanonicalFileName, cwd: string): ReadonlyMap<string> {
|
||||
function discoverProbableSymlinks(files: readonly SourceFile[], getCanonicalFileName: GetCanonicalFileName, cwd: string): ReadonlyMap<string> {
|
||||
const result = createMap<string>();
|
||||
const symlinks = flatten<readonly [string, string]>(mapDefined(files, sf =>
|
||||
sf.resolvedModules && compact(arrayFrom(mapIterator(sf.resolvedModules.values(), res =>
|
||||
@@ -190,7 +190,7 @@ namespace ts.moduleSpecifiers {
|
||||
* Looks for existing imports that use symlinks to this module.
|
||||
* Symlinks will be returned first so they are preferred over the real path.
|
||||
*/
|
||||
function getAllModulePaths(files: ReadonlyArray<SourceFile>, importingFileName: string, importedFileName: string, getCanonicalFileName: GetCanonicalFileName, host: ModuleSpecifierResolutionHost, redirectTargetsMap: RedirectTargetsMap): ReadonlyArray<string> {
|
||||
function getAllModulePaths(files: readonly SourceFile[], importingFileName: string, importedFileName: string, getCanonicalFileName: GetCanonicalFileName, host: ModuleSpecifierResolutionHost, redirectTargetsMap: RedirectTargetsMap): readonly string[] {
|
||||
const redirects = redirectTargetsMap.get(importedFileName);
|
||||
const importedFileNames = redirects ? [...redirects, importedFileName] : [importedFileName];
|
||||
const cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : "";
|
||||
@@ -226,7 +226,7 @@ namespace ts.moduleSpecifiers {
|
||||
}
|
||||
}
|
||||
|
||||
function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex: string, relativeToBaseUrl: string, paths: MapLike<ReadonlyArray<string>>): string | undefined {
|
||||
function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex: string, relativeToBaseUrl: string, paths: MapLike<readonly string[]>): string | undefined {
|
||||
for (const key in paths) {
|
||||
for (const patternText of paths[key]) {
|
||||
const pattern = removeFileExtension(normalizePath(patternText));
|
||||
@@ -249,7 +249,7 @@ namespace ts.moduleSpecifiers {
|
||||
}
|
||||
}
|
||||
|
||||
function tryGetModuleNameFromRootDirs(rootDirs: ReadonlyArray<string>, moduleFileName: string, sourceDirectory: string, getCanonicalFileName: (file: string) => string): string | undefined {
|
||||
function tryGetModuleNameFromRootDirs(rootDirs: readonly string[], moduleFileName: string, sourceDirectory: string, getCanonicalFileName: (file: string) => string): string | undefined {
|
||||
const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
||||
if (normalizedTargetPath === undefined) {
|
||||
return undefined;
|
||||
@@ -404,7 +404,7 @@ namespace ts.moduleSpecifiers {
|
||||
return state > States.NodeModules ? { topLevelNodeModulesIndex, topLevelPackageNameIndex, packageRootIndex, fileNameIndex } : undefined;
|
||||
}
|
||||
|
||||
function getPathRelativeToRootDirs(path: string, rootDirs: ReadonlyArray<string>, getCanonicalFileName: GetCanonicalFileName): string | undefined {
|
||||
function getPathRelativeToRootDirs(path: string, rootDirs: readonly string[], getCanonicalFileName: GetCanonicalFileName): string | undefined {
|
||||
return firstDefined(rootDirs, rootDir => {
|
||||
const relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName)!; // TODO: GH#18217
|
||||
return isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
||||
|
||||
+35
-35
@@ -316,9 +316,9 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
/*@internal*/ export function getPreEmitDiagnostics(program: BuilderProgram, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
export function getPreEmitDiagnostics(program: Program | BuilderProgram, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic> {
|
||||
export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
/*@internal*/ export function getPreEmitDiagnostics(program: BuilderProgram, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
export function getPreEmitDiagnostics(program: Program | BuilderProgram, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[] {
|
||||
const diagnostics = [
|
||||
...program.getConfigFileParsingDiagnostics(),
|
||||
...program.getOptionsDiagnostics(cancellationToken),
|
||||
@@ -340,7 +340,7 @@ namespace ts {
|
||||
getNewLine(): string;
|
||||
}
|
||||
|
||||
export function formatDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, host: FormatDiagnosticsHost): string {
|
||||
export function formatDiagnostics(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string {
|
||||
let output = "";
|
||||
|
||||
for (const diagnostic of diagnostics) {
|
||||
@@ -465,7 +465,7 @@ namespace ts {
|
||||
return output;
|
||||
}
|
||||
|
||||
export function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray<Diagnostic>, host: FormatDiagnosticsHost): string {
|
||||
export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string {
|
||||
let output = "";
|
||||
for (const diagnostic of diagnostics) {
|
||||
if (diagnostic.file) {
|
||||
@@ -562,7 +562,7 @@ namespace ts {
|
||||
fileExists: (fileName: string) => boolean,
|
||||
hasInvalidatedResolution: HasInvalidatedResolution,
|
||||
hasChangedAutomaticTypeDirectiveNames: boolean,
|
||||
projectReferences: ReadonlyArray<ProjectReference> | undefined
|
||||
projectReferences: readonly ProjectReference[] | undefined
|
||||
): boolean {
|
||||
// If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date
|
||||
if (!program || hasChangedAutomaticTypeDirectiveNames) {
|
||||
@@ -647,7 +647,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray<Diagnostic> {
|
||||
export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[] {
|
||||
return configFileParseResult.options.configFile ?
|
||||
[...configFileParseResult.options.configFile.parseDiagnostics, ...configFileParseResult.errors] :
|
||||
configFileParseResult.errors;
|
||||
@@ -665,7 +665,7 @@ namespace ts {
|
||||
!isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)));
|
||||
}
|
||||
|
||||
function createCreateProgramOptions(rootNames: ReadonlyArray<string>, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>): CreateProgramOptions {
|
||||
function createCreateProgramOptions(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): CreateProgramOptions {
|
||||
return {
|
||||
rootNames,
|
||||
options,
|
||||
@@ -700,8 +700,8 @@ namespace ts {
|
||||
* @param configFileParsingDiagnostics - error during config file parsing
|
||||
* @returns A 'Program' object.
|
||||
*/
|
||||
export function createProgram(rootNames: ReadonlyArray<string>, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>): Program;
|
||||
export function createProgram(rootNamesOrOptions: ReadonlyArray<string> | CreateProgramOptions, _options?: CompilerOptions, _host?: CompilerHost, _oldProgram?: Program, _configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>): Program {
|
||||
export function createProgram(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): Program;
|
||||
export function createProgram(rootNamesOrOptions: readonly string[] | CreateProgramOptions, _options?: CompilerOptions, _host?: CompilerHost, _oldProgram?: Program, _configFileParsingDiagnostics?: readonly Diagnostic[]): Program {
|
||||
const createProgramOptions = isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options!, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217
|
||||
const { rootNames, options, configFileParsingDiagnostics, projectReferences } = createProgramOptions;
|
||||
let { oldProgram } = createProgramOptions;
|
||||
@@ -800,13 +800,13 @@ namespace ts {
|
||||
* - undefined otherwise
|
||||
*/
|
||||
const filesByName = createMap<SourceFile | false | undefined>();
|
||||
let missingFilePaths: ReadonlyArray<Path> | undefined;
|
||||
let missingFilePaths: readonly Path[] | undefined;
|
||||
// stores 'filename -> file association' ignoring case
|
||||
// used to track cases when two file names differ only in casing
|
||||
const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createMap<SourceFile>() : undefined;
|
||||
|
||||
// A parallel array to projectReferences storing the results of reading in the referenced tsconfig files
|
||||
let resolvedProjectReferences: ReadonlyArray<ResolvedProjectReference | undefined> | undefined;
|
||||
let resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined;
|
||||
let projectReferenceRedirects: Map<ResolvedProjectReference | false> | undefined;
|
||||
let mapFromFileToProjectReferenceRedirects: Map<Path> | undefined;
|
||||
|
||||
@@ -1528,7 +1528,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emitWorker(program: Program, sourceFile: SourceFile | undefined, writeFileCallback: WriteFileCallback | undefined, cancellationToken: CancellationToken | undefined, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult {
|
||||
let declarationDiagnostics: ReadonlyArray<Diagnostic> = [];
|
||||
let declarationDiagnostics: readonly Diagnostic[] = [];
|
||||
|
||||
if (!emitOnlyDtsFiles) {
|
||||
if (options.noEmit) {
|
||||
@@ -1596,8 +1596,8 @@ namespace ts {
|
||||
|
||||
function getDiagnosticsHelper<T extends Diagnostic>(
|
||||
sourceFile: SourceFile,
|
||||
getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => ReadonlyArray<T>,
|
||||
cancellationToken: CancellationToken): ReadonlyArray<T> {
|
||||
getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => readonly T[],
|
||||
cancellationToken: CancellationToken): readonly T[] {
|
||||
if (sourceFile) {
|
||||
return getDiagnostics(sourceFile, cancellationToken);
|
||||
}
|
||||
@@ -1609,15 +1609,15 @@ namespace ts {
|
||||
}));
|
||||
}
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): ReadonlyArray<DiagnosticWithLocation> {
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): readonly DiagnosticWithLocation[] {
|
||||
return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
|
||||
}
|
||||
|
||||
function getSemanticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): ReadonlyArray<Diagnostic> {
|
||||
function getSemanticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): readonly Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
|
||||
}
|
||||
|
||||
function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): ReadonlyArray<DiagnosticWithLocation> {
|
||||
function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): readonly DiagnosticWithLocation[] {
|
||||
const options = program.getCompilerOptions();
|
||||
// collect diagnostics from the program only once if either no source file was specified or out/outFile is set (bundled emit)
|
||||
if (!sourceFile || options.out || options.outFile) {
|
||||
@@ -1628,7 +1628,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): ReadonlyArray<DiagnosticWithLocation> {
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): readonly DiagnosticWithLocation[] {
|
||||
// For JavaScript files, we report semantic errors for using TypeScript-only
|
||||
// constructs from within a JavaScript file as syntactic errors.
|
||||
if (isSourceFileJS(sourceFile)) {
|
||||
@@ -1663,7 +1663,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): ReadonlyArray<Diagnostic> {
|
||||
function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): readonly Diagnostic[] {
|
||||
return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedSemanticDiagnosticsForFile, getSemanticDiagnosticsForFileNoCache);
|
||||
}
|
||||
|
||||
@@ -1681,7 +1681,7 @@ namespace ts {
|
||||
// By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins)
|
||||
const includeBindAndCheckDiagnostics = sourceFile.scriptKind === ScriptKind.TS || sourceFile.scriptKind === ScriptKind.TSX ||
|
||||
sourceFile.scriptKind === ScriptKind.External || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred;
|
||||
const bindDiagnostics: ReadonlyArray<Diagnostic> = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
|
||||
const bindDiagnostics: readonly Diagnostic[] = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
|
||||
const checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
|
||||
const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
@@ -1700,7 +1700,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getSuggestionDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): ReadonlyArray<DiagnosticWithLocation> {
|
||||
function getSuggestionDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): readonly DiagnosticWithLocation[] {
|
||||
return runWithCancellationToken(() => {
|
||||
return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
|
||||
});
|
||||
@@ -1916,7 +1916,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsWorker(sourceFile: SourceFile, cancellationToken: CancellationToken): ReadonlyArray<DiagnosticWithLocation> {
|
||||
function getDeclarationDiagnosticsWorker(sourceFile: SourceFile, cancellationToken: CancellationToken): readonly DiagnosticWithLocation[] {
|
||||
return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
|
||||
}
|
||||
|
||||
@@ -1933,7 +1933,7 @@ namespace ts {
|
||||
cancellationToken: CancellationToken,
|
||||
cache: DiagnosticCache<T>,
|
||||
getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => T[] | undefined,
|
||||
): ReadonlyArray<T> {
|
||||
): readonly T[] {
|
||||
|
||||
const cachedResult = sourceFile
|
||||
? cache.perFile && cache.perFile.get(sourceFile.path)
|
||||
@@ -1955,7 +1955,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): ReadonlyArray<DiagnosticWithLocation> {
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): readonly DiagnosticWithLocation[] {
|
||||
return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -1984,7 +1984,7 @@ namespace ts {
|
||||
return rootNames.length ? sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : emptyArray as any as SortedReadonlyArray<Diagnostic>;
|
||||
}
|
||||
|
||||
function getConfigFileParsingDiagnostics(): ReadonlyArray<Diagnostic> {
|
||||
function getConfigFileParsingDiagnostics(): readonly Diagnostic[] {
|
||||
return configFileParsingDiagnostics || emptyArray;
|
||||
}
|
||||
|
||||
@@ -2427,21 +2427,21 @@ namespace ts {
|
||||
}
|
||||
|
||||
function forEachProjectReference<T>(
|
||||
projectReferences: ReadonlyArray<ProjectReference> | undefined,
|
||||
resolvedProjectReferences: ReadonlyArray<ResolvedProjectReference | undefined> | undefined,
|
||||
projectReferences: readonly ProjectReference[] | undefined,
|
||||
resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined,
|
||||
cbResolvedRef: (resolvedRef: ResolvedProjectReference | undefined, index: number, parent: ResolvedProjectReference | undefined) => T | undefined,
|
||||
cbRef?: (projectReferences: ReadonlyArray<ProjectReference> | undefined, parent: ResolvedProjectReference | undefined) => T | undefined
|
||||
cbRef?: (projectReferences: readonly ProjectReference[] | undefined, parent: ResolvedProjectReference | undefined) => T | undefined
|
||||
): T | undefined {
|
||||
let seenResolvedRefs: ResolvedProjectReference[] | undefined;
|
||||
|
||||
return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef);
|
||||
|
||||
function worker(
|
||||
projectReferences: ReadonlyArray<ProjectReference> | undefined,
|
||||
resolvedProjectReferences: ReadonlyArray<ResolvedProjectReference | undefined> | undefined,
|
||||
projectReferences: readonly ProjectReference[] | undefined,
|
||||
resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined,
|
||||
parent: ResolvedProjectReference | undefined,
|
||||
cbResolvedRef: (resolvedRef: ResolvedProjectReference | undefined, index: number, parent: ResolvedProjectReference | undefined) => T | undefined,
|
||||
cbRef?: (projectReferences: ReadonlyArray<ProjectReference> | undefined, parent: ResolvedProjectReference | undefined) => T | undefined,
|
||||
cbRef?: (projectReferences: readonly ProjectReference[] | undefined, parent: ResolvedProjectReference | undefined) => T | undefined,
|
||||
): T | undefined {
|
||||
|
||||
// Visit project references first
|
||||
@@ -2650,7 +2650,7 @@ namespace ts {
|
||||
return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
|
||||
}
|
||||
|
||||
function checkSourceFilesBelongToPath(sourceFiles: ReadonlyArray<SourceFile>, rootDirectory: string): boolean {
|
||||
function checkSourceFilesBelongToPath(sourceFiles: readonly SourceFile[], rootDirectory: string): boolean {
|
||||
let allFilesBelongToPath = true;
|
||||
const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory));
|
||||
|
||||
@@ -3171,7 +3171,7 @@ namespace ts {
|
||||
getCurrentDirectory(): string;
|
||||
fileExists(fileName: string): boolean;
|
||||
readFile(fileName: string): string | undefined;
|
||||
readDirectory?(rootDir: string, extensions: ReadonlyArray<string>, excludes: ReadonlyArray<string> | undefined, includes: ReadonlyArray<string>, depth?: number): string[];
|
||||
readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[];
|
||||
trace?(s: string): void;
|
||||
onUnRecoverableConfigFileDiagnostic?: DiagnosticReporter;
|
||||
}
|
||||
@@ -3198,7 +3198,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function createPrependNodes(projectReferences: ReadonlyArray<ProjectReference> | undefined, getCommandLine: (ref: ProjectReference, index: number) => ParsedCommandLine | undefined, readFile: (path: string) => string | undefined) {
|
||||
export function createPrependNodes(projectReferences: readonly ProjectReference[] | undefined, getCommandLine: (ref: ProjectReference, index: number) => ParsedCommandLine | undefined, readFile: (path: string) => string | undefined) {
|
||||
if (!projectReferences) return emptyArray;
|
||||
let nodes: InputFiles[] | undefined;
|
||||
for (let i = 0; i < projectReferences.length; i++) {
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ts {
|
||||
invalidateResolutionOfFile(filePath: Path): void;
|
||||
removeResolutionsOfFile(filePath: Path): void;
|
||||
removeResolutionsFromProjectReferenceRedirects(filePath: Path): void;
|
||||
setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: Map<ReadonlyArray<string>>): void;
|
||||
setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: Map<readonly string[]>): void;
|
||||
createHasInvalidatedResolution(forceAllFilesAsInvalidated?: boolean): HasInvalidatedResolution;
|
||||
|
||||
startCachingPerDirectoryResolution(): void;
|
||||
@@ -25,7 +25,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
interface ResolutionWithFailedLookupLocations {
|
||||
readonly failedLookupLocations: ReadonlyArray<string>;
|
||||
readonly failedLookupLocations: readonly string[];
|
||||
isInvalidated?: boolean;
|
||||
refCount?: number;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ namespace ts {
|
||||
export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootDirForResolution: string | undefined, logChangesWhenResolvingModule: boolean): ResolutionCache {
|
||||
let filesWithChangedSetOfUnresolvedImports: Path[] | undefined;
|
||||
let filesWithInvalidatedResolutions: Map<true> | undefined;
|
||||
let filesWithInvalidatedNonRelativeUnresolvedImports: ReadonlyMap<ReadonlyArray<string>> | undefined;
|
||||
let filesWithInvalidatedNonRelativeUnresolvedImports: ReadonlyMap<readonly string[]> | undefined;
|
||||
let allFilesHaveInvalidatedResolution = false;
|
||||
const nonRelativeExternalModuleResolutions = createMultiMap<ResolutionWithFailedLookupLocations>();
|
||||
|
||||
@@ -287,7 +287,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function resolveNamesWithLocalCache<T extends ResolutionWithFailedLookupLocations, R extends ResolutionWithResolvedFileName>(
|
||||
names: ReadonlyArray<string>,
|
||||
names: readonly string[],
|
||||
containingFile: string,
|
||||
redirectedReference: ResolvedProjectReference | undefined,
|
||||
cache: Map<Map<T>>,
|
||||
@@ -295,7 +295,7 @@ namespace ts {
|
||||
loader: (name: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference) => T,
|
||||
getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName<T, R>,
|
||||
shouldRetryResolution: (t: T) => boolean,
|
||||
reusedNames: ReadonlyArray<string> | undefined,
|
||||
reusedNames: readonly string[] | undefined,
|
||||
logChanges: boolean): (R | undefined)[] {
|
||||
|
||||
const path = resolutionHost.toPath(containingFile);
|
||||
@@ -689,7 +689,7 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap: ReadonlyMap<ReadonlyArray<string>>) {
|
||||
function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap: ReadonlyMap<readonly string[]>) {
|
||||
Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
|
||||
filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -35,8 +35,8 @@ namespace ts {
|
||||
readonly major: number;
|
||||
readonly minor: number;
|
||||
readonly patch: number;
|
||||
readonly prerelease: ReadonlyArray<string>;
|
||||
readonly build: ReadonlyArray<string>;
|
||||
readonly prerelease: readonly string[];
|
||||
readonly build: readonly string[];
|
||||
|
||||
constructor(text: string);
|
||||
constructor(major: number, minor?: number, patch?: number, prerelease?: string, build?: string);
|
||||
@@ -120,7 +120,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function comparePrerelaseIdentifiers(left: ReadonlyArray<string>, right: ReadonlyArray<string>) {
|
||||
function comparePrerelaseIdentifiers(left: readonly string[], right: readonly string[]) {
|
||||
// https://semver.org/#spec-item-11
|
||||
// > When major, minor, and patch are equal, a pre-release version has lower precedence
|
||||
// > than a normal version.
|
||||
@@ -168,7 +168,7 @@ namespace ts {
|
||||
* Describes a semantic version range, per https://github.com/npm/node-semver#ranges
|
||||
*/
|
||||
export class VersionRange {
|
||||
private _alternatives: ReadonlyArray<ReadonlyArray<Comparator>>;
|
||||
private _alternatives: readonly (readonly Comparator[])[];
|
||||
|
||||
constructor(spec: string) {
|
||||
this._alternatives = spec ? Debug.assertDefined(parseRange(spec), "Invalid range spec.") : emptyArray;
|
||||
@@ -349,7 +349,7 @@ namespace ts {
|
||||
return { operator, operand };
|
||||
}
|
||||
|
||||
function testDisjunction(version: Version, alternatives: ReadonlyArray<ReadonlyArray<Comparator>>) {
|
||||
function testDisjunction(version: Version, alternatives: readonly (readonly Comparator[])[]) {
|
||||
// an empty disjunction is treated as "*" (all versions)
|
||||
if (alternatives.length === 0) return true;
|
||||
for (const alternative of alternatives) {
|
||||
@@ -358,7 +358,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function testAlternative(version: Version, comparators: ReadonlyArray<Comparator>) {
|
||||
function testAlternative(version: Version, comparators: readonly Comparator[]) {
|
||||
for (const comparator of comparators) {
|
||||
if (!testComparator(version, comparator.operator, comparator.operand)) return false;
|
||||
}
|
||||
@@ -377,11 +377,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function formatDisjunction(alternatives: ReadonlyArray<ReadonlyArray<Comparator>>) {
|
||||
function formatDisjunction(alternatives: readonly (readonly Comparator[])[]) {
|
||||
return map(alternatives, formatAlternative).join(" || ") || "*";
|
||||
}
|
||||
|
||||
function formatAlternative(comparators: ReadonlyArray<Comparator>) {
|
||||
function formatAlternative(comparators: readonly Comparator[]) {
|
||||
return map(comparators, formatComparator).join(" ");
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace ts {
|
||||
getLineText(line: number): string;
|
||||
}
|
||||
|
||||
export function getLineInfo(text: string, lineStarts: ReadonlyArray<number>): LineInfo {
|
||||
export function getLineInfo(text: string, lineStarts: readonly number[]): LineInfo {
|
||||
return {
|
||||
getLineCount: () => lineStarts.length,
|
||||
getLineText: line => text.substring(lineStarts[line], lineStarts[line + 1])
|
||||
@@ -623,9 +623,9 @@ namespace ts {
|
||||
const generatedFile = host.getSourceFileLike(generatedAbsoluteFilePath);
|
||||
const sourceFileAbsolutePaths = map.sources.map(source => getNormalizedAbsolutePath(source, sourceRoot));
|
||||
const sourceToSourceIndexMap = createMapFromEntries(sourceFileAbsolutePaths.map((source, i) => [host.getCanonicalFileName(source), i] as [string, number]));
|
||||
let decodedMappings: ReadonlyArray<MappedPosition> | undefined;
|
||||
let decodedMappings: readonly MappedPosition[] | undefined;
|
||||
let generatedMappings: SortedReadonlyArray<MappedPosition> | undefined;
|
||||
let sourceMappings: ReadonlyArray<SortedReadonlyArray<SourceMappedPosition>> | undefined;
|
||||
let sourceMappings: readonly SortedReadonlyArray<SourceMappedPosition>[] | undefined;
|
||||
|
||||
return {
|
||||
getSourcePosition,
|
||||
|
||||
+5
-5
@@ -383,7 +383,7 @@ namespace ts {
|
||||
export interface RecursiveDirectoryWatcherHost {
|
||||
watchDirectory: HostWatchDirectory;
|
||||
useCaseSensitiveFileNames: boolean;
|
||||
getAccessibleSortedChildDirectories(path: string): ReadonlyArray<string>;
|
||||
getAccessibleSortedChildDirectories(path: string): readonly string[];
|
||||
directoryExists(dir: string): boolean;
|
||||
realpath(s: string): string;
|
||||
}
|
||||
@@ -398,7 +398,7 @@ namespace ts {
|
||||
interface ChildDirectoryWatcher extends FileWatcher {
|
||||
dirName: string;
|
||||
}
|
||||
type ChildWatches = ReadonlyArray<ChildDirectoryWatcher>;
|
||||
type ChildWatches = readonly ChildDirectoryWatcher[];
|
||||
interface HostDirectoryWatcher {
|
||||
watcher: FileWatcher;
|
||||
childWatches: ChildWatches;
|
||||
@@ -625,7 +625,7 @@ namespace ts {
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string[];
|
||||
readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[];
|
||||
readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[];
|
||||
getModifiedTime?(path: string): Date | undefined;
|
||||
setModifiedTime?(path: string, time: Date): void;
|
||||
deleteFile?(path: string): void;
|
||||
@@ -696,7 +696,7 @@ namespace ts {
|
||||
readFile(path: string): string | undefined;
|
||||
writeFile(path: string, contents: string): void;
|
||||
getDirectories(path: string): string[];
|
||||
readDirectory(path: string, extensions?: ReadonlyArray<string>, basePaths?: ReadonlyArray<string>, excludeEx?: string, includeFileEx?: string, includeDirEx?: string): string[];
|
||||
readDirectory(path: string, extensions?: readonly string[], basePaths?: readonly string[], excludeEx?: string, includeFileEx?: string, includeDirEx?: string): string[];
|
||||
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
|
||||
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
|
||||
realpath(path: string): string;
|
||||
@@ -1227,7 +1227,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extensions?: ReadonlyArray<string>, excludes?: ReadonlyArray<string>, includes?: ReadonlyArray<string>, depth?: number): string[] {
|
||||
function readDirectory(path: string, extensions?: readonly string[], excludes?: readonly string[], includes?: readonly string[], depth?: number): string[] {
|
||||
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace ts {
|
||||
* @param transforms An array of `TransformerFactory` callbacks.
|
||||
* @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files.
|
||||
*/
|
||||
export function transformNodes<T extends Node>(resolver: EmitResolver | undefined, host: EmitHost | undefined, options: CompilerOptions, nodes: ReadonlyArray<T>, transformers: ReadonlyArray<TransformerFactory<T>>, allowDtsFiles: boolean): TransformationResult<T> {
|
||||
export function transformNodes<T extends Node>(resolver: EmitResolver | undefined, host: EmitHost | undefined, options: CompilerOptions, nodes: readonly T[], transformers: readonly TransformerFactory<T>[], allowDtsFiles: boolean): TransformationResult<T> {
|
||||
const enabledSyntaxKindFeatures = new Array<SyntaxKindFeatureFlags>(SyntaxKind.Count);
|
||||
let lexicalEnvironmentVariableDeclarations: VariableDeclaration[];
|
||||
let lexicalEnvironmentFunctionDeclarations: FunctionDeclaration[];
|
||||
|
||||
@@ -376,7 +376,7 @@ namespace ts {
|
||||
* @param properties An array of property declarations to transform.
|
||||
* @param receiver The receiver on which each property should be assigned.
|
||||
*/
|
||||
function addInitializedPropertyStatements(statements: Statement[], properties: ReadonlyArray<PropertyDeclaration>, receiver: LeftHandSideExpression) {
|
||||
function addInitializedPropertyStatements(statements: Statement[], properties: readonly PropertyDeclaration[], receiver: LeftHandSideExpression) {
|
||||
for (const property of properties) {
|
||||
const statement = createExpressionStatement(transformInitializedProperty(property, receiver));
|
||||
setSourceMapRange(statement, moveRangePastModifiers(property));
|
||||
@@ -392,7 +392,7 @@ namespace ts {
|
||||
* @param properties An array of property declarations to transform.
|
||||
* @param receiver The receiver on which each property should be assigned.
|
||||
*/
|
||||
function generateInitializedPropertyExpressions(properties: ReadonlyArray<PropertyDeclaration>, receiver: LeftHandSideExpression) {
|
||||
function generateInitializedPropertyExpressions(properties: readonly PropertyDeclaration[], receiver: LeftHandSideExpression) {
|
||||
const expressions: Expression[] = [];
|
||||
for (const property of properties) {
|
||||
const expression = transformInitializedProperty(property, receiver);
|
||||
|
||||
@@ -83,14 +83,14 @@ namespace ts {
|
||||
let currentSourceFile: SourceFile;
|
||||
let refs: Map<SourceFile>;
|
||||
let libs: Map<boolean>;
|
||||
let emittedImports: ReadonlyArray<AnyImportSyntax> | undefined; // must be declared in container so it can be `undefined` while transformer's first pass
|
||||
let emittedImports: readonly AnyImportSyntax[] | undefined; // must be declared in container so it can be `undefined` while transformer's first pass
|
||||
const resolver = context.getEmitResolver();
|
||||
const options = context.getCompilerOptions();
|
||||
const newLine = getNewLineCharacter(options);
|
||||
const { noResolve, stripInternal } = options;
|
||||
return transformRoot;
|
||||
|
||||
function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives: ReadonlyArray<string> | undefined): void {
|
||||
function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives: readonly string[] | undefined): void {
|
||||
if (!typeReferenceDirectives) {
|
||||
return;
|
||||
}
|
||||
@@ -1177,7 +1177,7 @@ namespace ts {
|
||||
const modifiers = createNodeArray(ensureModifiers(input));
|
||||
const typeParameters = ensureTypeParams(input, input.typeParameters);
|
||||
const ctor = getFirstConstructorWithBody(input);
|
||||
let parameterProperties: ReadonlyArray<PropertyDeclaration> | undefined;
|
||||
let parameterProperties: readonly PropertyDeclaration[] | undefined;
|
||||
if (ctor) {
|
||||
const oldDiag = getSymbolAccessibilityDiagnostic;
|
||||
parameterProperties = compact(flatMap(ctor.parameters, (param) => {
|
||||
@@ -1350,11 +1350,11 @@ namespace ts {
|
||||
return isExportAssignment(node) || isExportDeclaration(node);
|
||||
}
|
||||
|
||||
function hasScopeMarker(statements: ReadonlyArray<Statement>) {
|
||||
function hasScopeMarker(statements: readonly Statement[]) {
|
||||
return some(statements, isScopeMarker);
|
||||
}
|
||||
|
||||
function ensureModifiers(node: Node): ReadonlyArray<Modifier> | undefined {
|
||||
function ensureModifiers(node: Node): readonly Modifier[] | undefined {
|
||||
const currentFlags = getModifierFlags(node);
|
||||
const newFlags = ensureModifierFlags(node);
|
||||
if (currentFlags === newFlags) {
|
||||
|
||||
@@ -532,7 +532,7 @@ namespace ts {
|
||||
/** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement
|
||||
* `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`
|
||||
*/
|
||||
function createRestCall(context: TransformationContext, value: Expression, elements: ReadonlyArray<BindingOrAssignmentElement>, computedTempVariables: ReadonlyArray<Expression>, location: TextRange): Expression {
|
||||
function createRestCall(context: TransformationContext, value: Expression, elements: readonly BindingOrAssignmentElement[], computedTempVariables: readonly Expression[], location: TextRange): Expression {
|
||||
context.requestEmitHelper(restHelper);
|
||||
const propertyNames: Expression[] = [];
|
||||
let computedTempVariableOffset = 0;
|
||||
|
||||
@@ -2067,7 +2067,7 @@ namespace ts {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function getRangeUnion(declarations: ReadonlyArray<Node>): TextRange {
|
||||
function getRangeUnion(declarations: readonly Node[]): TextRange {
|
||||
// declarations may not be sorted by position.
|
||||
// pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
|
||||
let pos = -1, end = -1;
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace ts {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function chunkObjectLiteralElements(elements: ReadonlyArray<ObjectLiteralElementLike>): Expression[] {
|
||||
function chunkObjectLiteralElements(elements: readonly ObjectLiteralElementLike[]): Expression[] {
|
||||
let chunkObject: ObjectLiteralElementLike[] | undefined;
|
||||
const objects: Expression[] = [];
|
||||
for (const e of elements) {
|
||||
|
||||
@@ -1172,7 +1172,7 @@ namespace ts {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function transformAndEmitStatements(statements: ReadonlyArray<Statement>, start = 0) {
|
||||
function transformAndEmitStatements(statements: readonly Statement[], start = 0) {
|
||||
const numStatements = statements.length;
|
||||
for (let i = start; i < numStatements; i++) {
|
||||
transformAndEmitStatement(statements[i]);
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace ts {
|
||||
return visitJsxOpeningFragment(node.openingFragment, node.children, isChild, /*location*/ node);
|
||||
}
|
||||
|
||||
function visitJsxOpeningLikeElement(node: JsxOpeningLikeElement, children: ReadonlyArray<JsxChild> | undefined, isChild: boolean, location: TextRange) {
|
||||
function visitJsxOpeningLikeElement(node: JsxOpeningLikeElement, children: readonly JsxChild[] | undefined, isChild: boolean, location: TextRange) {
|
||||
const tagName = getTagName(node);
|
||||
let objectProperties: Expression | undefined;
|
||||
const attrs = node.attributes.properties;
|
||||
@@ -133,7 +133,7 @@ namespace ts {
|
||||
return element;
|
||||
}
|
||||
|
||||
function visitJsxOpeningFragment(node: JsxOpeningFragment, children: ReadonlyArray<JsxChild>, isChild: boolean, location: TextRange) {
|
||||
function visitJsxOpeningFragment(node: JsxOpeningFragment, children: readonly JsxChild[], isChild: boolean, location: TextRange) {
|
||||
const element = createExpressionForJsxFragment(
|
||||
context.getEmitResolver().getJsxFactoryEntity(currentSourceFile),
|
||||
compilerOptions.reactNamespace!, // TODO: GH#18217
|
||||
|
||||
@@ -580,7 +580,7 @@ namespace ts {
|
||||
return parameter.decorators !== undefined && parameter.decorators.length > 0;
|
||||
}
|
||||
|
||||
function getClassFacts(node: ClassDeclaration, staticProperties: ReadonlyArray<PropertyDeclaration>) {
|
||||
function getClassFacts(node: ClassDeclaration, staticProperties: readonly PropertyDeclaration[]) {
|
||||
let facts = ClassFacts.None;
|
||||
if (some(staticProperties)) facts |= ClassFacts.HasStaticInitializedProperties;
|
||||
const extendsClauseElement = getEffectiveBaseTypeNode(node);
|
||||
@@ -924,7 +924,7 @@ namespace ts {
|
||||
* @param isStatic A value indicating whether to retrieve static or instance members of
|
||||
* the class.
|
||||
*/
|
||||
function getDecoratedClassElements(node: ClassExpression | ClassDeclaration, isStatic: boolean): ReadonlyArray<ClassElement> {
|
||||
function getDecoratedClassElements(node: ClassExpression | ClassDeclaration, isStatic: boolean): readonly ClassElement[] {
|
||||
return filter(node.members, isStatic ? m => isStaticDecoratedClassElement(m, node) : m => isInstanceDecoratedClassElement(m, node));
|
||||
}
|
||||
|
||||
@@ -963,8 +963,8 @@ namespace ts {
|
||||
* A structure describing the decorators for a class element.
|
||||
*/
|
||||
interface AllDecorators {
|
||||
decorators: ReadonlyArray<Decorator> | undefined;
|
||||
parameters?: ReadonlyArray<ReadonlyArray<Decorator> | undefined>;
|
||||
decorators: readonly Decorator[] | undefined;
|
||||
parameters?: readonly (readonly Decorator[] | undefined)[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -974,7 +974,7 @@ namespace ts {
|
||||
* @param node The function-like node.
|
||||
*/
|
||||
function getDecoratorsOfParameters(node: FunctionLikeDeclaration | undefined) {
|
||||
let decorators: (ReadonlyArray<Decorator> | undefined)[] | undefined;
|
||||
let decorators: (readonly Decorator[] | undefined)[] | undefined;
|
||||
if (node) {
|
||||
const parameters = node.parameters;
|
||||
const firstParameterIsThis = parameters.length > 0 && parameterIsThisKeyword(parameters[0]);
|
||||
@@ -1588,7 +1588,7 @@ namespace ts {
|
||||
return createIdentifier("Object");
|
||||
}
|
||||
|
||||
function serializeTypeList(types: ReadonlyArray<TypeNode>): SerializedTypeNode {
|
||||
function serializeTypeList(types: readonly TypeNode[]): SerializedTypeNode {
|
||||
// Note when updating logic here also update getEntityNameForDecoratorMetadata
|
||||
// so that aliases can be marked as referenced
|
||||
let serializedUnion: SerializedTypeNode | undefined;
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace ts {
|
||||
* @param node The class node.
|
||||
* @param isStatic A value indicating whether to get properties from the static or instance side of the class.
|
||||
*/
|
||||
export function getInitializedProperties(node: ClassExpression | ClassDeclaration, isStatic: boolean): ReadonlyArray<PropertyDeclaration> {
|
||||
export function getInitializedProperties(node: ClassExpression | ClassDeclaration, isStatic: boolean): readonly PropertyDeclaration[] {
|
||||
return filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty);
|
||||
}
|
||||
|
||||
|
||||
+32
-32
@@ -282,7 +282,7 @@ namespace ts {
|
||||
getNextInvalidatedProject(cancellationToken?: CancellationToken): InvalidatedProject<T> | undefined;
|
||||
|
||||
// Currently used for testing but can be made public if needed:
|
||||
/*@internal*/ getBuildOrder(): ReadonlyArray<ResolvedConfigFileName>;
|
||||
/*@internal*/ getBuildOrder(): readonly ResolvedConfigFileName[];
|
||||
|
||||
// Testing only
|
||||
/*@internal*/ getUpToDateStatusOfProject(project: string): UpToDateStatus;
|
||||
@@ -332,11 +332,11 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function createSolutionBuilder<T extends BuilderProgram>(host: SolutionBuilderHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder<T> {
|
||||
export function createSolutionBuilder<T extends BuilderProgram>(host: SolutionBuilderHost<T>, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder<T> {
|
||||
return createSolutionBuilderWorker(/*watch*/ false, host, rootNames, defaultOptions);
|
||||
}
|
||||
|
||||
export function createSolutionBuilderWithWatch<T extends BuilderProgram>(host: SolutionBuilderWithWatchHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder<T> {
|
||||
export function createSolutionBuilderWithWatch<T extends BuilderProgram>(host: SolutionBuilderWithWatchHost<T>, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder<T> {
|
||||
return createSolutionBuilderWorker(/*watch*/ true, host, rootNames, defaultOptions);
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ namespace ts {
|
||||
// State of solution
|
||||
readonly options: BuildOptions;
|
||||
readonly baseCompilerOptions: CompilerOptions;
|
||||
readonly rootNames: ReadonlyArray<string>;
|
||||
readonly rootNames: readonly string[];
|
||||
|
||||
readonly resolvedConfigFilePaths: Map<ResolvedConfigFilePath>;
|
||||
readonly configFileCache: ConfigFileMap<ConfigFileCacheEntry>;
|
||||
@@ -372,7 +372,7 @@ namespace ts {
|
||||
readonly extendedConfigCache: Map<ExtendedConfigCacheEntry>;
|
||||
|
||||
readonly builderPrograms: ConfigFileMap<T>;
|
||||
readonly diagnostics: ConfigFileMap<ReadonlyArray<Diagnostic>>;
|
||||
readonly diagnostics: ConfigFileMap<readonly Diagnostic[]>;
|
||||
readonly projectPendingBuild: ConfigFileMap<ConfigFileProgramReloadLevel>;
|
||||
readonly projectErrorsReported: ConfigFileMap<true>;
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace ts {
|
||||
readonly moduleResolutionCache: ModuleResolutionCache | undefined;
|
||||
|
||||
// Mutable state
|
||||
buildOrder: ReadonlyArray<ResolvedConfigFileName> | undefined;
|
||||
buildOrder: readonly ResolvedConfigFileName[] | undefined;
|
||||
readFileWithCache: (f: string) => string | undefined;
|
||||
projectCompilerOptions: CompilerOptions;
|
||||
cache: SolutionBuilderStateCache | undefined;
|
||||
@@ -403,7 +403,7 @@ namespace ts {
|
||||
writeLog: (s: string) => void;
|
||||
}
|
||||
|
||||
function createSolutionBuilderState<T extends BuilderProgram>(watch: boolean, hostOrHostWithWatch: SolutionBuilderHost<T> | SolutionBuilderWithWatchHost<T>, rootNames: ReadonlyArray<string>, options: BuildOptions): SolutionBuilderState<T> {
|
||||
function createSolutionBuilderState<T extends BuilderProgram>(watch: boolean, hostOrHostWithWatch: SolutionBuilderHost<T> | SolutionBuilderWithWatchHost<T>, rootNames: readonly string[], options: BuildOptions): SolutionBuilderState<T> {
|
||||
const host = hostOrHostWithWatch as SolutionBuilderHost<T>;
|
||||
const hostWithWatch = hostOrHostWithWatch as SolutionBuilderWithWatchHost<T>;
|
||||
const currentDirectory = host.getCurrentDirectory();
|
||||
@@ -524,7 +524,7 @@ namespace ts {
|
||||
return resolveConfigFileProjectName(resolvePath(state.currentDirectory, name));
|
||||
}
|
||||
|
||||
function createBuildOrder(state: SolutionBuilderState, roots: ReadonlyArray<ResolvedConfigFileName>): ReadonlyArray<ResolvedConfigFileName> {
|
||||
function createBuildOrder(state: SolutionBuilderState, roots: readonly ResolvedConfigFileName[]): readonly ResolvedConfigFileName[] {
|
||||
const temporaryMarks = createMap() as ConfigFileMap<true>;
|
||||
const permanentMarks = createMap() as ConfigFileMap<true>;
|
||||
const circularityReportStack: string[] = [];
|
||||
@@ -726,7 +726,7 @@ namespace ts {
|
||||
readonly kind: InvalidatedProjectKind;
|
||||
readonly project: ResolvedConfigFileName;
|
||||
/*@internal*/ readonly projectPath: ResolvedConfigFilePath;
|
||||
/*@internal*/ readonly buildOrder: ReadonlyArray<ResolvedConfigFileName>;
|
||||
/*@internal*/ readonly buildOrder: readonly ResolvedConfigFileName[];
|
||||
/**
|
||||
* To dispose this project and ensure that all the necessary actions are taken and state is updated accordingly
|
||||
*/
|
||||
@@ -749,14 +749,14 @@ namespace ts {
|
||||
getBuilderProgram(): T | undefined;
|
||||
getProgram(): Program | undefined;
|
||||
getSourceFile(fileName: string): SourceFile | undefined;
|
||||
getSourceFiles(): ReadonlyArray<SourceFile>;
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getConfigFileParsingDiagnostics(): ReadonlyArray<Diagnostic>;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getAllDependencies(sourceFile: SourceFile): ReadonlyArray<string>;
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult<ReadonlyArray<Diagnostic>>;
|
||||
getSourceFiles(): readonly SourceFile[];
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getAllDependencies(sourceFile: SourceFile): readonly string[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult<readonly Diagnostic[]>;
|
||||
/*
|
||||
* Calling emit directly with targetSourceFile and emitOnlyDtsFiles set to true is not advised since
|
||||
* emit in build system is responsible in updating status of the project
|
||||
@@ -793,7 +793,7 @@ namespace ts {
|
||||
project: ResolvedConfigFileName,
|
||||
projectPath: ResolvedConfigFilePath,
|
||||
config: ParsedCommandLine,
|
||||
buildOrder: ReadonlyArray<ResolvedConfigFileName>
|
||||
buildOrder: readonly ResolvedConfigFileName[]
|
||||
): UpdateOutputFileStampsProject {
|
||||
let updateOutputFileStampsPending = true;
|
||||
return {
|
||||
@@ -823,7 +823,7 @@ namespace ts {
|
||||
projectPath: ResolvedConfigFilePath,
|
||||
projectIndex: number,
|
||||
config: ParsedCommandLine,
|
||||
buildOrder: ReadonlyArray<ResolvedConfigFileName>,
|
||||
buildOrder: readonly ResolvedConfigFileName[],
|
||||
): BuildInvalidedProject<T> | UpdateBundleProject<T> {
|
||||
enum Step {
|
||||
CreateProgram,
|
||||
@@ -928,7 +928,7 @@ namespace ts {
|
||||
return program && action(program);
|
||||
}
|
||||
|
||||
function withProgramOrEmptyArray<U>(action: (program: T) => ReadonlyArray<U>): ReadonlyArray<U> {
|
||||
function withProgramOrEmptyArray<U>(action: (program: T) => readonly U[]): readonly U[] {
|
||||
return withProgramOrUndefined(action) || emptyArray;
|
||||
}
|
||||
|
||||
@@ -969,7 +969,7 @@ namespace ts {
|
||||
step++;
|
||||
}
|
||||
|
||||
function handleDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, errorFlags: BuildResultFlags, errorType: string) {
|
||||
function handleDiagnostics(diagnostics: readonly Diagnostic[], errorFlags: BuildResultFlags, errorType: string) {
|
||||
if (diagnostics.length) {
|
||||
buildResult = buildErrors(
|
||||
state,
|
||||
@@ -1238,7 +1238,7 @@ namespace ts {
|
||||
|
||||
function getNextInvalidatedProject<T extends BuilderProgram>(
|
||||
state: SolutionBuilderState<T>,
|
||||
buildOrder: ReadonlyArray<ResolvedConfigFileName>,
|
||||
buildOrder: readonly ResolvedConfigFileName[],
|
||||
reportQueue: boolean
|
||||
): InvalidatedProject<T> | undefined {
|
||||
if (!state.projectPendingBuild.size) return undefined;
|
||||
@@ -1364,7 +1364,7 @@ namespace ts {
|
||||
state: SolutionBuilderState<T>,
|
||||
resolvedPath: ResolvedConfigFilePath,
|
||||
program: T | undefined,
|
||||
diagnostics: ReadonlyArray<Diagnostic>,
|
||||
diagnostics: readonly Diagnostic[],
|
||||
errorFlags: BuildResultFlags,
|
||||
errorType: string
|
||||
) {
|
||||
@@ -1674,7 +1674,7 @@ namespace ts {
|
||||
projectPath: ResolvedConfigFilePath,
|
||||
projectIndex: number,
|
||||
config: ParsedCommandLine,
|
||||
buildOrder: ReadonlyArray<ResolvedConfigFileName>,
|
||||
buildOrder: readonly ResolvedConfigFileName[],
|
||||
buildResult: BuildResultFlags
|
||||
) {
|
||||
// Queue only if there are no errors
|
||||
@@ -1956,7 +1956,7 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
function startWatching(state: SolutionBuilderState, buildOrder: ReadonlyArray<ResolvedConfigFileName>) {
|
||||
function startWatching(state: SolutionBuilderState, buildOrder: readonly ResolvedConfigFileName[]) {
|
||||
if (!state.watchAllProjectsPending) return;
|
||||
state.watchAllProjectsPending = false;
|
||||
for (const resolved of buildOrder) {
|
||||
@@ -1979,9 +1979,9 @@ namespace ts {
|
||||
* A SolutionBuilder has an immutable set of rootNames that are the "entry point" projects, but
|
||||
* can dynamically add/remove other projects based on changes on the rootNames' references
|
||||
*/
|
||||
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: false, host: SolutionBuilderHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder<T>;
|
||||
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: true, host: SolutionBuilderWithWatchHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder<T>;
|
||||
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: boolean, hostOrHostWithWatch: SolutionBuilderHost<T> | SolutionBuilderWithWatchHost<T>, rootNames: ReadonlyArray<string>, options: BuildOptions): SolutionBuilder<T> {
|
||||
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: false, host: SolutionBuilderHost<T>, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder<T>;
|
||||
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: true, host: SolutionBuilderWithWatchHost<T>, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder<T>;
|
||||
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: boolean, hostOrHostWithWatch: SolutionBuilderHost<T> | SolutionBuilderWithWatchHost<T>, rootNames: readonly string[], options: BuildOptions): SolutionBuilder<T> {
|
||||
const state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options);
|
||||
return {
|
||||
build: (project, cancellationToken) => build(state, project, cancellationToken),
|
||||
@@ -2017,11 +2017,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function reportErrors({ host }: SolutionBuilderState, errors: ReadonlyArray<Diagnostic>) {
|
||||
function reportErrors({ host }: SolutionBuilderState, errors: readonly Diagnostic[]) {
|
||||
errors.forEach(err => host.reportDiagnostic(err));
|
||||
}
|
||||
|
||||
function reportAndStoreErrors(state: SolutionBuilderState, proj: ResolvedConfigFilePath, errors: ReadonlyArray<Diagnostic>) {
|
||||
function reportAndStoreErrors(state: SolutionBuilderState, proj: ResolvedConfigFilePath, errors: readonly Diagnostic[]) {
|
||||
reportErrors(state, errors);
|
||||
state.projectErrorsReported.set(proj, true);
|
||||
if (errors.length) {
|
||||
@@ -2033,7 +2033,7 @@ namespace ts {
|
||||
reportAndStoreErrors(state, proj, [state.configFileCache.get(proj) as Diagnostic]);
|
||||
}
|
||||
|
||||
function reportErrorSummary(state: SolutionBuilderState, buildOrder: ReadonlyArray<ResolvedConfigFileName>) {
|
||||
function reportErrorSummary(state: SolutionBuilderState, buildOrder: readonly ResolvedConfigFileName[]) {
|
||||
if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) return;
|
||||
state.needsSummary = false;
|
||||
const { diagnostics } = state;
|
||||
@@ -2057,7 +2057,7 @@ namespace ts {
|
||||
/**
|
||||
* Report the build ordering inferred from the current project graph if we're in verbose mode
|
||||
*/
|
||||
function reportBuildQueue(state: SolutionBuilderState, buildQueue: ReadonlyArray<ResolvedConfigFileName>) {
|
||||
function reportBuildQueue(state: SolutionBuilderState, buildQueue: readonly ResolvedConfigFileName[]) {
|
||||
if (state.options.verbose) {
|
||||
reportStatus(state, Diagnostics.Projects_in_this_build_Colon_0, buildQueue.map(s => "\r\n * " + relName(state, s)).join(""));
|
||||
}
|
||||
|
||||
+86
-86
@@ -639,7 +639,7 @@ namespace ts {
|
||||
|
||||
export interface JSDocContainer {
|
||||
/* @internal */ jsDoc?: JSDoc[]; // JSDoc that directly precedes this node
|
||||
/* @internal */ jsDocCache?: ReadonlyArray<JSDocTag>; // Cache for getJSDocTags
|
||||
/* @internal */ jsDocCache?: readonly JSDocTag[]; // Cache for getJSDocTags
|
||||
}
|
||||
|
||||
export type HasJSDoc =
|
||||
@@ -2512,8 +2512,8 @@ namespace ts {
|
||||
|
||||
export interface JSDocSignature extends JSDocType, Declaration {
|
||||
kind: SyntaxKind.JSDocSignature;
|
||||
typeParameters?: ReadonlyArray<JSDocTemplateTag>;
|
||||
parameters: ReadonlyArray<JSDocParameterTag>;
|
||||
typeParameters?: readonly JSDocTemplateTag[];
|
||||
parameters: readonly JSDocParameterTag[];
|
||||
type: JSDocReturnTag | undefined;
|
||||
}
|
||||
|
||||
@@ -2536,7 +2536,7 @@ namespace ts {
|
||||
|
||||
export interface JSDocTypeLiteral extends JSDocType {
|
||||
kind: SyntaxKind.JSDocTypeLiteral;
|
||||
jsDocPropertyTags?: ReadonlyArray<JSDocPropertyLikeTag>;
|
||||
jsDocPropertyTags?: readonly JSDocPropertyLikeTag[];
|
||||
/** If true, then this type literal represents an *array* of its type. */
|
||||
isArrayType?: boolean;
|
||||
}
|
||||
@@ -2642,7 +2642,7 @@ namespace ts {
|
||||
*/
|
||||
export interface SourceFileLike {
|
||||
readonly text: string;
|
||||
lineMap?: ReadonlyArray<number>;
|
||||
lineMap?: readonly number[];
|
||||
/* @internal */
|
||||
getPositionOfLineAndCharacter?(line: number, character: number, allowEdits?: true): number;
|
||||
}
|
||||
@@ -2688,11 +2688,11 @@ namespace ts {
|
||||
*/
|
||||
/* @internal */ redirectInfo?: RedirectInfo;
|
||||
|
||||
amdDependencies: ReadonlyArray<AmdDependency>;
|
||||
amdDependencies: readonly AmdDependency[];
|
||||
moduleName?: string;
|
||||
referencedFiles: ReadonlyArray<FileReference>;
|
||||
typeReferenceDirectives: ReadonlyArray<FileReference>;
|
||||
libReferenceDirectives: ReadonlyArray<FileReference>;
|
||||
referencedFiles: readonly FileReference[];
|
||||
typeReferenceDirectives: readonly FileReference[];
|
||||
libReferenceDirectives: readonly FileReference[];
|
||||
languageVariant: LanguageVariant;
|
||||
isDeclarationFile: boolean;
|
||||
|
||||
@@ -2741,22 +2741,22 @@ namespace ts {
|
||||
/* @internal */ jsDocDiagnostics?: DiagnosticWithLocation[];
|
||||
|
||||
// Stores additional file-level diagnostics reported by the program
|
||||
/* @internal */ additionalSyntacticDiagnostics?: ReadonlyArray<DiagnosticWithLocation>;
|
||||
/* @internal */ additionalSyntacticDiagnostics?: readonly DiagnosticWithLocation[];
|
||||
|
||||
// Stores a line map for the file.
|
||||
// This field should never be used directly to obtain line map, use getLineMap function instead.
|
||||
/* @internal */ lineMap: ReadonlyArray<number>;
|
||||
/* @internal */ lineMap: readonly number[];
|
||||
/* @internal */ classifiableNames?: ReadonlyUnderscoreEscapedMap<true>;
|
||||
// Stores a mapping 'external module reference text' -> 'resolved file name' | undefined
|
||||
// It is used to resolve module names in the checker.
|
||||
// Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead
|
||||
/* @internal */ resolvedModules?: Map<ResolvedModuleFull | undefined>;
|
||||
/* @internal */ resolvedTypeReferenceDirectiveNames: Map<ResolvedTypeReferenceDirective | undefined>;
|
||||
/* @internal */ imports: ReadonlyArray<StringLiteralLike>;
|
||||
/* @internal */ imports: readonly StringLiteralLike[];
|
||||
// Identifier only if `declare global`
|
||||
/* @internal */ moduleAugmentations: ReadonlyArray<StringLiteral | Identifier>;
|
||||
/* @internal */ moduleAugmentations: (StringLiteral | Identifier)[];
|
||||
/* @internal */ patternAmbientModules?: PatternAmbientModule[];
|
||||
/* @internal */ ambientModuleNames: ReadonlyArray<string>;
|
||||
/* @internal */ ambientModuleNames: readonly string[];
|
||||
/* @internal */ checkJsDirective?: CheckJsDirective;
|
||||
/* @internal */ version: string;
|
||||
/* @internal */ pragmas: ReadonlyPragmaMap;
|
||||
@@ -2767,15 +2767,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export type ExportedModulesFromDeclarationEmit = ReadonlyArray<Symbol>;
|
||||
export type ExportedModulesFromDeclarationEmit = readonly Symbol[];
|
||||
|
||||
export interface Bundle extends Node {
|
||||
kind: SyntaxKind.Bundle;
|
||||
prepends: ReadonlyArray<InputFiles | UnparsedSource>;
|
||||
sourceFiles: ReadonlyArray<SourceFile>;
|
||||
/* @internal */ syntheticFileReferences?: ReadonlyArray<FileReference>;
|
||||
/* @internal */ syntheticTypeReferences?: ReadonlyArray<FileReference>;
|
||||
/* @internal */ syntheticLibReferences?: ReadonlyArray<FileReference>;
|
||||
prepends: readonly (InputFiles | UnparsedSource)[];
|
||||
sourceFiles: readonly SourceFile[];
|
||||
/* @internal */ syntheticFileReferences?: readonly FileReference[];
|
||||
/* @internal */ syntheticTypeReferences?: readonly FileReference[];
|
||||
/* @internal */ syntheticLibReferences?: readonly FileReference[];
|
||||
/* @internal */ hasNoDefaultLib?: boolean;
|
||||
}
|
||||
|
||||
@@ -2798,19 +2798,19 @@ namespace ts {
|
||||
kind: SyntaxKind.UnparsedSource;
|
||||
fileName: string;
|
||||
text: string;
|
||||
prologues: ReadonlyArray<UnparsedPrologue>;
|
||||
helpers: ReadonlyArray<UnscopedEmitHelper> | undefined;
|
||||
prologues: readonly UnparsedPrologue[];
|
||||
helpers: readonly UnscopedEmitHelper[] | undefined;
|
||||
|
||||
// References and noDefaultLibAre Dts only
|
||||
referencedFiles: ReadonlyArray<FileReference>;
|
||||
typeReferenceDirectives: ReadonlyArray<string> | undefined;
|
||||
libReferenceDirectives: ReadonlyArray<FileReference>;
|
||||
referencedFiles: readonly FileReference[];
|
||||
typeReferenceDirectives: readonly string[] | undefined;
|
||||
libReferenceDirectives: readonly FileReference[];
|
||||
hasNoDefaultLib?: boolean;
|
||||
|
||||
sourceMapPath?: string;
|
||||
sourceMapText?: string;
|
||||
syntheticReferences?: ReadonlyArray<UnparsedSyntheticReference>;
|
||||
texts: ReadonlyArray<UnparsedSourceText>;
|
||||
syntheticReferences?: readonly UnparsedSyntheticReference[];
|
||||
texts: readonly UnparsedSourceText[];
|
||||
/*@internal*/ oldFileOfCurrentEmit?: boolean;
|
||||
/*@internal*/ parsedSourceMap?: RawSourceMap | false | undefined;
|
||||
// Adding this to satisfy services, fix later
|
||||
@@ -2837,7 +2837,7 @@ namespace ts {
|
||||
kind: SyntaxKind.UnparsedPrepend;
|
||||
data: string;
|
||||
parent: UnparsedSource;
|
||||
texts: ReadonlyArray<UnparsedTextLike>;
|
||||
texts: readonly UnparsedTextLike[];
|
||||
}
|
||||
|
||||
export interface UnparsedTextLike extends UnparsedSection {
|
||||
@@ -2879,7 +2879,7 @@ namespace ts {
|
||||
export interface ParseConfigHost {
|
||||
useCaseSensitiveFileNames: boolean;
|
||||
|
||||
readDirectory(rootDir: string, extensions: ReadonlyArray<string>, excludes: ReadonlyArray<string> | undefined, includes: ReadonlyArray<string>, depth?: number): ReadonlyArray<string>;
|
||||
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[];
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether the specified path exists and is a file.
|
||||
@@ -2903,7 +2903,7 @@ namespace ts {
|
||||
data: string,
|
||||
writeByteOrderMark: boolean,
|
||||
onError?: (message: string) => void,
|
||||
sourceFiles?: ReadonlyArray<SourceFile>,
|
||||
sourceFiles?: readonly SourceFile[],
|
||||
) => void;
|
||||
|
||||
export class OperationCanceledException { }
|
||||
@@ -2921,19 +2921,19 @@ namespace ts {
|
||||
/**
|
||||
* Get a list of root file names that were passed to a 'createProgram'
|
||||
*/
|
||||
getRootFileNames(): ReadonlyArray<string>;
|
||||
getRootFileNames(): readonly string[];
|
||||
|
||||
/**
|
||||
* Get a list of files in the program
|
||||
*/
|
||||
getSourceFiles(): ReadonlyArray<SourceFile>;
|
||||
getSourceFiles(): readonly SourceFile[];
|
||||
|
||||
/**
|
||||
* Get a list of file names that were passed to 'createProgram' or referenced in a
|
||||
* program source file but could not be located.
|
||||
*/
|
||||
/* @internal */
|
||||
getMissingFilePaths(): ReadonlyArray<Path>;
|
||||
getMissingFilePaths(): readonly Path[];
|
||||
|
||||
/**
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
@@ -2947,14 +2947,14 @@ namespace ts {
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult;
|
||||
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<DiagnosticWithLocation>;
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
|
||||
/** The first time this is called, it will return global diagnostics (no location). */
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<DiagnosticWithLocation>;
|
||||
getConfigFileParsingDiagnostics(): ReadonlyArray<Diagnostic>;
|
||||
/* @internal */ getSuggestionDiagnostics(sourceFile: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<DiagnosticWithLocation>;
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
|
||||
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
|
||||
/* @internal */ getSuggestionDiagnostics(sourceFile: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
|
||||
|
||||
/**
|
||||
* Gets a type checker that can be used to semantically analyze source files in the program.
|
||||
@@ -2996,8 +2996,8 @@ namespace ts {
|
||||
|
||||
/* @internal */ getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined;
|
||||
|
||||
getProjectReferences(): ReadonlyArray<ProjectReference> | undefined;
|
||||
getResolvedProjectReferences(): ReadonlyArray<ResolvedProjectReference | undefined> | undefined;
|
||||
getProjectReferences(): readonly ProjectReference[] | undefined;
|
||||
getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined;
|
||||
/*@internal*/ getProjectReferenceRedirect(fileName: string): string | undefined;
|
||||
/*@internal*/ getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined;
|
||||
/*@internal*/ forEachResolvedProjectReference<T>(cb: (resolvedProjectReference: ResolvedProjectReference | undefined, resolvedProjectReferencePath: Path) => T | undefined): T | undefined;
|
||||
@@ -3007,12 +3007,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export type RedirectTargetsMap = ReadonlyMap<ReadonlyArray<string>>;
|
||||
export type RedirectTargetsMap = ReadonlyMap<readonly string[]>;
|
||||
|
||||
export interface ResolvedProjectReference {
|
||||
commandLine: ParsedCommandLine;
|
||||
sourceFile: SourceFile;
|
||||
references?: ReadonlyArray<ResolvedProjectReference | undefined>;
|
||||
references?: readonly (ResolvedProjectReference | undefined)[];
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -3040,8 +3040,8 @@ namespace ts {
|
||||
|
||||
/*@internal*/
|
||||
export interface EmitTransformers {
|
||||
scriptTransformers: ReadonlyArray<TransformerFactory<SourceFile | Bundle>>;
|
||||
declarationTransformers: ReadonlyArray<TransformerFactory<SourceFile | Bundle>>;
|
||||
scriptTransformers: readonly TransformerFactory<SourceFile | Bundle>[];
|
||||
declarationTransformers: readonly TransformerFactory<SourceFile | Bundle>[];
|
||||
}
|
||||
|
||||
export interface SourceMapSpan {
|
||||
@@ -3061,7 +3061,7 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export interface SourceMapEmitResult {
|
||||
inputSourceFileNames: ReadonlyArray<string>; // Input source file (which one can use on program to get the file), 1:1 mapping with the sourceMap.sources list
|
||||
inputSourceFileNames: readonly string[]; // Input source file (which one can use on program to get the file), 1:1 mapping with the sourceMap.sources list
|
||||
sourceMap: RawSourceMap;
|
||||
}
|
||||
|
||||
@@ -3085,7 +3085,7 @@ namespace ts {
|
||||
export interface EmitResult {
|
||||
emitSkipped: boolean;
|
||||
/** Contains declaration emit diagnostics */
|
||||
diagnostics: ReadonlyArray<Diagnostic>;
|
||||
diagnostics: readonly Diagnostic[];
|
||||
emittedFiles?: string[]; // Array of files the compiler wrote to disk
|
||||
/* @internal */ sourceMaps?: SourceMapEmitResult[]; // Array of sourceMapData if compiler emitted sourcemaps
|
||||
/* @internal */ exportedModulesFromDeclarationEmit?: ExportedModulesFromDeclarationEmit;
|
||||
@@ -3095,7 +3095,7 @@ namespace ts {
|
||||
export interface TypeCheckerHost extends ModuleSpecifierResolutionHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
|
||||
getSourceFiles(): ReadonlyArray<SourceFile>;
|
||||
getSourceFiles(): readonly SourceFile[];
|
||||
getSourceFile(fileName: string): SourceFile | undefined;
|
||||
getResolvedTypeReferenceDirectives(): ReadonlyMap<ResolvedTypeReferenceDirective | undefined>;
|
||||
getProjectReferenceRedirect(fileName: string): string | undefined;
|
||||
@@ -3110,7 +3110,7 @@ namespace ts {
|
||||
getPropertyOfType(type: Type, propertyName: string): Symbol | undefined;
|
||||
/* @internal */ getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined;
|
||||
getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined;
|
||||
getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray<Signature>;
|
||||
getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[];
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined;
|
||||
getBaseTypes(type: InterfaceType): BaseType[];
|
||||
getBaseTypeOfLiteralType(type: Type): Type;
|
||||
@@ -3182,7 +3182,7 @@ namespace ts {
|
||||
|
||||
getFullyQualifiedName(symbol: Symbol): string;
|
||||
getAugmentedPropertiesOfType(type: Type): Symbol[];
|
||||
getRootSymbols(symbol: Symbol): ReadonlyArray<Symbol>;
|
||||
getRootSymbols(symbol: Symbol): readonly Symbol[];
|
||||
getContextualType(node: Expression): Type | undefined;
|
||||
/* @internal */ getContextualTypeForObjectLiteralElement(element: ObjectLiteralElementLike): Type | undefined;
|
||||
/* @internal */ getContextualTypeForArgumentAtIndex(call: CallLikeExpression, argIndex: number): Type | undefined;
|
||||
@@ -3196,7 +3196,7 @@ namespace ts {
|
||||
*/
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined;
|
||||
/* @internal */ getResolvedSignatureForSignatureHelp(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined;
|
||||
/* @internal */ getExpandedParameters(sig: Signature): ReadonlyArray<Symbol>;
|
||||
/* @internal */ getExpandedParameters(sig: Signature): readonly Symbol[];
|
||||
/* @internal */ hasEffectiveRestParameter(sig: Signature): boolean;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
||||
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
|
||||
@@ -3294,7 +3294,7 @@ namespace ts {
|
||||
* So for `{ a } | { b }`, this will include both `a` and `b`.
|
||||
* Does not include properties of primitive types.
|
||||
*/
|
||||
/* @internal */ getAllPossiblePropertiesOfTypes(type: ReadonlyArray<Type>): Symbol[];
|
||||
/* @internal */ getAllPossiblePropertiesOfTypes(type: readonly Type[]): Symbol[];
|
||||
/* @internal */ resolveName(name: string, location: Node, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined;
|
||||
/* @internal */ getJsxNamespace(location?: Node): string;
|
||||
|
||||
@@ -3322,7 +3322,7 @@ namespace ts {
|
||||
* Does *not* get *all* suggestion diagnostics, just the ones that were convenient to report in the checker.
|
||||
* Others are added in computeSuggestionDiagnostics.
|
||||
*/
|
||||
/* @internal */ getSuggestionDiagnostics(file: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<DiagnosticWithLocation>;
|
||||
/* @internal */ getSuggestionDiagnostics(file: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
|
||||
|
||||
/**
|
||||
* Depending on the operation performed, it may be appropriate to throw away the checker
|
||||
@@ -3331,7 +3331,7 @@ namespace ts {
|
||||
*/
|
||||
runWithCancellationToken<T>(token: CancellationToken, cb: (checker: TypeChecker) => T): T;
|
||||
|
||||
/* @internal */ getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol: Symbol): ReadonlyArray<TypeParameter> | undefined;
|
||||
/* @internal */ getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol: Symbol): readonly TypeParameter[] | undefined;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -3450,9 +3450,9 @@ namespace ts {
|
||||
/* @internal */
|
||||
export interface SymbolWalker {
|
||||
/** Note: Return values are not ordered. */
|
||||
walkType(root: Type): { visitedTypes: ReadonlyArray<Type>, visitedSymbols: ReadonlyArray<Symbol> };
|
||||
walkType(root: Type): { visitedTypes: readonly Type[], visitedSymbols: readonly Symbol[] };
|
||||
/** Note: Return values are not ordered. */
|
||||
walkSymbol(root: Symbol): { visitedTypes: ReadonlyArray<Type>, visitedSymbols: ReadonlyArray<Symbol> };
|
||||
walkSymbol(root: Symbol): { visitedTypes: readonly Type[], visitedSymbols: readonly Symbol[] };
|
||||
}
|
||||
|
||||
// This was previously deprecated in our public API, but is still used internally
|
||||
@@ -4038,7 +4038,7 @@ namespace ts {
|
||||
symbol: Symbol; // Symbol associated with type (if any)
|
||||
pattern?: DestructuringPattern; // Destructuring pattern represented by type (if any)
|
||||
aliasSymbol?: Symbol; // Alias associated with type
|
||||
aliasTypeArguments?: ReadonlyArray<Type>; // Alias type arguments (if any)
|
||||
aliasTypeArguments?: readonly Type[]; // Alias type arguments (if any)
|
||||
/* @internal */ aliasTypeArgumentsContainsMarker?: boolean; // Alias type arguments (if any)
|
||||
/* @internal */
|
||||
permissiveInstantiation?: Type; // Instantiation with type parameters mapped to wildcard type
|
||||
@@ -4143,8 +4143,8 @@ namespace ts {
|
||||
objectFlags: ObjectFlags;
|
||||
/* @internal */ members?: SymbolTable; // Properties by name
|
||||
/* @internal */ properties?: Symbol[]; // Properties
|
||||
/* @internal */ callSignatures?: ReadonlyArray<Signature>; // Call signatures of type
|
||||
/* @internal */ constructSignatures?: ReadonlyArray<Signature>; // Construct signatures of type
|
||||
/* @internal */ callSignatures?: readonly Signature[]; // Call signatures of type
|
||||
/* @internal */ constructSignatures?: readonly Signature[]; // Construct signatures of type
|
||||
/* @internal */ stringIndexInfo?: IndexInfo; // String indexing info
|
||||
/* @internal */ numberIndexInfo?: IndexInfo; // Numeric indexing info
|
||||
}
|
||||
@@ -4184,7 +4184,7 @@ namespace ts {
|
||||
*/
|
||||
export interface TypeReference extends ObjectType {
|
||||
target: GenericType; // Type reference target
|
||||
typeArguments?: ReadonlyArray<Type>; // Type reference type arguments (undefined if none)
|
||||
typeArguments?: readonly Type[]; // Type reference type arguments (undefined if none)
|
||||
/* @internal */
|
||||
literalType?: TypeReference; // Clone of type with ObjectFlags.ArrayLiteral set
|
||||
}
|
||||
@@ -4285,8 +4285,8 @@ namespace ts {
|
||||
export interface ResolvedType extends ObjectType, UnionOrIntersectionType {
|
||||
members: SymbolTable; // Properties by name
|
||||
properties: Symbol[]; // Properties
|
||||
callSignatures: ReadonlyArray<Signature>; // Call signatures of type
|
||||
constructSignatures: ReadonlyArray<Signature>; // Construct signatures of type
|
||||
callSignatures: readonly Signature[]; // Call signatures of type
|
||||
constructSignatures: readonly Signature[]; // Construct signatures of type
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -4429,8 +4429,8 @@ namespace ts {
|
||||
|
||||
export interface Signature {
|
||||
declaration?: SignatureDeclaration | JSDocSignature; // Originating declaration
|
||||
typeParameters?: ReadonlyArray<TypeParameter>; // Type parameters (undefined if non-generic)
|
||||
parameters: ReadonlyArray<Symbol>; // Parameters
|
||||
typeParameters?: readonly TypeParameter[]; // Type parameters (undefined if non-generic)
|
||||
parameters: readonly Symbol[]; // Parameters
|
||||
/* @internal */
|
||||
thisParameter?: Symbol; // symbol of this-type parameter
|
||||
/* @internal */
|
||||
@@ -4537,7 +4537,7 @@ namespace ts {
|
||||
mapper: TypeMapper; // Mapper that fixes inferences
|
||||
nonFixingMapper: TypeMapper; // Mapper that doesn't fix inferences
|
||||
returnMapper?: TypeMapper; // Type mapper for inferences from return types (if any)
|
||||
inferredTypeParameters?: ReadonlyArray<TypeParameter>; // Inferred type parameters for function result
|
||||
inferredTypeParameters?: readonly TypeParameter[]; // Inferred type parameters for function result
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -4846,7 +4846,7 @@ namespace ts {
|
||||
options: CompilerOptions;
|
||||
typeAcquisition?: TypeAcquisition;
|
||||
fileNames: string[];
|
||||
projectReferences?: ReadonlyArray<ProjectReference>;
|
||||
projectReferences?: readonly ProjectReference[];
|
||||
raw?: any;
|
||||
errors: Diagnostic[];
|
||||
wildcardDirectories?: MapLike<WatchDirectoryFlags>;
|
||||
@@ -4861,17 +4861,17 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export interface ConfigFileSpecs {
|
||||
filesSpecs: ReadonlyArray<string> | undefined;
|
||||
filesSpecs: readonly string[] | undefined;
|
||||
/**
|
||||
* Present to report errors (user specified specs), validatedIncludeSpecs are used for file name matching
|
||||
*/
|
||||
includeSpecs?: ReadonlyArray<string>;
|
||||
includeSpecs?: readonly string[];
|
||||
/**
|
||||
* Present to report errors (user specified specs), validatedExcludeSpecs are used for file name matching
|
||||
*/
|
||||
excludeSpecs?: ReadonlyArray<string>;
|
||||
validatedIncludeSpecs?: ReadonlyArray<string>;
|
||||
validatedExcludeSpecs?: ReadonlyArray<string>;
|
||||
excludeSpecs?: readonly string[];
|
||||
validatedIncludeSpecs?: readonly string[];
|
||||
validatedExcludeSpecs?: readonly string[];
|
||||
wildcardDirectories: MapLike<WatchDirectoryFlags>;
|
||||
}
|
||||
|
||||
@@ -4882,12 +4882,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface CreateProgramOptions {
|
||||
rootNames: ReadonlyArray<string>;
|
||||
rootNames: readonly string[];
|
||||
options: CompilerOptions;
|
||||
projectReferences?: ReadonlyArray<ProjectReference>;
|
||||
projectReferences?: readonly ProjectReference[];
|
||||
host?: CompilerHost;
|
||||
oldProgram?: Program;
|
||||
configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>;
|
||||
configFileParsingDiagnostics?: readonly Diagnostic[];
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -5154,7 +5154,7 @@ namespace ts {
|
||||
export interface ResolvedModuleWithFailedLookupLocations {
|
||||
readonly resolvedModule: ResolvedModuleFull | undefined;
|
||||
/* @internal */
|
||||
readonly failedLookupLocations: ReadonlyArray<string>;
|
||||
readonly failedLookupLocations: readonly string[];
|
||||
}
|
||||
|
||||
export interface ResolvedTypeReferenceDirective {
|
||||
@@ -5169,7 +5169,7 @@ namespace ts {
|
||||
|
||||
export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
|
||||
readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined;
|
||||
readonly failedLookupLocations: ReadonlyArray<string>;
|
||||
readonly failedLookupLocations: readonly string[];
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -5186,7 +5186,7 @@ namespace ts {
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
getNewLine(): string;
|
||||
readDirectory?(rootDir: string, extensions: ReadonlyArray<string>, excludes: ReadonlyArray<string> | undefined, includes: ReadonlyArray<string>, depth?: number): string[];
|
||||
readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[];
|
||||
|
||||
/*
|
||||
* CompilerHost must either implement resolveModuleNames (in case if it wants to be completely in charge of
|
||||
@@ -5296,7 +5296,7 @@ namespace ts {
|
||||
export interface SourceMapSource {
|
||||
fileName: string;
|
||||
text: string;
|
||||
/* @internal */ lineMap: ReadonlyArray<number>;
|
||||
/* @internal */ lineMap: readonly number[];
|
||||
skipTrivia?: (pos: number) => number;
|
||||
}
|
||||
|
||||
@@ -5421,7 +5421,7 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export interface EmitHost extends ScriptReferenceHost, ModuleSpecifierResolutionHost {
|
||||
getSourceFiles(): ReadonlyArray<SourceFile>;
|
||||
getSourceFiles(): readonly SourceFile[];
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
getCurrentDirectory(): string;
|
||||
|
||||
@@ -5435,7 +5435,7 @@ namespace ts {
|
||||
|
||||
isEmitBlocked(emitFileName: string): boolean;
|
||||
|
||||
getPrependNodes(): ReadonlyArray<InputFiles | UnparsedSource>;
|
||||
getPrependNodes(): readonly (InputFiles | UnparsedSource)[];
|
||||
|
||||
writeFile: WriteFileCallback;
|
||||
getProgramBuildInfo(): ProgramBuildInfo | undefined;
|
||||
@@ -5696,7 +5696,7 @@ namespace ts {
|
||||
js?: BundleFileInfo;
|
||||
dts?: BundleFileInfo;
|
||||
commonSourceDirectory: string;
|
||||
sourceFiles: ReadonlyArray<string>;
|
||||
sourceFiles: readonly string[];
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -5793,7 +5793,7 @@ namespace ts {
|
||||
*/
|
||||
/* @internal */
|
||||
export interface SourceMapGenerator {
|
||||
getSources(): ReadonlyArray<string>;
|
||||
getSources(): readonly string[];
|
||||
/**
|
||||
* Adds a source to the source map.
|
||||
*/
|
||||
@@ -5888,7 +5888,7 @@ namespace ts {
|
||||
reportPrivateInBaseOfClassExpression?(propertyName: string): void;
|
||||
reportInaccessibleUniqueSymbolError?(): void;
|
||||
reportLikelyUnsafeImportRequiredError?(specifier: string): void;
|
||||
moduleResolverHost?: ModuleSpecifierResolutionHost & { getSourceFiles(): ReadonlyArray<SourceFile>, getCommonSourceDirectory(): string };
|
||||
moduleResolverHost?: ModuleSpecifierResolutionHost & { getSourceFiles(): readonly SourceFile[], getCommonSourceDirectory(): string };
|
||||
trackReferencedAmbientModule?(decl: ModuleDeclaration, symbol: Symbol): void;
|
||||
trackExternalModuleSymbolOfImportTypeNode?(symbol: Symbol): void;
|
||||
}
|
||||
@@ -6100,7 +6100,7 @@ namespace ts {
|
||||
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
||||
|
||||
/* @internal */
|
||||
type ArgumentDefinitionToFieldUnion<T extends ReadonlyArray<PragmaArgumentSpecification<any>>> = {
|
||||
type ArgumentDefinitionToFieldUnion<T extends readonly PragmaArgumentSpecification<any>[]> = {
|
||||
[K in keyof T]: PragmaArgTypeOptional<T[K], T[K] extends {name: infer TName} ? TName extends string ? TName : never : never>
|
||||
}[Extract<keyof T, number>]; // The mapped type maps over only the tuple members, but this reindex gets _all_ members - by extracting only `number` keys, we get only the tuple members
|
||||
|
||||
@@ -6109,7 +6109,7 @@ namespace ts {
|
||||
*/
|
||||
/* @internal */
|
||||
type PragmaArgumentType<KPrag extends keyof ConcretePragmaSpecs> =
|
||||
ConcretePragmaSpecs[KPrag] extends { args: ReadonlyArray<PragmaArgumentSpecification<any>> }
|
||||
ConcretePragmaSpecs[KPrag] extends { args: readonly PragmaArgumentSpecification<any>[] }
|
||||
? UnionToIntersection<ArgumentDefinitionToFieldUnion<ConcretePragmaSpecs[KPrag]["args"]>>
|
||||
: never;
|
||||
|
||||
|
||||
+74
-74
@@ -6,7 +6,7 @@ namespace ts {
|
||||
return pathIsRelative(moduleName) || isRootedDiskPath(moduleName);
|
||||
}
|
||||
|
||||
export function sortAndDeduplicateDiagnostics<T extends Diagnostic>(diagnostics: ReadonlyArray<T>): SortedReadonlyArray<T> {
|
||||
export function sortAndDeduplicateDiagnostics<T extends Diagnostic>(diagnostics: readonly T[]): SortedReadonlyArray<T> {
|
||||
return sortAndDeduplicate<T>(diagnostics, compareDiagnostics);
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace ts {
|
||||
return !!map && !!map.size;
|
||||
}
|
||||
|
||||
export function createSymbolTable(symbols?: ReadonlyArray<Symbol>): SymbolTable {
|
||||
export function createSymbolTable(symbols?: readonly Symbol[]): SymbolTable {
|
||||
const result = createMap<Symbol>() as SymbolTable;
|
||||
if (symbols) {
|
||||
for (const symbol of symbols) {
|
||||
@@ -189,10 +189,10 @@ namespace ts {
|
||||
*
|
||||
* @param array the array of input elements.
|
||||
*/
|
||||
export function arrayToSet(array: ReadonlyArray<string>): Map<true>;
|
||||
export function arrayToSet<T>(array: ReadonlyArray<T>, makeKey: (value: T) => string | undefined): Map<true>;
|
||||
export function arrayToSet<T>(array: ReadonlyArray<T>, makeKey: (value: T) => __String | undefined): UnderscoreEscapedMap<true>;
|
||||
export function arrayToSet(array: ReadonlyArray<any>, makeKey?: (value: any) => string | __String | undefined): Map<true> | UnderscoreEscapedMap<true> {
|
||||
export function arrayToSet(array: readonly string[]): Map<true>;
|
||||
export function arrayToSet<T>(array: readonly T[], makeKey: (value: T) => string | undefined): Map<true>;
|
||||
export function arrayToSet<T>(array: readonly T[], makeKey: (value: T) => __String | undefined): UnderscoreEscapedMap<true>;
|
||||
export function arrayToSet(array: readonly any[], makeKey?: (value: any) => string | __String | undefined): Map<true> | UnderscoreEscapedMap<true> {
|
||||
return arrayToMap<any, true>(array, makeKey || (s => s), () => true);
|
||||
}
|
||||
|
||||
@@ -269,8 +269,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function hasChangesInResolutions<T>(
|
||||
names: ReadonlyArray<string>,
|
||||
newResolutions: ReadonlyArray<T>,
|
||||
names: readonly string[],
|
||||
newResolutions: readonly T[],
|
||||
oldResolutions: ReadonlyMap<T> | undefined,
|
||||
comparer: (oldResolution: T, newResolution: T) => boolean): boolean {
|
||||
Debug.assert(names.length === newResolutions.length);
|
||||
@@ -407,7 +407,7 @@ namespace ts {
|
||||
return !nodeIsMissing(node);
|
||||
}
|
||||
|
||||
function insertStatementsAfterPrologue<T extends Statement>(to: T[], from: ReadonlyArray<T> | undefined, isPrologueDirective: (node: Node) => boolean): T[] {
|
||||
function insertStatementsAfterPrologue<T extends Statement>(to: T[], from: readonly T[] | undefined, isPrologueDirective: (node: Node) => boolean): T[] {
|
||||
if (from === undefined || from.length === 0) return to;
|
||||
let statementIndex = 0;
|
||||
// skip all prologue directives to insert at the correct position
|
||||
@@ -441,11 +441,11 @@ namespace ts {
|
||||
/**
|
||||
* Prepends statements to an array while taking care of prologue directives.
|
||||
*/
|
||||
export function insertStatementsAfterStandardPrologue<T extends Statement>(to: T[], from: ReadonlyArray<T> | undefined): T[] {
|
||||
export function insertStatementsAfterStandardPrologue<T extends Statement>(to: T[], from: readonly T[] | undefined): T[] {
|
||||
return insertStatementsAfterPrologue(to, from, isPrologueDirective);
|
||||
}
|
||||
|
||||
export function insertStatementsAfterCustomPrologue<T extends Statement>(to: T[], from: ReadonlyArray<T> | undefined): T[] {
|
||||
export function insertStatementsAfterCustomPrologue<T extends Statement>(to: T[], from: readonly T[] | undefined): T[] {
|
||||
return insertStatementsAfterPrologue(to, from, isAnyPrologueDirective);
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ namespace ts {
|
||||
* Note: it is expected that the `nodeArray` and the `node` are within the same file.
|
||||
* For example, searching for a `SourceFile` in a `SourceFile[]` wouldn't work.
|
||||
*/
|
||||
export function indexOfNode(nodeArray: ReadonlyArray<Node>, node: Node) {
|
||||
export function indexOfNode(nodeArray: readonly Node[], node: Node) {
|
||||
return binarySearch(nodeArray, node, getPos, compareValues);
|
||||
}
|
||||
|
||||
@@ -1308,7 +1308,7 @@ namespace ts {
|
||||
return predicate && predicate.kind === TypePredicateKind.This;
|
||||
}
|
||||
|
||||
export function getPropertyAssignment(objectLiteral: ObjectLiteralExpression, key: string, key2?: string): ReadonlyArray<PropertyAssignment> {
|
||||
export function getPropertyAssignment(objectLiteral: ObjectLiteralExpression, key: string, key2?: string): readonly PropertyAssignment[] {
|
||||
return objectLiteral.properties.filter((property): property is PropertyAssignment => {
|
||||
if (property.kind === SyntaxKind.PropertyAssignment) {
|
||||
const propName = getTextOfPropertyName(property.name);
|
||||
@@ -1332,7 +1332,7 @@ namespace ts {
|
||||
undefined);
|
||||
}
|
||||
|
||||
export function getTsConfigPropArray(tsConfigSourceFile: TsConfigSourceFile | undefined, propKey: string): ReadonlyArray<PropertyAssignment> {
|
||||
export function getTsConfigPropArray(tsConfigSourceFile: TsConfigSourceFile | undefined, propKey: string): readonly PropertyAssignment[] {
|
||||
const jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile);
|
||||
return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : emptyArray;
|
||||
}
|
||||
@@ -2206,7 +2206,7 @@ namespace ts {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export function getJSDocCommentsAndTags(hostNode: Node): ReadonlyArray<JSDoc | JSDocTag> {
|
||||
export function getJSDocCommentsAndTags(hostNode: Node): readonly (JSDoc | JSDocTag)[] {
|
||||
let result: (JSDoc | JSDocTag)[] | undefined;
|
||||
// Pull parameter comments from declaring function as well
|
||||
if (isVariableLike(hostNode) && hasInitializer(hostNode) && hasJSDocNodes(hostNode.initializer!)) {
|
||||
@@ -2597,7 +2597,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Returns the node in an `extends` or `implements` clause of a class or interface. */
|
||||
export function getAllSuperTypeNodes(node: Node): ReadonlyArray<TypeNode> {
|
||||
export function getAllSuperTypeNodes(node: Node): readonly TypeNode[] {
|
||||
return isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || emptyArray :
|
||||
isClassLike(node) ? concatenate(singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || emptyArray :
|
||||
emptyArray;
|
||||
@@ -3464,7 +3464,7 @@ namespace ts {
|
||||
* @param host An EmitHost.
|
||||
* @param targetSourceFile An optional target source file to emit.
|
||||
*/
|
||||
export function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): ReadonlyArray<SourceFile> {
|
||||
export function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): readonly SourceFile[] {
|
||||
const options = host.getCompilerOptions();
|
||||
const isSourceFileFromExternalLibrary = (file: SourceFile) => host.isSourceFileFromExternalLibrary(file);
|
||||
const getResolvedProjectReferenceToRedirect = (fileName: string) => host.getResolvedProjectReferenceToRedirect(fileName);
|
||||
@@ -3505,7 +3505,7 @@ namespace ts {
|
||||
return combinePaths(newDirPath, sourceFilePath);
|
||||
}
|
||||
|
||||
export function writeFile(host: { writeFile: WriteFileCallback; }, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: ReadonlyArray<SourceFile>) {
|
||||
export function writeFile(host: { writeFile: WriteFileCallback; }, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: readonly SourceFile[]) {
|
||||
host.writeFile(fileName, data, writeByteOrderMark, hostErrorMessage => {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}, sourceFiles);
|
||||
@@ -3515,7 +3515,7 @@ namespace ts {
|
||||
return getLineAndCharacterOfPosition(currentSourceFile, pos).line;
|
||||
}
|
||||
|
||||
export function getLineOfLocalPositionFromLineMap(lineMap: ReadonlyArray<number>, pos: number) {
|
||||
export function getLineOfLocalPositionFromLineMap(lineMap: readonly number[], pos: number) {
|
||||
return computeLineAndCharacterOfPosition(lineMap, pos).line;
|
||||
}
|
||||
|
||||
@@ -3633,7 +3633,7 @@ namespace ts {
|
||||
node.type || (isInJSFile(node) ? getJSDocReturnType(node) : undefined);
|
||||
}
|
||||
|
||||
export function getJSDocTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray<TypeParameterDeclaration> {
|
||||
export function getJSDocTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[] {
|
||||
return flatMap(getJSDocTags(node), tag => isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined);
|
||||
}
|
||||
|
||||
@@ -3651,11 +3651,11 @@ namespace ts {
|
||||
return parameter && getEffectiveTypeAnnotationNode(parameter);
|
||||
}
|
||||
|
||||
export function emitNewLineBeforeLeadingComments(lineMap: ReadonlyArray<number>, writer: EmitTextWriter, node: TextRange, leadingComments: ReadonlyArray<CommentRange> | undefined) {
|
||||
export function emitNewLineBeforeLeadingComments(lineMap: readonly number[], writer: EmitTextWriter, node: TextRange, leadingComments: readonly CommentRange[] | undefined) {
|
||||
emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments);
|
||||
}
|
||||
|
||||
export function emitNewLineBeforeLeadingCommentsOfPosition(lineMap: ReadonlyArray<number>, writer: EmitTextWriter, pos: number, leadingComments: ReadonlyArray<CommentRange> | undefined) {
|
||||
export function emitNewLineBeforeLeadingCommentsOfPosition(lineMap: readonly number[], writer: EmitTextWriter, pos: number, leadingComments: readonly CommentRange[] | undefined) {
|
||||
// If the leading comments start on different line than the start of node, write new line
|
||||
if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos &&
|
||||
getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) {
|
||||
@@ -3663,7 +3663,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function emitNewLineBeforeLeadingCommentOfPosition(lineMap: ReadonlyArray<number>, writer: EmitTextWriter, pos: number, commentPos: number) {
|
||||
export function emitNewLineBeforeLeadingCommentOfPosition(lineMap: readonly number[], writer: EmitTextWriter, pos: number, commentPos: number) {
|
||||
// If the leading comments start on different line than the start of node, write new line
|
||||
if (pos !== commentPos &&
|
||||
getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) {
|
||||
@@ -3673,13 +3673,13 @@ namespace ts {
|
||||
|
||||
export function emitComments(
|
||||
text: string,
|
||||
lineMap: ReadonlyArray<number>,
|
||||
lineMap: readonly number[],
|
||||
writer: EmitTextWriter,
|
||||
comments: ReadonlyArray<CommentRange> | undefined,
|
||||
comments: readonly CommentRange[] | undefined,
|
||||
leadingSeparator: boolean,
|
||||
trailingSeparator: boolean,
|
||||
newLine: string,
|
||||
writeComment: (text: string, lineMap: ReadonlyArray<number>, writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void) {
|
||||
writeComment: (text: string, lineMap: readonly number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void) {
|
||||
if (comments && comments.length > 0) {
|
||||
if (leadingSeparator) {
|
||||
writer.writeSpace(" ");
|
||||
@@ -3711,8 +3711,8 @@ namespace ts {
|
||||
* Detached comment is a comment at the top of file or function body that is separated from
|
||||
* the next statement by space.
|
||||
*/
|
||||
export function emitDetachedComments(text: string, lineMap: ReadonlyArray<number>, writer: EmitTextWriter,
|
||||
writeComment: (text: string, lineMap: ReadonlyArray<number>, writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void,
|
||||
export function emitDetachedComments(text: string, lineMap: readonly number[], writer: EmitTextWriter,
|
||||
writeComment: (text: string, lineMap: readonly number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void,
|
||||
node: TextRange, newLine: string, removeComments: boolean) {
|
||||
let leadingComments: CommentRange[] | undefined;
|
||||
let currentDetachedCommentInfo: { nodePos: number, detachedCommentEndPos: number } | undefined;
|
||||
@@ -3775,7 +3775,7 @@ namespace ts {
|
||||
|
||||
}
|
||||
|
||||
export function writeCommentRange(text: string, lineMap: ReadonlyArray<number>, writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) {
|
||||
export function writeCommentRange(text: string, lineMap: readonly number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) {
|
||||
if (text.charCodeAt(commentPos + 1) === CharacterCodes.asterisk) {
|
||||
const firstCommentLineAndCharacter = computeLineAndCharacterOfPosition(lineMap, commentPos);
|
||||
const lineCount = lineMap.length;
|
||||
@@ -4786,7 +4786,7 @@ namespace ts {
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
export function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray<TextChangeRange>): TextChangeRange {
|
||||
export function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange {
|
||||
if (changes.length === 0) {
|
||||
return unchangedTextChangeRange;
|
||||
}
|
||||
@@ -5262,7 +5262,7 @@ namespace ts {
|
||||
*
|
||||
* For binding patterns, parameter tags are matched by position.
|
||||
*/
|
||||
export function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray<JSDocParameterTag> {
|
||||
export function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[] {
|
||||
if (param.name) {
|
||||
if (isIdentifier(param.name)) {
|
||||
const name = param.name.escapedText;
|
||||
@@ -5291,7 +5291,7 @@ namespace ts {
|
||||
* node are returned first, so in the previous example, the template
|
||||
* tag on the containing function expression would be first.
|
||||
*/
|
||||
export function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray<JSDocTemplateTag> {
|
||||
export function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[] {
|
||||
const name = param.name.escapedText;
|
||||
return getJSDocTags(param.parent).filter((tag): tag is JSDocTemplateTag =>
|
||||
isJSDocTemplateTag(tag) && tag.typeParameters.some(tp => tp.name.escapedText === name));
|
||||
@@ -5392,7 +5392,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Get all JSDoc tags related to a node, including those on parent nodes. */
|
||||
export function getJSDocTags(node: Node): ReadonlyArray<JSDocTag> {
|
||||
export function getJSDocTags(node: Node): readonly JSDocTag[] {
|
||||
let tags = (node as JSDocContainer).jsDocCache;
|
||||
// If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing.
|
||||
if (tags === undefined) {
|
||||
@@ -5409,7 +5409,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Gets all JSDoc tags of a specified kind, or undefined if not present. */
|
||||
export function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray<JSDocTag> {
|
||||
export function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[] {
|
||||
return getJSDocTags(node).filter(doc => doc.kind === kind);
|
||||
}
|
||||
|
||||
@@ -5417,7 +5417,7 @@ namespace ts {
|
||||
* Gets the effective type parameters. If the node was parsed in a
|
||||
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
|
||||
*/
|
||||
export function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray<TypeParameterDeclaration> {
|
||||
export function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[] {
|
||||
if (isJSDocSignature(node)) {
|
||||
return emptyArray;
|
||||
}
|
||||
@@ -6221,7 +6221,7 @@ namespace ts {
|
||||
// Node Arrays
|
||||
|
||||
/* @internal */
|
||||
export function isNodeArray<T extends Node>(array: ReadonlyArray<T>): array is NodeArray<T> {
|
||||
export function isNodeArray<T extends Node>(array: readonly T[]): array is NodeArray<T> {
|
||||
return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
|
||||
}
|
||||
|
||||
@@ -7607,7 +7607,7 @@ namespace ts {
|
||||
* Reduce an array of path components to a more simplified path by navigating any
|
||||
* `"."` or `".."` entries in the path.
|
||||
*/
|
||||
export function reducePathComponents(components: ReadonlyArray<string>) {
|
||||
export function reducePathComponents(components: readonly string[]) {
|
||||
if (!some(components)) return [];
|
||||
const reduced = [components[0]];
|
||||
for (let i = 1; i < components.length; i++) {
|
||||
@@ -7646,7 +7646,7 @@ namespace ts {
|
||||
* Formats a parsed path consisting of a root component (at index 0) and zero or more path
|
||||
* segments (at indices > 0).
|
||||
*/
|
||||
export function getPathFromPathComponents(pathComponents: ReadonlyArray<string>) {
|
||||
export function getPathFromPathComponents(pathComponents: readonly string[]) {
|
||||
if (pathComponents.length === 0) return "";
|
||||
|
||||
const root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
|
||||
@@ -7657,7 +7657,7 @@ namespace ts {
|
||||
return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
|
||||
}
|
||||
|
||||
function getPathWithoutRoot(pathComponents: ReadonlyArray<string>) {
|
||||
function getPathWithoutRoot(pathComponents: readonly string[]) {
|
||||
if (pathComponents.length === 0) return "";
|
||||
return pathComponents.slice(1).join(directorySeparator);
|
||||
}
|
||||
@@ -7756,8 +7756,8 @@ namespace ts {
|
||||
* getBaseFileName("/path/to/file.js", ".ext", true) === "file.js"
|
||||
* ```
|
||||
*/
|
||||
export function getBaseFileName(path: string, extensions: string | ReadonlyArray<string>, ignoreCase: boolean): string;
|
||||
export function getBaseFileName(path: string, extensions?: string | ReadonlyArray<string>, ignoreCase?: boolean) {
|
||||
export function getBaseFileName(path: string, extensions: string | readonly string[], ignoreCase: boolean): string;
|
||||
export function getBaseFileName(path: string, extensions?: string | readonly string[], ignoreCase?: boolean) {
|
||||
path = normalizeSlashes(path);
|
||||
|
||||
// if the path provided is itself the root, then it has not file name.
|
||||
@@ -7964,7 +7964,7 @@ namespace ts {
|
||||
return stringContains(getBaseFileName(fileName), ".");
|
||||
}
|
||||
|
||||
export const commonPackageFolders: ReadonlyArray<string> = ["node_modules", "bower_components", "jspm_packages"];
|
||||
export const commonPackageFolders: readonly string[] = ["node_modules", "bower_components", "jspm_packages"];
|
||||
|
||||
const implicitExcludePathRegexPattern = `(?!(${commonPackageFolders.join("|")})(/|$))`;
|
||||
|
||||
@@ -8012,7 +8012,7 @@ namespace ts {
|
||||
exclude: excludeMatcher
|
||||
};
|
||||
|
||||
export function getRegularExpressionForWildcard(specs: ReadonlyArray<string> | undefined, basePath: string, usage: "files" | "directories" | "exclude"): string | undefined {
|
||||
export function getRegularExpressionForWildcard(specs: readonly string[] | undefined, basePath: string, usage: "files" | "directories" | "exclude"): string | undefined {
|
||||
const patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
|
||||
if (!patterns || !patterns.length) {
|
||||
return undefined;
|
||||
@@ -8024,7 +8024,7 @@ namespace ts {
|
||||
return `^(${pattern})${terminator}`;
|
||||
}
|
||||
|
||||
export function getRegularExpressionsForWildcards(specs: ReadonlyArray<string> | undefined, basePath: string, usage: "files" | "directories" | "exclude"): ReadonlyArray<string> | undefined {
|
||||
export function getRegularExpressionsForWildcards(specs: readonly string[] | undefined, basePath: string, usage: "files" | "directories" | "exclude"): readonly string[] | undefined {
|
||||
if (specs === undefined || specs.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -8122,22 +8122,22 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface FileSystemEntries {
|
||||
readonly files: ReadonlyArray<string>;
|
||||
readonly directories: ReadonlyArray<string>;
|
||||
readonly files: readonly string[];
|
||||
readonly directories: readonly string[];
|
||||
}
|
||||
|
||||
export interface FileMatcherPatterns {
|
||||
/** One pattern for each "include" spec. */
|
||||
includeFilePatterns: ReadonlyArray<string> | undefined;
|
||||
includeFilePatterns: readonly string[] | undefined;
|
||||
/** One pattern matching one of any of the "include" specs. */
|
||||
includeFilePattern: string | undefined;
|
||||
includeDirectoryPattern: string | undefined;
|
||||
excludePattern: string | undefined;
|
||||
basePaths: ReadonlyArray<string>;
|
||||
basePaths: readonly string[];
|
||||
}
|
||||
|
||||
/** @param path directory of the tsconfig.json */
|
||||
export function getFileMatcherPatterns(path: string, excludes: ReadonlyArray<string> | undefined, includes: ReadonlyArray<string> | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns {
|
||||
export function getFileMatcherPatterns(path: string, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns {
|
||||
path = normalizePath(path);
|
||||
currentDirectory = normalizePath(currentDirectory);
|
||||
const absolutePath = combinePaths(currentDirectory, path);
|
||||
@@ -8156,7 +8156,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** @param path directory of the tsconfig.json */
|
||||
export function matchFiles(path: string, extensions: ReadonlyArray<string> | undefined, excludes: ReadonlyArray<string> | undefined, includes: ReadonlyArray<string> | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string): string[] {
|
||||
export function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string): string[] {
|
||||
path = normalizePath(path);
|
||||
currentDirectory = normalizePath(currentDirectory);
|
||||
|
||||
@@ -8220,7 +8220,7 @@ namespace ts {
|
||||
/**
|
||||
* Computes the unique non-wildcard base paths amongst the provided include patterns.
|
||||
*/
|
||||
function getBasePaths(path: string, includes: ReadonlyArray<string> | undefined, useCaseSensitiveFileNames: boolean): string[] {
|
||||
function getBasePaths(path: string, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean): string[] {
|
||||
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
|
||||
const basePaths: string[] = [path];
|
||||
|
||||
@@ -8292,18 +8292,18 @@ namespace ts {
|
||||
/**
|
||||
* List of supported extensions in order of file resolution precedence.
|
||||
*/
|
||||
export const supportedTSExtensions: ReadonlyArray<Extension> = [Extension.Ts, Extension.Tsx, Extension.Dts];
|
||||
export const supportedTSExtensionsWithJson: ReadonlyArray<Extension> = [Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Json];
|
||||
export const supportedTSExtensions: readonly Extension[] = [Extension.Ts, Extension.Tsx, Extension.Dts];
|
||||
export const supportedTSExtensionsWithJson: readonly Extension[] = [Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Json];
|
||||
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
|
||||
export const supportedTSExtensionsForExtractExtension: ReadonlyArray<Extension> = [Extension.Dts, Extension.Ts, Extension.Tsx];
|
||||
export const supportedJSExtensions: ReadonlyArray<Extension> = [Extension.Js, Extension.Jsx];
|
||||
export const supportedJSAndJsonExtensions: ReadonlyArray<Extension> = [Extension.Js, Extension.Jsx, Extension.Json];
|
||||
const allSupportedExtensions: ReadonlyArray<Extension> = [...supportedTSExtensions, ...supportedJSExtensions];
|
||||
const allSupportedExtensionsWithJson: ReadonlyArray<Extension> = [...supportedTSExtensions, ...supportedJSExtensions, Extension.Json];
|
||||
export const supportedTSExtensionsForExtractExtension: readonly Extension[] = [Extension.Dts, Extension.Ts, Extension.Tsx];
|
||||
export const supportedJSExtensions: readonly Extension[] = [Extension.Js, Extension.Jsx];
|
||||
export const supportedJSAndJsonExtensions: readonly Extension[] = [Extension.Js, Extension.Jsx, Extension.Json];
|
||||
const allSupportedExtensions: readonly Extension[] = [...supportedTSExtensions, ...supportedJSExtensions];
|
||||
const allSupportedExtensionsWithJson: readonly Extension[] = [...supportedTSExtensions, ...supportedJSExtensions, Extension.Json];
|
||||
|
||||
export function getSupportedExtensions(options?: CompilerOptions): ReadonlyArray<Extension>;
|
||||
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: ReadonlyArray<FileExtensionInfo>): ReadonlyArray<string>;
|
||||
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: ReadonlyArray<FileExtensionInfo>): ReadonlyArray<string> {
|
||||
export function getSupportedExtensions(options?: CompilerOptions): readonly Extension[];
|
||||
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[];
|
||||
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[] {
|
||||
const needJsExtensions = options && options.allowJs;
|
||||
|
||||
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
||||
@@ -8318,7 +8318,7 @@ namespace ts {
|
||||
return deduplicate<string>(extensions, equateStringsCaseSensitive, compareStringsCaseSensitive);
|
||||
}
|
||||
|
||||
export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: ReadonlyArray<string>): ReadonlyArray<string> {
|
||||
export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[]): readonly string[] {
|
||||
if (!options || !options.resolveJsonModule) { return supportedExtensions; }
|
||||
if (supportedExtensions === allSupportedExtensions) { return allSupportedExtensionsWithJson; }
|
||||
if (supportedExtensions === supportedTSExtensions) { return supportedTSExtensionsWithJson; }
|
||||
@@ -8341,7 +8341,7 @@ namespace ts {
|
||||
return some(supportedTSExtensions, extension => fileExtensionIs(fileName, extension));
|
||||
}
|
||||
|
||||
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: ReadonlyArray<FileExtensionInfo>) {
|
||||
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]) {
|
||||
if (!fileName) { return false; }
|
||||
|
||||
const supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
|
||||
@@ -8366,7 +8366,7 @@ namespace ts {
|
||||
Lowest = DeclarationAndJavaScriptFiles,
|
||||
}
|
||||
|
||||
export function getExtensionPriority(path: string, supportedExtensions: ReadonlyArray<string>): ExtensionPriority {
|
||||
export function getExtensionPriority(path: string, supportedExtensions: readonly string[]): ExtensionPriority {
|
||||
for (let i = supportedExtensions.length - 1; i >= 0; i--) {
|
||||
if (fileExtensionIs(path, supportedExtensions[i])) {
|
||||
return adjustExtensionPriority(<ExtensionPriority>i, supportedExtensions);
|
||||
@@ -8381,7 +8381,7 @@ namespace ts {
|
||||
/**
|
||||
* Adjusts an extension priority to be the highest priority within the same range.
|
||||
*/
|
||||
export function adjustExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: ReadonlyArray<string>): ExtensionPriority {
|
||||
export function adjustExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: readonly string[]): ExtensionPriority {
|
||||
if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) {
|
||||
return ExtensionPriority.TypeScriptFiles;
|
||||
}
|
||||
@@ -8396,7 +8396,7 @@ namespace ts {
|
||||
/**
|
||||
* Gets the next lowest extension priority for a given priority.
|
||||
*/
|
||||
export function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: ReadonlyArray<string>): ExtensionPriority {
|
||||
export function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: readonly string[]): ExtensionPriority {
|
||||
if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) {
|
||||
return ExtensionPriority.DeclarationAndJavaScriptFiles;
|
||||
}
|
||||
@@ -8429,8 +8429,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function changeAnyExtension(path: string, ext: string): string;
|
||||
export function changeAnyExtension(path: string, ext: string, extensions: string | ReadonlyArray<string>, ignoreCase: boolean): string;
|
||||
export function changeAnyExtension(path: string, ext: string, extensions?: string | ReadonlyArray<string>, ignoreCase?: boolean) {
|
||||
export function changeAnyExtension(path: string, ext: string, extensions: string | readonly string[], ignoreCase: boolean): string;
|
||||
export function changeAnyExtension(path: string, ext: string, extensions?: string | readonly string[], ignoreCase?: boolean) {
|
||||
const pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
|
||||
return pathext ? path.slice(0, path.length - pathext.length) + (startsWith(ext, ".") ? ext : "." + ext) : path;
|
||||
}
|
||||
@@ -8477,7 +8477,7 @@ namespace ts {
|
||||
return find<Extension>(extensionsToRemove, e => fileExtensionIs(path, e));
|
||||
}
|
||||
|
||||
function getAnyExtensionFromPathWorker(path: string, extensions: string | ReadonlyArray<string>, stringEqualityComparer: (a: string, b: string) => boolean) {
|
||||
function getAnyExtensionFromPathWorker(path: string, extensions: string | readonly string[], stringEqualityComparer: (a: string, b: string) => boolean) {
|
||||
if (typeof extensions === "string") extensions = [extensions];
|
||||
for (let extension of extensions) {
|
||||
if (!startsWith(extension, ".")) extension = "." + extension;
|
||||
@@ -8498,8 +8498,8 @@ namespace ts {
|
||||
/**
|
||||
* Gets the file extension for a path, provided it is one of the provided extensions.
|
||||
*/
|
||||
export function getAnyExtensionFromPath(path: string, extensions: string | ReadonlyArray<string>, ignoreCase: boolean): string;
|
||||
export function getAnyExtensionFromPath(path: string, extensions?: string | ReadonlyArray<string>, ignoreCase?: boolean): string {
|
||||
export function getAnyExtensionFromPath(path: string, extensions: string | readonly string[], ignoreCase: boolean): string;
|
||||
export function getAnyExtensionFromPath(path: string, extensions?: string | readonly string[], ignoreCase?: boolean): string {
|
||||
// Retrieves any string from the final "." onwards from a base file name.
|
||||
// Unlike extensionFromPath, which throws an exception on unrecognized extensions.
|
||||
if (extensions) {
|
||||
@@ -8528,7 +8528,7 @@ namespace ts {
|
||||
* Return an exact match if possible, or a pattern match, or undefined.
|
||||
* (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.)
|
||||
*/
|
||||
export function matchPatternOrExact(patternStrings: ReadonlyArray<string>, candidate: string): string | Pattern | undefined {
|
||||
export function matchPatternOrExact(patternStrings: readonly string[], candidate: string): string | Pattern | undefined {
|
||||
const patterns: Pattern[] = [];
|
||||
for (const patternString of patternStrings) {
|
||||
const pattern = tryParsePattern(patternString);
|
||||
@@ -8546,7 +8546,7 @@ namespace ts {
|
||||
|
||||
export type Mutable<T extends object> = { -readonly [K in keyof T]: T[K] };
|
||||
|
||||
export function sliceAfter<T>(arr: ReadonlyArray<T>, value: T): ReadonlyArray<T> {
|
||||
export function sliceAfter<T>(arr: readonly T[], value: T): readonly T[] {
|
||||
const index = arr.indexOf(value);
|
||||
Debug.assert(index !== -1);
|
||||
return arr.slice(index);
|
||||
@@ -8560,7 +8560,7 @@ namespace ts {
|
||||
return diagnostic;
|
||||
}
|
||||
|
||||
export function minAndMax<T>(arr: ReadonlyArray<T>, getValue: (value: T) => number): { readonly min: number, readonly max: number } {
|
||||
export function minAndMax<T>(arr: readonly T[], getValue: (value: T) => number): { readonly min: number, readonly max: number } {
|
||||
Debug.assert(arr.length !== 0);
|
||||
let min = getValue(arr[0]);
|
||||
let max = min;
|
||||
|
||||
@@ -928,7 +928,7 @@ namespace ts {
|
||||
*
|
||||
* @param nodes The NodeArray.
|
||||
*/
|
||||
function extractSingleNode(nodes: ReadonlyArray<Node>): Node | undefined {
|
||||
function extractSingleNode(nodes: readonly Node[]): Node | undefined {
|
||||
Debug.assert(nodes.length <= 1, "Too many nodes written to output.");
|
||||
return singleOrUndefined(nodes);
|
||||
}
|
||||
@@ -1456,13 +1456,13 @@ namespace ts {
|
||||
/**
|
||||
* Merges generated lexical declarations into a new statement list.
|
||||
*/
|
||||
export function mergeLexicalEnvironment(statements: NodeArray<Statement>, declarations: ReadonlyArray<Statement> | undefined): NodeArray<Statement>;
|
||||
export function mergeLexicalEnvironment(statements: NodeArray<Statement>, declarations: readonly Statement[] | undefined): NodeArray<Statement>;
|
||||
|
||||
/**
|
||||
* Appends generated lexical declarations to an array of statements.
|
||||
*/
|
||||
export function mergeLexicalEnvironment(statements: Statement[], declarations: ReadonlyArray<Statement> | undefined): Statement[];
|
||||
export function mergeLexicalEnvironment(statements: Statement[] | NodeArray<Statement>, declarations: ReadonlyArray<Statement> | undefined) {
|
||||
export function mergeLexicalEnvironment(statements: Statement[], declarations: readonly Statement[] | undefined): Statement[];
|
||||
export function mergeLexicalEnvironment(statements: Statement[] | NodeArray<Statement>, declarations: readonly Statement[] | undefined) {
|
||||
if (!some(declarations)) {
|
||||
return statements;
|
||||
}
|
||||
@@ -1477,7 +1477,7 @@ namespace ts {
|
||||
*
|
||||
* @param nodes The NodeArray.
|
||||
*/
|
||||
export function liftToBlock(nodes: ReadonlyArray<Node>): Statement {
|
||||
export function liftToBlock(nodes: readonly Node[]): Statement {
|
||||
Debug.assert(every(nodes, isStatement), "Cannot lift nodes to a Block.");
|
||||
return <Statement>singleOrUndefined(nodes) || createBlock(<NodeArray<Statement>>nodes);
|
||||
}
|
||||
|
||||
+20
-20
@@ -88,7 +88,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getErrorCountForSummary(diagnostics: ReadonlyArray<Diagnostic>) {
|
||||
export function getErrorCountForSummary(diagnostics: readonly Diagnostic[]) {
|
||||
return countWhere(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
|
||||
}
|
||||
|
||||
@@ -110,12 +110,12 @@ namespace ts {
|
||||
export interface ProgramToEmitFilesAndReportErrors {
|
||||
getCurrentDirectory(): string;
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFiles(): ReadonlyArray<SourceFile>;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getConfigFileParsingDiagnostics(): ReadonlyArray<Diagnostic>;
|
||||
getSourceFiles(): readonly SourceFile[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult;
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ namespace ts {
|
||||
/**
|
||||
* Creates the watch compiler host from system for compiling root files and options in watch mode
|
||||
*/
|
||||
export function createWatchCompilerHostOfFilesAndCompilerOptions<T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram>(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray<ProjectReference>): WatchCompilerHostOfFilesAndCompilerOptions<T> {
|
||||
export function createWatchCompilerHostOfFilesAndCompilerOptions<T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram>(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions<T> {
|
||||
const host = createWatchCompilerHost(system, createProgram, reportDiagnostic || createDiagnosticReporter(system), reportWatchStatus) as WatchCompilerHostOfFilesAndCompilerOptions<T>;
|
||||
host.rootFiles = rootFiles;
|
||||
host.options = options;
|
||||
@@ -413,10 +413,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface IncrementalCompilationOptions {
|
||||
rootNames: ReadonlyArray<string>;
|
||||
rootNames: readonly string[];
|
||||
options: CompilerOptions;
|
||||
configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>;
|
||||
projectReferences?: ReadonlyArray<ProjectReference>;
|
||||
configFileParsingDiagnostics?: readonly Diagnostic[];
|
||||
projectReferences?: readonly ProjectReference[];
|
||||
host?: CompilerHost;
|
||||
reportDiagnostic?: DiagnosticReporter;
|
||||
reportErrorSummary?: ReportEmitErrorSummary;
|
||||
@@ -466,10 +466,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface IncrementalProgramOptions<T extends BuilderProgram> {
|
||||
rootNames: ReadonlyArray<string>;
|
||||
rootNames: readonly string[];
|
||||
options: CompilerOptions;
|
||||
configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>;
|
||||
projectReferences?: ReadonlyArray<ProjectReference>;
|
||||
configFileParsingDiagnostics?: readonly Diagnostic[];
|
||||
projectReferences?: readonly ProjectReference[];
|
||||
host?: CompilerHost;
|
||||
createProgram?: CreateProgram<T>;
|
||||
}
|
||||
@@ -485,7 +485,7 @@ namespace ts {
|
||||
|
||||
export type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void;
|
||||
/** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */
|
||||
export type CreateProgram<T extends BuilderProgram> = (rootNames: ReadonlyArray<string> | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>, projectReferences?: ReadonlyArray<ProjectReference> | undefined) => T;
|
||||
export type CreateProgram<T extends BuilderProgram> = (rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[] | undefined) => T;
|
||||
|
||||
/** Host that has watch functionality used in --watch mode */
|
||||
export interface WatchHost {
|
||||
@@ -531,7 +531,7 @@ namespace ts {
|
||||
/** If provided, used in resolutions as well as handling directory structure */
|
||||
getDirectories?(path: string): string[];
|
||||
/** If provided, used to cache and handle directory structure modifications */
|
||||
readDirectory?(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[];
|
||||
readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[];
|
||||
|
||||
/** Symbol links resolution */
|
||||
realpath?(path: string): string;
|
||||
@@ -575,7 +575,7 @@ namespace ts {
|
||||
options: CompilerOptions;
|
||||
|
||||
/** Project References */
|
||||
projectReferences?: ReadonlyArray<ProjectReference>;
|
||||
projectReferences?: readonly ProjectReference[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,7 +592,7 @@ namespace ts {
|
||||
* Used to generate source file names from the config file and its include, exclude, files rules
|
||||
* and also to cache the directory stucture
|
||||
*/
|
||||
readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[];
|
||||
readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -632,8 +632,8 @@ namespace ts {
|
||||
* Create the watch compiler host for either configFile or fileNames and its options
|
||||
*/
|
||||
export function createWatchCompilerHost<T extends BuilderProgram>(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile<T>;
|
||||
export function createWatchCompilerHost<T extends BuilderProgram>(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray<ProjectReference>): WatchCompilerHostOfFilesAndCompilerOptions<T>;
|
||||
export function createWatchCompilerHost<T extends BuilderProgram>(rootFilesOrConfigFileName: string | string[], options: CompilerOptions | undefined, system: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray<ProjectReference>): WatchCompilerHostOfFilesAndCompilerOptions<T> | WatchCompilerHostOfConfigFile<T> {
|
||||
export function createWatchCompilerHost<T extends BuilderProgram>(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions<T>;
|
||||
export function createWatchCompilerHost<T extends BuilderProgram>(rootFilesOrConfigFileName: string | string[], options: CompilerOptions | undefined, system: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions<T> | WatchCompilerHostOfConfigFile<T> {
|
||||
if (isArray(rootFilesOrConfigFileName)) {
|
||||
return createWatchCompilerHostOfFilesAndCompilerOptions(rootFilesOrConfigFileName, options!, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferences); // TODO: GH#18217
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ts {
|
||||
// TODO: GH#18217 Optional methods are frequently used as non-optional
|
||||
directoryExists?(path: string): boolean;
|
||||
getDirectories?(path: string): string[];
|
||||
readDirectory?(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[];
|
||||
readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[];
|
||||
realpath?(path: string): string;
|
||||
|
||||
createDirectory?(path: string): void;
|
||||
@@ -26,7 +26,7 @@ namespace ts {
|
||||
useCaseSensitiveFileNames: boolean;
|
||||
|
||||
getDirectories(path: string): string[];
|
||||
readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[];
|
||||
readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[];
|
||||
|
||||
/** Returns the queried result for the file exists and directory exists if at all it was done */
|
||||
addOrDeleteFileOrDirectory(fileOrDirectory: string, fileOrDirectoryPath: Path): FileAndDirectoryExistence | undefined;
|
||||
@@ -113,7 +113,7 @@ namespace ts {
|
||||
return getCanonicalFileName(name1) === getCanonicalFileName(name2);
|
||||
}
|
||||
|
||||
function hasEntry(entries: ReadonlyArray<string>, name: string) {
|
||||
function hasEntry(entries: readonly string[], name: string) {
|
||||
return some(entries, file => fileNameEqual(file, name));
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace ts {
|
||||
return host.getDirectories!(rootDir);
|
||||
}
|
||||
|
||||
function readDirectory(rootDir: string, extensions?: ReadonlyArray<string>, excludes?: ReadonlyArray<string>, includes?: ReadonlyArray<string>, depth?: number): string[] {
|
||||
function readDirectory(rootDir: string, extensions?: readonly string[], excludes?: readonly string[], includes?: readonly string[], depth?: number): string[] {
|
||||
const rootDirPath = toPath(rootDir);
|
||||
const result = tryReadDirectory(rootDir, rootDirPath);
|
||||
if (result) {
|
||||
|
||||
@@ -588,7 +588,7 @@ namespace ts.server {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getCodeFixesAtPosition(file: string, start: number, end: number, errorCodes: ReadonlyArray<number>): ReadonlyArray<CodeFixAction> {
|
||||
getCodeFixesAtPosition(file: string, start: number, end: number, errorCodes: readonly number[]): readonly CodeFixAction[] {
|
||||
const args: protocol.CodeFixRequestArgs = { ...this.createFileRangeRequestArgs(file, start, end), errorCodes };
|
||||
|
||||
const request = this.processRequest<protocol.CodeFixRequest>(CommandNames.GetCodeFixes, args);
|
||||
@@ -666,7 +666,7 @@ namespace ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
organizeImports(_scope: OrganizeImportsScope, _formatOptions: FormatCodeSettings): ReadonlyArray<FileTextChanges> {
|
||||
organizeImports(_scope: OrganizeImportsScope, _formatOptions: FormatCodeSettings): readonly FileTextChanges[] {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace compiler {
|
||||
* Correlates compilation inputs and outputs
|
||||
*/
|
||||
export interface CompilationOutput {
|
||||
readonly inputs: ReadonlyArray<documents.TextDocument>;
|
||||
readonly inputs: readonly documents.TextDocument[];
|
||||
readonly js: documents.TextDocument | undefined;
|
||||
readonly dts: documents.TextDocument | undefined;
|
||||
readonly map: documents.TextDocument | undefined;
|
||||
@@ -49,7 +49,7 @@ namespace compiler {
|
||||
public readonly program: ts.Program | undefined;
|
||||
public readonly result: ts.EmitResult | undefined;
|
||||
public readonly options: ts.CompilerOptions;
|
||||
public readonly diagnostics: ReadonlyArray<ts.Diagnostic>;
|
||||
public readonly diagnostics: readonly ts.Diagnostic[];
|
||||
public readonly js: ReadonlyMap<string, documents.TextDocument>;
|
||||
public readonly dts: ReadonlyMap<string, documents.TextDocument>;
|
||||
public readonly maps: ReadonlyMap<string, documents.TextDocument>;
|
||||
@@ -58,7 +58,7 @@ namespace compiler {
|
||||
private _inputs: documents.TextDocument[] = [];
|
||||
private _inputsAndOutputs: collections.SortedMap<string, CompilationOutput>;
|
||||
|
||||
constructor(host: fakes.CompilerHost, options: ts.CompilerOptions, program: ts.Program | undefined, result: ts.EmitResult | undefined, diagnostics: ReadonlyArray<ts.Diagnostic>) {
|
||||
constructor(host: fakes.CompilerHost, options: ts.CompilerOptions, program: ts.Program | undefined, result: ts.EmitResult | undefined, diagnostics: readonly ts.Diagnostic[]) {
|
||||
this.host = host;
|
||||
this.program = program;
|
||||
this.result = result;
|
||||
@@ -143,15 +143,15 @@ namespace compiler {
|
||||
return this.host.vfs;
|
||||
}
|
||||
|
||||
public get inputs(): ReadonlyArray<documents.TextDocument> {
|
||||
public get inputs(): readonly documents.TextDocument[] {
|
||||
return this._inputs;
|
||||
}
|
||||
|
||||
public get outputs(): ReadonlyArray<documents.TextDocument> {
|
||||
public get outputs(): readonly documents.TextDocument[] {
|
||||
return this.host.outputs;
|
||||
}
|
||||
|
||||
public get traces(): ReadonlyArray<string> {
|
||||
public get traces(): readonly string[] {
|
||||
return this.host.traces;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace compiler {
|
||||
return this._inputsAndOutputs.get(vpath.resolve(this.vfs.cwd(), path));
|
||||
}
|
||||
|
||||
public getInputs(path: string): ReadonlyArray<documents.TextDocument> | undefined {
|
||||
public getInputs(path: string): readonly documents.TextDocument[] | undefined {
|
||||
const outputs = this.getInputsAndOutputs(path);
|
||||
return outputs && outputs.inputs;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace documents {
|
||||
public readonly file: string;
|
||||
public readonly text: string;
|
||||
|
||||
private _lineStarts: ReadonlyArray<number> | undefined;
|
||||
private _lineStarts: readonly number[] | undefined;
|
||||
private _testFile: Harness.Compiler.TestFile | undefined;
|
||||
|
||||
constructor(file: string, text: string, meta?: Map<string, string>) {
|
||||
@@ -16,7 +16,7 @@ namespace documents {
|
||||
this.meta = meta || new Map<string, string>();
|
||||
}
|
||||
|
||||
public get lineStarts(): ReadonlyArray<number> {
|
||||
public get lineStarts(): readonly number[] {
|
||||
return this._lineStarts || (this._lineStarts = ts.computeLineStarts(this.text));
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ namespace documents {
|
||||
public readonly version: number;
|
||||
public readonly file: string;
|
||||
public readonly sourceRoot: string | undefined;
|
||||
public readonly sources: ReadonlyArray<string> = [];
|
||||
public readonly sourcesContent: ReadonlyArray<string> | undefined;
|
||||
public readonly mappings: ReadonlyArray<Mapping> = [];
|
||||
public readonly names: ReadonlyArray<string> | undefined;
|
||||
public readonly sources: readonly string[] = [];
|
||||
public readonly sourcesContent: readonly string[] | undefined;
|
||||
public readonly mappings: readonly Mapping[] = [];
|
||||
public readonly names: readonly string[] | undefined;
|
||||
|
||||
private static readonly _mappingRegExp = /([A-Za-z0-9+/]+),?|(;)|./g;
|
||||
private static readonly _sourceMappingURLRegExp = /^\/\/[#@]\s*sourceMappingURL\s*=\s*(.*?)\s*$/mig;
|
||||
@@ -156,11 +156,11 @@ namespace documents {
|
||||
return url === undefined ? undefined : this.fromUrl(url);
|
||||
}
|
||||
|
||||
public getMappingsForEmittedLine(emittedLine: number): ReadonlyArray<Mapping> | undefined {
|
||||
public getMappingsForEmittedLine(emittedLine: number): readonly Mapping[] | undefined {
|
||||
return this._emittedLineMappings[emittedLine];
|
||||
}
|
||||
|
||||
public getMappingsForSourceLine(sourceIndex: number, sourceLine: number): ReadonlyArray<Mapping> | undefined {
|
||||
public getMappingsForSourceLine(sourceIndex: number, sourceLine: number): readonly Mapping[] | undefined {
|
||||
const mappingsForSource = this._sourceLineMappings[sourceIndex];
|
||||
return mappingsForSource && mappingsForSource[sourceLine];
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace fakes {
|
||||
return result;
|
||||
}
|
||||
|
||||
public readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[] {
|
||||
public readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] {
|
||||
return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path));
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace fakes {
|
||||
return this.sys.getDirectories(path);
|
||||
}
|
||||
|
||||
public readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[] {
|
||||
public readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] {
|
||||
return this.sys.readDirectory(path, extensions, exclude, include, depth);
|
||||
}
|
||||
|
||||
|
||||
+88
-88
@@ -188,7 +188,7 @@ namespace FourSlash {
|
||||
|
||||
// Add input file which has matched file name with the given reference-file path.
|
||||
// This is necessary when resolveReference flag is specified
|
||||
private addMatchedInputFile(referenceFilePath: string, extensions: ReadonlyArray<string> | undefined) {
|
||||
private addMatchedInputFile(referenceFilePath: string, extensions: readonly string[] | undefined) {
|
||||
const inputFiles = this.inputFiles;
|
||||
const languageServiceAdapterHost = this.languageServiceAdapterHost;
|
||||
const didAdd = tryAdd(referenceFilePath);
|
||||
@@ -392,7 +392,7 @@ namespace FourSlash {
|
||||
this.goToPosition(marker.position);
|
||||
}
|
||||
|
||||
public goToEachMarker(markers: ReadonlyArray<Marker>, action: (marker: Marker, index: number) => void) {
|
||||
public goToEachMarker(markers: readonly Marker[], action: (marker: Marker, index: number) => void) {
|
||||
assert(markers.length);
|
||||
for (let i = 0; i < markers.length; i++) {
|
||||
this.goToMarker(markers[i]);
|
||||
@@ -493,7 +493,7 @@ namespace FourSlash {
|
||||
];
|
||||
}
|
||||
|
||||
private getAllDiagnostics(): ReadonlyArray<ts.Diagnostic> {
|
||||
private getAllDiagnostics(): readonly ts.Diagnostic[] {
|
||||
return ts.flatMap(this.languageServiceAdapterHost.getFilenames(), fileName => {
|
||||
if (!ts.isAnySupportedFileExtension(fileName)) {
|
||||
return [];
|
||||
@@ -534,7 +534,7 @@ namespace FourSlash {
|
||||
predicate(start!, start! + length!, startMarker.position, endMarker === undefined ? undefined : endMarker.position)); // TODO: GH#18217
|
||||
}
|
||||
|
||||
private printErrorLog(expectErrors: boolean, errors: ReadonlyArray<ts.Diagnostic>): void {
|
||||
private printErrorLog(expectErrors: boolean, errors: readonly ts.Diagnostic[]): void {
|
||||
if (expectErrors) {
|
||||
Harness.IO.log("Expected error not found. Error list is:");
|
||||
}
|
||||
@@ -631,7 +631,7 @@ namespace FourSlash {
|
||||
this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinitionAndBoundSpan());
|
||||
}
|
||||
|
||||
private getGoToDefinition(): ReadonlyArray<ts.DefinitionInfo> {
|
||||
private getGoToDefinition(): readonly ts.DefinitionInfo[] {
|
||||
return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)!;
|
||||
}
|
||||
|
||||
@@ -644,12 +644,12 @@ namespace FourSlash {
|
||||
this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition));
|
||||
}
|
||||
|
||||
private verifyGoToX(arg0: any, endMarkerNames: ArrayOrSingle<string> | undefined, getDefs: () => ReadonlyArray<ts.DefinitionInfo> | ts.DefinitionInfoAndBoundSpan | undefined) {
|
||||
private verifyGoToX(arg0: any, endMarkerNames: ArrayOrSingle<string> | undefined, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
|
||||
if (endMarkerNames) {
|
||||
this.verifyGoToXPlain(arg0, endMarkerNames, getDefs);
|
||||
}
|
||||
else if (ts.isArray(arg0)) {
|
||||
const pairs = arg0 as ReadonlyArray<[ArrayOrSingle<string>, ArrayOrSingle<string>]>;
|
||||
const pairs = arg0 as readonly [ArrayOrSingle<string>, ArrayOrSingle<string>][];
|
||||
for (const [start, end] of pairs) {
|
||||
this.verifyGoToXPlain(start, end, getDefs);
|
||||
}
|
||||
@@ -664,7 +664,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private verifyGoToXPlain(startMarkerNames: ArrayOrSingle<string>, endMarkerNames: ArrayOrSingle<string>, getDefs: () => ReadonlyArray<ts.DefinitionInfo> | ts.DefinitionInfoAndBoundSpan | undefined) {
|
||||
private verifyGoToXPlain(startMarkerNames: ArrayOrSingle<string>, endMarkerNames: ArrayOrSingle<string>, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
|
||||
for (const start of toArray(startMarkerNames)) {
|
||||
this.verifyGoToXSingle(start, endMarkerNames, getDefs);
|
||||
}
|
||||
@@ -676,14 +676,14 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private verifyGoToXSingle(startMarkerName: string, endMarkerNames: ArrayOrSingle<string>, getDefs: () => ReadonlyArray<ts.DefinitionInfo> | ts.DefinitionInfoAndBoundSpan | undefined) {
|
||||
private verifyGoToXSingle(startMarkerName: string, endMarkerNames: ArrayOrSingle<string>, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
|
||||
this.goToMarker(startMarkerName);
|
||||
this.verifyGoToXWorker(toArray(endMarkerNames), getDefs, startMarkerName);
|
||||
}
|
||||
|
||||
private verifyGoToXWorker(endMarkers: ReadonlyArray<string>, getDefs: () => ReadonlyArray<ts.DefinitionInfo> | ts.DefinitionInfoAndBoundSpan | undefined, startMarkerName?: string) {
|
||||
private verifyGoToXWorker(endMarkers: readonly string[], getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined, startMarkerName?: string) {
|
||||
const defs = getDefs();
|
||||
let definitions: ReadonlyArray<ts.DefinitionInfo>;
|
||||
let definitions: readonly ts.DefinitionInfo[];
|
||||
let testName: string;
|
||||
|
||||
if (!defs || ts.isArray(defs)) {
|
||||
@@ -859,7 +859,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private verifyCompletionsAreExactly(actual: ReadonlyArray<ts.CompletionEntry>, expected: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, marker?: ArrayOrSingle<string | Marker>) {
|
||||
private verifyCompletionsAreExactly(actual: readonly ts.CompletionEntry[], expected: readonly FourSlashInterface.ExpectedCompletionEntry[], marker?: ArrayOrSingle<string | Marker>) {
|
||||
// First pass: test that names are right. Then we'll test details.
|
||||
assert.deepEqual(actual.map(a => a.name), expected.map(e => typeof e === "string" ? e : e.name), marker ? "At marker " + JSON.stringify(marker) : undefined);
|
||||
|
||||
@@ -953,7 +953,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private verifyDocumentHighlightsRespectFilesList(files: ReadonlyArray<string>): void {
|
||||
private verifyDocumentHighlightsRespectFilesList(files: readonly string[]): void {
|
||||
const startFile = this.activeFile.fileName;
|
||||
for (const fileName of files) {
|
||||
const searchFileNames = startFile === fileName ? [startFile] : [startFile, fileName];
|
||||
@@ -964,7 +964,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyReferenceGroups(starts: ArrayOrSingle<string> | ArrayOrSingle<Range>, parts: ReadonlyArray<FourSlashInterface.ReferenceGroup>): void {
|
||||
public verifyReferenceGroups(starts: ArrayOrSingle<string> | ArrayOrSingle<Range>, parts: readonly FourSlashInterface.ReferenceGroup[]): void {
|
||||
interface ReferenceGroupJson {
|
||||
definition: string | { text: string, range: ts.TextSpan };
|
||||
references: ts.ReferenceEntry[];
|
||||
@@ -1012,9 +1012,9 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
// Necessary to have this function since `findReferences` isn't implemented in `client.ts`
|
||||
public verifyGetReferencesForServerTest(expected: ReadonlyArray<ts.ReferenceEntry>): void {
|
||||
public verifyGetReferencesForServerTest(expected: readonly ts.ReferenceEntry[]): void {
|
||||
const refs = this.getReferencesAtCaret();
|
||||
assert.deepEqual<ReadonlyArray<ts.ReferenceEntry> | undefined>(refs, expected);
|
||||
assert.deepEqual<readonly ts.ReferenceEntry[] | undefined>(refs, expected);
|
||||
}
|
||||
|
||||
public verifySingleReferenceGroup(definition: FourSlashInterface.ReferenceGroupDefinition, ranges?: Range[] | string) {
|
||||
@@ -1093,21 +1093,21 @@ namespace FourSlash {
|
||||
return this.languageService.findReferences(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
public getSyntacticDiagnostics(expected: ReadonlyArray<FourSlashInterface.Diagnostic>) {
|
||||
public getSyntacticDiagnostics(expected: readonly FourSlashInterface.Diagnostic[]) {
|
||||
const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
|
||||
this.testDiagnostics(expected, diagnostics, "error");
|
||||
}
|
||||
|
||||
public getSemanticDiagnostics(expected: ReadonlyArray<FourSlashInterface.Diagnostic>) {
|
||||
public getSemanticDiagnostics(expected: readonly FourSlashInterface.Diagnostic[]) {
|
||||
const diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName);
|
||||
this.testDiagnostics(expected, diagnostics, "error");
|
||||
}
|
||||
|
||||
public getSuggestionDiagnostics(expected: ReadonlyArray<FourSlashInterface.Diagnostic>): void {
|
||||
public getSuggestionDiagnostics(expected: readonly FourSlashInterface.Diagnostic[]): void {
|
||||
this.testDiagnostics(expected, this.languageService.getSuggestionDiagnostics(this.activeFile.fileName), "suggestion");
|
||||
}
|
||||
|
||||
private testDiagnostics(expected: ReadonlyArray<FourSlashInterface.Diagnostic>, diagnostics: ReadonlyArray<ts.Diagnostic>, category: string) {
|
||||
private testDiagnostics(expected: readonly FourSlashInterface.Diagnostic[], diagnostics: readonly ts.Diagnostic[], category: string) {
|
||||
assert.deepEqual(ts.realizeDiagnostics(diagnostics, "\n"), expected.map((e): ts.RealizedDiagnostic => ({
|
||||
message: e.message,
|
||||
category,
|
||||
@@ -1203,7 +1203,7 @@ namespace FourSlash {
|
||||
const references = this.languageService.findRenameLocations(
|
||||
this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments, providePrefixAndSuffixTextForRename);
|
||||
|
||||
const sort = (locations: ReadonlyArray<ts.RenameLocation> | undefined) =>
|
||||
const sort = (locations: readonly ts.RenameLocation[] | undefined) =>
|
||||
locations && ts.sort(locations, (r1, r2) => ts.compareStringsCaseSensitive(r1.fileName, r2.fileName) || r1.textSpan.start - r2.textSpan.start);
|
||||
assert.deepEqual(sort(references), sort(ranges.map((rangeOrOptions): ts.RenameLocation => {
|
||||
const { range, ...prefixSuffixText } = "range" in rangeOrOptions ? rangeOrOptions : { range: rangeOrOptions }; // eslint-disable-line no-in-operator
|
||||
@@ -1234,7 +1234,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifySignatureHelpPresence(expectPresent: boolean, triggerReason: ts.SignatureHelpTriggerReason | undefined, markers: ReadonlyArray<string | Marker>) {
|
||||
public verifySignatureHelpPresence(expectPresent: boolean, triggerReason: ts.SignatureHelpTriggerReason | undefined, markers: readonly (string | Marker)[]) {
|
||||
if (markers.length) {
|
||||
for (const marker of markers) {
|
||||
this.goToMarker(marker);
|
||||
@@ -1253,7 +1253,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifySignatureHelp(optionses: ReadonlyArray<FourSlashInterface.VerifySignatureHelpOptions>) {
|
||||
public verifySignatureHelp(optionses: readonly FourSlashInterface.VerifySignatureHelpOptions[]) {
|
||||
for (const options of optionses) {
|
||||
if (options.marker === undefined) {
|
||||
this.verifySignatureHelpWorker(options);
|
||||
@@ -1308,7 +1308,7 @@ namespace FourSlash {
|
||||
assert.equal(actualTag.text, expectedTag.text, this.assertionMessageAtLastKnownMarker("signature help tag " + actualTag.name));
|
||||
});
|
||||
|
||||
const allKeys: ReadonlyArray<keyof FourSlashInterface.VerifySignatureHelpOptions> = [
|
||||
const allKeys: readonly (keyof FourSlashInterface.VerifySignatureHelpOptions)[] = [
|
||||
"marker",
|
||||
"triggerReason",
|
||||
"overloadsCount",
|
||||
@@ -1448,7 +1448,7 @@ namespace FourSlash {
|
||||
Harness.Baseline.runBaseline(baselineFile, this.baselineCurrentFileLocations(pos => this.getBreakpointStatementLocation(pos)!));
|
||||
}
|
||||
|
||||
private getEmitFiles(): ReadonlyArray<FourSlashFile> {
|
||||
private getEmitFiles(): readonly FourSlashFile[] {
|
||||
// Find file to be emitted
|
||||
const emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on
|
||||
|
||||
@@ -1468,7 +1468,7 @@ namespace FourSlash {
|
||||
return emitFiles;
|
||||
}
|
||||
|
||||
public verifyGetEmitOutput(expectedOutputFiles: ReadonlyArray<string>): void {
|
||||
public verifyGetEmitOutput(expectedOutputFiles: readonly string[]): void {
|
||||
const outputFiles = ts.flatMap(this.getEmitFiles(), e => this.languageService.getEmitOutput(e.fileName).outputFiles);
|
||||
|
||||
assert.deepEqual(outputFiles.map(f => f.name), expectedOutputFiles);
|
||||
@@ -1802,7 +1802,7 @@ namespace FourSlash {
|
||||
* @returns The number of characters added to the file as a result of the edits.
|
||||
* May be negative.
|
||||
*/
|
||||
private applyEdits(fileName: string, edits: ReadonlyArray<ts.TextChange>, isFormattingEdit: boolean): number {
|
||||
private applyEdits(fileName: string, edits: readonly ts.TextChange[], isFormattingEdit: boolean): number {
|
||||
// Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters
|
||||
const oldContent = this.getFileContent(fileName);
|
||||
let runningOffset = 0;
|
||||
@@ -1964,7 +1964,7 @@ namespace FourSlash {
|
||||
|
||||
public verifyRangesInImplementationList(markerName: string) {
|
||||
this.goToMarker(markerName);
|
||||
const implementations: ReadonlyArray<ImplementationLocationInformation> = this.languageService.getImplementationAtPosition(this.activeFile.fileName, this.currentCaretPosition)!;
|
||||
const implementations: readonly ImplementationLocationInformation[] = this.languageService.getImplementationAtPosition(this.activeFile.fileName, this.currentCaretPosition)!;
|
||||
if (!implementations || !implementations.length) {
|
||||
this.raiseError("verifyRangesInImplementationList failed - expected to find at least one implementation location but got 0");
|
||||
}
|
||||
@@ -2376,7 +2376,7 @@ namespace FourSlash {
|
||||
ts.Debug.assertEqual(fixWithId!.fixAllDescription, fixAllDescription);
|
||||
|
||||
const { changes, commands } = this.languageService.getCombinedCodeFix({ type: "file", fileName: this.activeFile.fileName }, fixId, this.formatCodeSettings, ts.emptyOptions);
|
||||
assert.deepEqual<ReadonlyArray<{}> | undefined>(commands, expectedCommands);
|
||||
assert.deepEqual<readonly {}[] | undefined>(commands, expectedCommands);
|
||||
this.verifyNewContent({ newFileContent }, changes);
|
||||
}
|
||||
|
||||
@@ -2412,7 +2412,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private verifyNewContent({ newFileContent, newRangeContent }: FourSlashInterface.NewContentOptions, changes: ReadonlyArray<ts.FileTextChanges>): void {
|
||||
private verifyNewContent({ newFileContent, newRangeContent }: FourSlashInterface.NewContentOptions, changes: readonly ts.FileTextChanges[]): void {
|
||||
if (newRangeContent !== undefined) {
|
||||
assert(newFileContent === undefined);
|
||||
assert(changes.length === 1, "Affected 0 or more than 1 file, must use 'newFileContent' instead of 'newRangeContent'");
|
||||
@@ -2442,7 +2442,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private verifyNewContentAfterChange({ newFileContent, newRangeContent }: FourSlashInterface.NewContentOptions, changedFiles: ReadonlyArray<string>) {
|
||||
private verifyNewContentAfterChange({ newFileContent, newRangeContent }: FourSlashInterface.NewContentOptions, changedFiles: readonly string[]) {
|
||||
const assertedChangedFiles = !newFileContent || typeof newFileContent === "string"
|
||||
? [this.activeFile.fileName]
|
||||
: ts.getOwnKeys(newFileContent);
|
||||
@@ -2468,7 +2468,7 @@ namespace FourSlash {
|
||||
* Rerieves a codefix satisfying the parameters, or undefined if no such codefix is found.
|
||||
* @param fileName Path to file where error should be retrieved from.
|
||||
*/
|
||||
private getCodeFixes(fileName: string, errorCode?: number, preferences: ts.UserPreferences = ts.emptyOptions): ReadonlyArray<ts.CodeFixAction> {
|
||||
private getCodeFixes(fileName: string, errorCode?: number, preferences: ts.UserPreferences = ts.emptyOptions): readonly ts.CodeFixAction[] {
|
||||
const diagnosticsForCodeFix = this.getDiagnostics(fileName, /*includeSuggestions*/ true).map(diagnostic => ({
|
||||
start: diagnostic.start,
|
||||
length: diagnostic.length,
|
||||
@@ -2484,7 +2484,7 @@ namespace FourSlash {
|
||||
});
|
||||
}
|
||||
|
||||
private applyChanges(changes: ReadonlyArray<ts.FileTextChanges>): void {
|
||||
private applyChanges(changes: readonly ts.FileTextChanges[]): void {
|
||||
for (const change of changes) {
|
||||
this.applyEdits(change.fileName, change.textChanges, /*isFormattingEdit*/ false);
|
||||
}
|
||||
@@ -2642,7 +2642,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyNavigateTo(options: ReadonlyArray<FourSlashInterface.VerifyNavigateToOptions>): void {
|
||||
public verifyNavigateTo(options: readonly FourSlashInterface.VerifyNavigateToOptions[]): void {
|
||||
for (const { pattern, expected, fileName } of options) {
|
||||
const items = this.languageService.getNavigateToItems(pattern, /*maxResultCount*/ undefined, fileName);
|
||||
this.assertObjectsEqual(items, expected.map((e): ts.NavigateToItem => ({
|
||||
@@ -2738,7 +2738,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private getDocumentHighlightsAtCurrentPosition(fileNamesToSearch: ReadonlyArray<string>) {
|
||||
private getDocumentHighlightsAtCurrentPosition(fileNamesToSearch: readonly string[]) {
|
||||
const filesToSearch = fileNamesToSearch.map(name => ts.combinePaths(this.basePath, name));
|
||||
return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch);
|
||||
}
|
||||
@@ -2793,7 +2793,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private verifyDocumentHighlights(expectedRanges: Range[], fileNames: ReadonlyArray<string> = [this.activeFile.fileName]) {
|
||||
private verifyDocumentHighlights(expectedRanges: Range[], fileNames: readonly string[] = [this.activeFile.fileName]) {
|
||||
fileNames = ts.map(fileNames, ts.normalizePath);
|
||||
const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNames) || [];
|
||||
|
||||
@@ -2881,7 +2881,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyRefactorsAvailable(names: ReadonlyArray<string>): void {
|
||||
public verifyRefactorsAvailable(names: readonly string[]): void {
|
||||
assert.deepEqual(unique(this.getApplicableRefactorsAtSelection(), r => r.name), names);
|
||||
}
|
||||
|
||||
@@ -2986,7 +2986,7 @@ namespace FourSlash {
|
||||
this.verifyNewContent({ newFileContent: options.newFileContents }, editInfo.edits);
|
||||
}
|
||||
|
||||
private testNewFileContents(edits: ReadonlyArray<ts.FileTextChanges>, newFileContents: { [fileName: string]: string }, description: string): void {
|
||||
private testNewFileContents(edits: readonly ts.FileTextChanges[], newFileContents: { [fileName: string]: string }, description: string): void {
|
||||
for (const { fileName, textChanges } of edits) {
|
||||
const newContent = newFileContents[fileName];
|
||||
if (newContent === undefined) {
|
||||
@@ -3099,7 +3099,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private tryFindFileWorker(name: string): { readonly file: FourSlashFile | undefined; readonly availableNames: ReadonlyArray<string>; } {
|
||||
private tryFindFileWorker(name: string): { readonly file: FourSlashFile | undefined; readonly availableNames: readonly string[]; } {
|
||||
name = ts.normalizePath(name);
|
||||
// names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName
|
||||
name = name.indexOf("/") === -1 ? (this.basePath + "/" + name) : name;
|
||||
@@ -3163,10 +3163,10 @@ namespace FourSlash {
|
||||
private getApplicableRefactorsAtSelection() {
|
||||
return this.getApplicableRefactorsWorker(this.getSelection(), this.activeFile.fileName);
|
||||
}
|
||||
private getApplicableRefactors(rangeOrMarker: Range | Marker, preferences = ts.emptyOptions): ReadonlyArray<ts.ApplicableRefactorInfo> {
|
||||
private getApplicableRefactors(rangeOrMarker: Range | Marker, preferences = ts.emptyOptions): readonly ts.ApplicableRefactorInfo[] {
|
||||
return this.getApplicableRefactorsWorker("position" in rangeOrMarker ? rangeOrMarker.position : rangeOrMarker, rangeOrMarker.fileName, preferences); // eslint-disable-line no-in-operator
|
||||
}
|
||||
private getApplicableRefactorsWorker(positionOrRange: number | ts.TextRange, fileName: string, preferences = ts.emptyOptions): ReadonlyArray<ts.ApplicableRefactorInfo> {
|
||||
private getApplicableRefactorsWorker(positionOrRange: number | ts.TextRange, fileName: string, preferences = ts.emptyOptions): readonly ts.ApplicableRefactorInfo[] {
|
||||
return this.languageService.getApplicableRefactors(fileName, positionOrRange, preferences) || ts.emptyArray;
|
||||
}
|
||||
|
||||
@@ -3175,7 +3175,7 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
function updateTextRangeForTextChanges({ pos, end }: ts.TextRange, textChanges: ReadonlyArray<ts.TextChange>): ts.TextRange {
|
||||
function updateTextRangeForTextChanges({ pos, end }: ts.TextRange, textChanges: readonly ts.TextChange[]): ts.TextRange {
|
||||
forEachTextChange(textChanges, change => {
|
||||
const update = (p: number): number => updatePosition(p, change.span.start, ts.textSpanEnd(change.span), change.newText);
|
||||
pos = update(pos);
|
||||
@@ -3185,7 +3185,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
/** Apply each textChange in order, updating future changes to account for the text offset of previous changes. */
|
||||
function forEachTextChange(changes: ReadonlyArray<ts.TextChange>, cb: (change: ts.TextChange) => void): void {
|
||||
function forEachTextChange(changes: readonly ts.TextChange[], cb: (change: ts.TextChange) => void): void {
|
||||
// Copy this so we don't ruin someone else's copy
|
||||
changes = JSON.parse(JSON.stringify(changes));
|
||||
for (let i = 0; i < changes.length; i++) {
|
||||
@@ -3659,7 +3659,7 @@ ${code}
|
||||
}
|
||||
|
||||
/** Collects an array of unique outputs. */
|
||||
function unique<T>(inputs: ReadonlyArray<T>, getOutput: (t: T) => string): string[] {
|
||||
function unique<T>(inputs: readonly T[], getOutput: (t: T) => string): string[] {
|
||||
const set = ts.createMap<true>();
|
||||
for (const input of inputs) {
|
||||
const out = getOutput(input);
|
||||
@@ -3668,7 +3668,7 @@ ${code}
|
||||
return ts.arrayFrom(set.keys());
|
||||
}
|
||||
|
||||
function toArray<T>(x: ArrayOrSingle<T>): ReadonlyArray<T> {
|
||||
function toArray<T>(x: ArrayOrSingle<T>): readonly T[] {
|
||||
return ts.isArray(x) ? x : [x];
|
||||
}
|
||||
|
||||
@@ -3693,7 +3693,7 @@ ${code}
|
||||
return s.replace(/\s/g, "");
|
||||
}
|
||||
|
||||
function findDuplicatedElement<T>(a: ReadonlyArray<T>, equal: (a: T, b: T) => boolean): T | undefined {
|
||||
function findDuplicatedElement<T>(a: readonly T[], equal: (a: T, b: T) => boolean): T | undefined {
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
for (let j = i + 1; j < a.length; j++) {
|
||||
if (equal(a[i], a[j])) {
|
||||
@@ -3777,9 +3777,9 @@ namespace FourSlashInterface {
|
||||
this.state.goToMarker(name);
|
||||
}
|
||||
|
||||
public eachMarker(markers: ReadonlyArray<string>, action: (marker: FourSlash.Marker, index: number) => void): void;
|
||||
public eachMarker(markers: readonly string[], action: (marker: FourSlash.Marker, index: number) => void): void;
|
||||
public eachMarker(action: (marker: FourSlash.Marker, index: number) => void): void;
|
||||
public eachMarker(a: ReadonlyArray<string> | ((marker: FourSlash.Marker, index: number) => void), b?: (marker: FourSlash.Marker, index: number) => void): void {
|
||||
public eachMarker(a: readonly string[] | ((marker: FourSlash.Marker, index: number) => void), b?: (marker: FourSlash.Marker, index: number) => void): void {
|
||||
const markers = typeof a === "function" ? this.state.getMarkers() : a.map(m => this.state.getMarkerByName(m));
|
||||
this.state.goToEachMarker(markers, typeof a === "function" ? a : b!);
|
||||
}
|
||||
@@ -3913,7 +3913,7 @@ namespace FourSlashInterface {
|
||||
this.state.verifyApplicableRefactorAvailableForRange(this.negative);
|
||||
}
|
||||
|
||||
public refactorsAvailable(names: ReadonlyArray<string>): void {
|
||||
public refactorsAvailable(names: readonly string[]): void {
|
||||
this.state.verifyRefactorsAvailable(names);
|
||||
}
|
||||
|
||||
@@ -4030,7 +4030,7 @@ namespace FourSlashInterface {
|
||||
this.state.verifyNoReferences(markerNameOrRange);
|
||||
}
|
||||
|
||||
public getReferencesForServerTest(expected: ReadonlyArray<ts.ReferenceEntry>) {
|
||||
public getReferencesForServerTest(expected: readonly ts.ReferenceEntry[]) {
|
||||
this.state.verifyGetReferencesForServerTest(expected);
|
||||
}
|
||||
|
||||
@@ -4062,7 +4062,7 @@ namespace FourSlashInterface {
|
||||
this.state.baselineCurrentFileNameOrDottedNameSpans();
|
||||
}
|
||||
|
||||
public getEmitOutput(expectedOutputFiles: ReadonlyArray<string>): void {
|
||||
public getEmitOutput(expectedOutputFiles: readonly string[]): void {
|
||||
this.state.verifyGetEmitOutput(expectedOutputFiles);
|
||||
}
|
||||
|
||||
@@ -4219,15 +4219,15 @@ namespace FourSlashInterface {
|
||||
this.state.verifyQuickInfoDisplayParts(kind, kindModifiers, textSpan, displayParts, documentation, tags);
|
||||
}
|
||||
|
||||
public getSyntacticDiagnostics(expected: ReadonlyArray<Diagnostic>) {
|
||||
public getSyntacticDiagnostics(expected: readonly Diagnostic[]) {
|
||||
this.state.getSyntacticDiagnostics(expected);
|
||||
}
|
||||
|
||||
public getSemanticDiagnostics(expected: ReadonlyArray<Diagnostic>) {
|
||||
public getSemanticDiagnostics(expected: readonly Diagnostic[]) {
|
||||
this.state.getSemanticDiagnostics(expected);
|
||||
}
|
||||
|
||||
public getSuggestionDiagnostics(expected: ReadonlyArray<Diagnostic>) {
|
||||
public getSuggestionDiagnostics(expected: readonly Diagnostic[]) {
|
||||
this.state.getSuggestionDiagnostics(expected);
|
||||
}
|
||||
|
||||
@@ -4578,13 +4578,13 @@ namespace FourSlashInterface {
|
||||
sortText: SortText.GlobalsOrKeywords
|
||||
});
|
||||
}
|
||||
export const keywordsWithUndefined: ReadonlyArray<ExpectedCompletionEntryObject> = res;
|
||||
export const keywords: ReadonlyArray<ExpectedCompletionEntryObject> = keywordsWithUndefined.filter(k => k.name !== "undefined");
|
||||
export const keywordsWithUndefined: readonly ExpectedCompletionEntryObject[] = res;
|
||||
export const keywords: readonly ExpectedCompletionEntryObject[] = keywordsWithUndefined.filter(k => k.name !== "undefined");
|
||||
|
||||
export const typeKeywords: ReadonlyArray<ExpectedCompletionEntryObject> =
|
||||
export const typeKeywords: readonly ExpectedCompletionEntryObject[] =
|
||||
["false", "null", "true", "void", "any", "boolean", "keyof", "never", "readonly", "number", "object", "string", "symbol", "undefined", "unique", "unknown", "bigint"].map(keywordEntry);
|
||||
|
||||
const globalTypeDecls: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
const globalTypeDecls: readonly ExpectedCompletionEntryObject[] = [
|
||||
interfaceEntry("Symbol"),
|
||||
typeEntry("PropertyKey"),
|
||||
interfaceEntry("PropertyDescriptor"),
|
||||
@@ -4689,7 +4689,7 @@ namespace FourSlashInterface {
|
||||
sortText: SortText.GlobalsOrKeywords
|
||||
};
|
||||
export const globalTypes = globalTypesPlus([]);
|
||||
export function globalTypesPlus(plus: ReadonlyArray<ExpectedCompletionEntry>): ReadonlyArray<ExpectedCompletionEntry> {
|
||||
export function globalTypesPlus(plus: readonly ExpectedCompletionEntry[]): readonly ExpectedCompletionEntry[] {
|
||||
return [
|
||||
globalThisEntry,
|
||||
...globalTypeDecls,
|
||||
@@ -4698,10 +4698,10 @@ namespace FourSlashInterface {
|
||||
];
|
||||
}
|
||||
|
||||
export const typeAssertionKeywords: ReadonlyArray<ExpectedCompletionEntry> =
|
||||
export const typeAssertionKeywords: readonly ExpectedCompletionEntry[] =
|
||||
globalTypesPlus([keywordEntry("const")]);
|
||||
|
||||
function getInJsKeywords(keywords: ReadonlyArray<ExpectedCompletionEntryObject>): ReadonlyArray<ExpectedCompletionEntryObject> {
|
||||
function getInJsKeywords(keywords: readonly ExpectedCompletionEntryObject[]): readonly ExpectedCompletionEntryObject[] {
|
||||
return keywords.filter(keyword => {
|
||||
switch (keyword.name) {
|
||||
case "enum":
|
||||
@@ -4737,19 +4737,19 @@ namespace FourSlashInterface {
|
||||
});
|
||||
}
|
||||
|
||||
export const classElementKeywords: ReadonlyArray<ExpectedCompletionEntryObject> =
|
||||
export const classElementKeywords: readonly ExpectedCompletionEntryObject[] =
|
||||
["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"].map(keywordEntry);
|
||||
|
||||
export const classElementInJsKeywords = getInJsKeywords(classElementKeywords);
|
||||
|
||||
export const constructorParameterKeywords: ReadonlyArray<ExpectedCompletionEntryObject> =
|
||||
export const constructorParameterKeywords: readonly ExpectedCompletionEntryObject[] =
|
||||
["private", "protected", "public", "readonly"].map((name): ExpectedCompletionEntryObject => ({
|
||||
name,
|
||||
kind: "keyword",
|
||||
sortText: SortText.GlobalsOrKeywords
|
||||
}));
|
||||
|
||||
export const functionMembers: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
export const functionMembers: readonly ExpectedCompletionEntryObject[] = [
|
||||
methodEntry("apply"),
|
||||
methodEntry("call"),
|
||||
methodEntry("bind"),
|
||||
@@ -4759,7 +4759,7 @@ namespace FourSlashInterface {
|
||||
propertyEntry("caller"),
|
||||
];
|
||||
|
||||
export const stringMembers: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
export const stringMembers: readonly ExpectedCompletionEntryObject[] = [
|
||||
methodEntry("toString"),
|
||||
methodEntry("charAt"),
|
||||
methodEntry("charCodeAt"),
|
||||
@@ -4783,14 +4783,14 @@ namespace FourSlashInterface {
|
||||
methodEntry("valueOf"),
|
||||
];
|
||||
|
||||
export const functionMembersWithPrototype: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
export const functionMembersWithPrototype: readonly ExpectedCompletionEntryObject[] = [
|
||||
...functionMembers.slice(0, 4),
|
||||
propertyEntry("prototype"),
|
||||
...functionMembers.slice(4),
|
||||
];
|
||||
|
||||
// TODO: Shouldn't propose type keywords in statement position
|
||||
export const statementKeywordsWithTypes: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
export const statementKeywordsWithTypes: readonly ExpectedCompletionEntryObject[] = [
|
||||
"break",
|
||||
"case",
|
||||
"catch",
|
||||
@@ -4850,7 +4850,7 @@ namespace FourSlashInterface {
|
||||
"bigint",
|
||||
].map(keywordEntry);
|
||||
|
||||
export const statementKeywords: ReadonlyArray<ExpectedCompletionEntryObject> = statementKeywordsWithTypes.filter(k => {
|
||||
export const statementKeywords: readonly ExpectedCompletionEntryObject[] = statementKeywordsWithTypes.filter(k => {
|
||||
const name = k.name;
|
||||
switch (name) {
|
||||
case "false":
|
||||
@@ -4868,7 +4868,7 @@ namespace FourSlashInterface {
|
||||
|
||||
export const statementInJsKeywords = getInJsKeywords(statementKeywords);
|
||||
|
||||
export const globalsVars: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
export const globalsVars: readonly ExpectedCompletionEntryObject[] = [
|
||||
functionEntry("eval"),
|
||||
functionEntry("parseInt"),
|
||||
functionEntry("parseFloat"),
|
||||
@@ -4913,7 +4913,7 @@ namespace FourSlashInterface {
|
||||
moduleEntry("Intl"),
|
||||
];
|
||||
|
||||
const globalKeywordsInsideFunction: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
const globalKeywordsInsideFunction: readonly ExpectedCompletionEntryObject[] = [
|
||||
"break",
|
||||
"case",
|
||||
"catch",
|
||||
@@ -4965,7 +4965,7 @@ namespace FourSlashInterface {
|
||||
sortText: SortText.GlobalsOrKeywords
|
||||
};
|
||||
// TODO: many of these are inappropriate to always provide
|
||||
export const globalsInsideFunction = (plus: ReadonlyArray<ExpectedCompletionEntry>): ReadonlyArray<ExpectedCompletionEntry> => [
|
||||
export const globalsInsideFunction = (plus: readonly ExpectedCompletionEntry[]): readonly ExpectedCompletionEntry[] => [
|
||||
{ name: "arguments", kind: "local var" },
|
||||
...plus,
|
||||
globalThisEntry,
|
||||
@@ -4977,7 +4977,7 @@ namespace FourSlashInterface {
|
||||
const globalInJsKeywordsInsideFunction = getInJsKeywords(globalKeywordsInsideFunction);
|
||||
|
||||
// TODO: many of these are inappropriate to always provide
|
||||
export const globalsInJsInsideFunction = (plus: ReadonlyArray<ExpectedCompletionEntry>): ReadonlyArray<ExpectedCompletionEntry> => [
|
||||
export const globalsInJsInsideFunction = (plus: readonly ExpectedCompletionEntry[]): readonly ExpectedCompletionEntry[] => [
|
||||
{ name: "arguments", kind: "local var" },
|
||||
globalThisEntry,
|
||||
...globalsVars,
|
||||
@@ -4987,7 +4987,7 @@ namespace FourSlashInterface {
|
||||
];
|
||||
|
||||
// TODO: many of these are inappropriate to always provide
|
||||
export const globalKeywords: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
export const globalKeywords: readonly ExpectedCompletionEntryObject[] = [
|
||||
"break",
|
||||
"case",
|
||||
"catch",
|
||||
@@ -5049,7 +5049,7 @@ namespace FourSlashInterface {
|
||||
|
||||
export const globalInJsKeywords = getInJsKeywords(globalKeywords);
|
||||
|
||||
export const insideMethodKeywords: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
export const insideMethodKeywords: readonly ExpectedCompletionEntryObject[] = [
|
||||
"break",
|
||||
"case",
|
||||
"catch",
|
||||
@@ -5097,21 +5097,21 @@ namespace FourSlashInterface {
|
||||
|
||||
export const insideMethodInJsKeywords = getInJsKeywords(insideMethodKeywords);
|
||||
|
||||
export const globals: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
export const globals: readonly ExpectedCompletionEntryObject[] = [
|
||||
globalThisEntry,
|
||||
...globalsVars,
|
||||
undefinedVarEntry,
|
||||
...globalKeywords
|
||||
];
|
||||
|
||||
export const globalsInJs: ReadonlyArray<ExpectedCompletionEntryObject> = [
|
||||
export const globalsInJs: readonly ExpectedCompletionEntryObject[] = [
|
||||
globalThisEntry,
|
||||
...globalsVars,
|
||||
undefinedVarEntry,
|
||||
...globalInJsKeywords
|
||||
];
|
||||
|
||||
export function globalsPlus(plus: ReadonlyArray<ExpectedCompletionEntry>): ReadonlyArray<ExpectedCompletionEntry> {
|
||||
export function globalsPlus(plus: readonly ExpectedCompletionEntry[]): readonly ExpectedCompletionEntry[] {
|
||||
return [
|
||||
globalThisEntry,
|
||||
...globalsVars,
|
||||
@@ -5120,7 +5120,7 @@ namespace FourSlashInterface {
|
||||
...globalKeywords];
|
||||
}
|
||||
|
||||
export function globalsInJsPlus(plus: ReadonlyArray<ExpectedCompletionEntry>): ReadonlyArray<ExpectedCompletionEntry> {
|
||||
export function globalsInJsPlus(plus: readonly ExpectedCompletionEntry[]): readonly ExpectedCompletionEntry[] {
|
||||
return [
|
||||
globalThisEntry,
|
||||
...globalsVars,
|
||||
@@ -5157,7 +5157,7 @@ namespace FourSlashInterface {
|
||||
readonly text?: string;
|
||||
readonly documentation?: string;
|
||||
readonly sourceDisplay?: string;
|
||||
readonly tags?: ReadonlyArray<ts.JSDocTagInfo>;
|
||||
readonly tags?: readonly ts.JSDocTagInfo[];
|
||||
readonly sortText?: ts.Completions.SortText;
|
||||
}
|
||||
|
||||
@@ -5188,14 +5188,14 @@ namespace FourSlashInterface {
|
||||
/** @default false */
|
||||
readonly isVariadic?: boolean;
|
||||
/** @default ts.emptyArray */
|
||||
readonly tags?: ReadonlyArray<ts.JSDocTagInfo>;
|
||||
readonly tags?: readonly ts.JSDocTagInfo[];
|
||||
readonly triggerReason?: ts.SignatureHelpTriggerReason;
|
||||
}
|
||||
|
||||
export interface VerifyNavigateToOptions {
|
||||
readonly pattern: string;
|
||||
readonly fileName?: string;
|
||||
readonly expected: ReadonlyArray<ExpectedNavigateToItem>;
|
||||
readonly expected: readonly ExpectedNavigateToItem[];
|
||||
}
|
||||
|
||||
export interface ExpectedNavigateToItem {
|
||||
@@ -5209,7 +5209,7 @@ namespace FourSlashInterface {
|
||||
readonly containerKind?: ts.ScriptElementKind;
|
||||
}
|
||||
|
||||
export type ArrayOrSingle<T> = T | ReadonlyArray<T>;
|
||||
export type ArrayOrSingle<T> = T | readonly T[];
|
||||
|
||||
export interface VerifyCompletionListContainsOptions extends ts.UserPreferences {
|
||||
triggerCharacter?: ts.CompletionsTriggerCharacter;
|
||||
@@ -5220,7 +5220,7 @@ namespace FourSlashInterface {
|
||||
}
|
||||
|
||||
export interface VerifyDocumentHighlightsOptions {
|
||||
filesToSearch?: ReadonlyArray<string>;
|
||||
filesToSearch?: readonly string[];
|
||||
}
|
||||
|
||||
export type NewFileContent = string | { readonly [filename: string]: string };
|
||||
@@ -5237,7 +5237,7 @@ namespace FourSlashInterface {
|
||||
readonly index?: number;
|
||||
readonly preferences?: ts.UserPreferences;
|
||||
readonly applyChanges?: boolean;
|
||||
readonly commands?: ReadonlyArray<ts.CodeActionCommand>;
|
||||
readonly commands?: readonly ts.CodeActionCommand[];
|
||||
}
|
||||
|
||||
export interface VerifyCodeFixAvailableOptions {
|
||||
@@ -5249,13 +5249,13 @@ namespace FourSlashInterface {
|
||||
fixId: string;
|
||||
fixAllDescription: string;
|
||||
newFileContent: NewFileContent;
|
||||
commands: ReadonlyArray<{}>;
|
||||
commands: readonly {}[];
|
||||
}
|
||||
|
||||
export interface VerifyRefactorOptions {
|
||||
name: string;
|
||||
actionName: string;
|
||||
refactors: ReadonlyArray<ts.ApplicableRefactorInfo>;
|
||||
refactors: readonly ts.ApplicableRefactorInfo[];
|
||||
}
|
||||
|
||||
export interface VerifyCompletionActionOptions extends NewContentOptions {
|
||||
@@ -5284,10 +5284,10 @@ namespace FourSlashInterface {
|
||||
readonly preferences?: ts.UserPreferences;
|
||||
}
|
||||
|
||||
export type RenameLocationsOptions = ReadonlyArray<RenameLocationOptions> | {
|
||||
export type RenameLocationsOptions = readonly RenameLocationOptions[] | {
|
||||
readonly findInStrings?: boolean;
|
||||
readonly findInComments?: boolean;
|
||||
readonly ranges: ReadonlyArray<RenameLocationOptions>;
|
||||
readonly ranges: readonly RenameLocationOptions[];
|
||||
readonly providePrefixAndSuffixTextForRename?: boolean;
|
||||
};
|
||||
export type RenameLocationOptions = FourSlash.Range | { readonly range: FourSlash.Range, readonly prefixText?: string, readonly suffixText?: string };
|
||||
|
||||
+13
-13
@@ -16,7 +16,7 @@ const assert: typeof _chai.assert = _chai.assert;
|
||||
}
|
||||
assertDeepImpl(a, b, msg);
|
||||
|
||||
function arrayExtraKeysObject(a: ReadonlyArray<{} | null | undefined>): object {
|
||||
function arrayExtraKeysObject(a: readonly ({} | null | undefined)[]): object {
|
||||
const obj: { [key: string]: {} | null | undefined } = {};
|
||||
for (const key in a) {
|
||||
if (Number.isNaN(Number(key))) {
|
||||
@@ -177,7 +177,7 @@ namespace Utils {
|
||||
return a !== undefined && typeof a.pos === "number";
|
||||
}
|
||||
|
||||
export function convertDiagnostics(diagnostics: ReadonlyArray<ts.Diagnostic>) {
|
||||
export function convertDiagnostics(diagnostics: readonly ts.Diagnostic[]) {
|
||||
return diagnostics.map(convertDiagnostic);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace Utils {
|
||||
o.containsParseError = true;
|
||||
}
|
||||
|
||||
for (const propertyName of Object.getOwnPropertyNames(n) as ReadonlyArray<keyof ts.SourceFile | keyof ts.Identifier>) {
|
||||
for (const propertyName of Object.getOwnPropertyNames(n) as readonly (keyof ts.SourceFile | keyof ts.Identifier)[]) {
|
||||
switch (propertyName) {
|
||||
case "parent":
|
||||
case "symbol":
|
||||
@@ -303,7 +303,7 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
export function assertDiagnosticsEquals(array1: ReadonlyArray<ts.Diagnostic>, array2: ReadonlyArray<ts.Diagnostic>) {
|
||||
export function assertDiagnosticsEquals(array1: readonly ts.Diagnostic[], array2: readonly ts.Diagnostic[]) {
|
||||
if (array1 === array2) {
|
||||
return;
|
||||
}
|
||||
@@ -462,7 +462,7 @@ namespace Harness {
|
||||
getExecutingFilePath(): string;
|
||||
getWorkspaceRoot(): string;
|
||||
exit(exitCode?: number): void;
|
||||
readDirectory(path: string, extension?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): ReadonlyArray<string>;
|
||||
readDirectory(path: string, extension?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): readonly string[];
|
||||
getAccessibleFileSystemEntries(dirname: string): ts.FileSystemEntries;
|
||||
tryEnableSourceMapsForHost?(): void;
|
||||
getEnvironmentVariable?(name: string): string;
|
||||
@@ -875,8 +875,8 @@ namespace Harness {
|
||||
currentDirectory: string;
|
||||
}
|
||||
|
||||
export function prepareDeclarationCompilationContext(inputFiles: ReadonlyArray<TestFile>,
|
||||
otherFiles: ReadonlyArray<TestFile>,
|
||||
export function prepareDeclarationCompilationContext(inputFiles: readonly TestFile[],
|
||||
otherFiles: readonly TestFile[],
|
||||
result: compiler.CompilationResult,
|
||||
harnessSettings: TestCaseParser.CompilerSettings & HarnessOptions,
|
||||
options: ts.CompilerOptions,
|
||||
@@ -955,12 +955,12 @@ namespace Harness {
|
||||
return { declInputFiles, declOtherFiles, declResult: output };
|
||||
}
|
||||
|
||||
export function minimalDiagnosticsToString(diagnostics: ReadonlyArray<ts.Diagnostic>, pretty?: boolean) {
|
||||
export function minimalDiagnosticsToString(diagnostics: readonly ts.Diagnostic[], pretty?: boolean) {
|
||||
const host = { getCanonicalFileName, getCurrentDirectory: () => "", getNewLine: () => IO.newLine() };
|
||||
return (pretty ? ts.formatDiagnosticsWithColorAndContext : ts.formatDiagnostics)(diagnostics, host);
|
||||
}
|
||||
|
||||
export function getErrorBaseline(inputFiles: ReadonlyArray<TestFile>, diagnostics: ReadonlyArray<ts.Diagnostic>, pretty?: boolean) {
|
||||
export function getErrorBaseline(inputFiles: readonly TestFile[], diagnostics: readonly ts.Diagnostic[], pretty?: boolean) {
|
||||
let outputLines = "";
|
||||
const gen = iterateErrorBaseline(inputFiles, diagnostics, { pretty });
|
||||
for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) {
|
||||
@@ -975,7 +975,7 @@ namespace Harness {
|
||||
|
||||
export const diagnosticSummaryMarker = "__diagnosticSummary";
|
||||
export const globalErrorsMarker = "__globalErrors";
|
||||
export function *iterateErrorBaseline(inputFiles: ReadonlyArray<TestFile>, diagnostics: ReadonlyArray<ts.Diagnostic>, options?: { pretty?: boolean, caseSensitive?: boolean, currentDirectory?: string }): IterableIterator<[string, string, number]> {
|
||||
export function *iterateErrorBaseline(inputFiles: readonly TestFile[], diagnostics: readonly ts.Diagnostic[], options?: { pretty?: boolean, caseSensitive?: boolean, currentDirectory?: string }): IterableIterator<[string, string, number]> {
|
||||
diagnostics = ts.sort(diagnostics, ts.compareDiagnostics);
|
||||
let outputLines = "";
|
||||
// Count up all errors that were found in files other than lib.d.ts so we don't miss any
|
||||
@@ -1127,7 +1127,7 @@ namespace Harness {
|
||||
assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors");
|
||||
}
|
||||
|
||||
export function doErrorBaseline(baselinePath: string, inputFiles: ReadonlyArray<TestFile>, errors: ReadonlyArray<ts.Diagnostic>, pretty?: boolean) {
|
||||
export function doErrorBaseline(baselinePath: string, inputFiles: readonly TestFile[], errors: readonly ts.Diagnostic[], pretty?: boolean) {
|
||||
Baseline.runBaseline(baselinePath.replace(/\.tsx?$/, ".errors.txt"),
|
||||
!errors || (errors.length === 0) ? null : getErrorBaseline(inputFiles, errors, pretty)); // eslint-disable-line no-null/no-null
|
||||
}
|
||||
@@ -1291,7 +1291,7 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export function doJsEmitBaseline(baselinePath: string, header: string, options: ts.CompilerOptions, result: compiler.CompilationResult, tsConfigFiles: ReadonlyArray<TestFile>, toBeCompiled: ReadonlyArray<TestFile>, otherFiles: ReadonlyArray<TestFile>, harnessSettings: TestCaseParser.CompilerSettings) {
|
||||
export function doJsEmitBaseline(baselinePath: string, header: string, options: ts.CompilerOptions, result: compiler.CompilationResult, tsConfigFiles: readonly TestFile[], toBeCompiled: readonly TestFile[], otherFiles: readonly TestFile[], harnessSettings: TestCaseParser.CompilerSettings) {
|
||||
if (!options.noEmit && !options.emitDeclarationOnly && result.js.size === 0 && result.diagnostics.length === 0) {
|
||||
throw new Error("Expected at least one js file to be emitted or at least one error to be created.");
|
||||
}
|
||||
@@ -1349,7 +1349,7 @@ namespace Harness {
|
||||
return "//// [" + fileName + "]\r\n" + utils.removeTestPathPrefixes(file.text);
|
||||
}
|
||||
|
||||
export function collateOutputs(outputFiles: ReadonlyArray<documents.TextDocument>): string {
|
||||
export function collateOutputs(outputFiles: readonly documents.TextDocument[]): string {
|
||||
const gen = iterateOutputs(outputFiles);
|
||||
// Emit them
|
||||
let result = "";
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace Harness.LanguageService {
|
||||
return this.sys.fileExists(fileName);
|
||||
}
|
||||
|
||||
readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[] {
|
||||
readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] {
|
||||
return this.sys.readDirectory(path, extensions, exclude, include, depth);
|
||||
}
|
||||
|
||||
@@ -558,10 +558,10 @@ namespace Harness.LanguageService {
|
||||
getApplicableRefactors(): ts.ApplicableRefactorInfo[] {
|
||||
throw new Error("Not supported on the shim.");
|
||||
}
|
||||
organizeImports(_scope: ts.OrganizeImportsScope, _formatOptions: ts.FormatCodeSettings): ReadonlyArray<ts.FileTextChanges> {
|
||||
organizeImports(_scope: ts.OrganizeImportsScope, _formatOptions: ts.FormatCodeSettings): readonly ts.FileTextChanges[] {
|
||||
throw new Error("Not supported on the shim.");
|
||||
}
|
||||
getEditsForFileRename(): ReadonlyArray<ts.FileTextChanges> {
|
||||
getEditsForFileRename(): readonly ts.FileTextChanges[] {
|
||||
throw new Error("Not supported on the shim.");
|
||||
}
|
||||
getEmitOutput(fileName: string): ts.EmitOutput {
|
||||
@@ -724,7 +724,7 @@ namespace Harness.LanguageService {
|
||||
return ts.sys.getEnvironmentVariable(name);
|
||||
}
|
||||
|
||||
readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[] {
|
||||
readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] {
|
||||
return this.host.readDirectory(path, extensions, exclude, include, depth);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,11 +62,11 @@ interface IoLog {
|
||||
}[];
|
||||
directoriesRead: {
|
||||
path: string,
|
||||
extensions: ReadonlyArray<string> | undefined,
|
||||
exclude: ReadonlyArray<string> | undefined,
|
||||
include: ReadonlyArray<string> | undefined,
|
||||
extensions: readonly string[] | undefined,
|
||||
exclude: readonly string[] | undefined,
|
||||
include: readonly string[] | undefined,
|
||||
depth: number | undefined,
|
||||
result: ReadonlyArray<string>,
|
||||
result: readonly string[],
|
||||
}[];
|
||||
useCaseSensitiveFileNames?: boolean;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Harness.SourceMapRecorder {
|
||||
let sourceMapNames: string[] | null | undefined;
|
||||
|
||||
let jsFile: documents.TextDocument;
|
||||
let jsLineMap: ReadonlyArray<number>;
|
||||
let jsLineMap: readonly number[];
|
||||
let tsCode: string;
|
||||
let tsLineMap: number[];
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Harness.SourceMapRecorder {
|
||||
writeJsFileLines(jsLineMap.length);
|
||||
}
|
||||
|
||||
function getTextOfLine(line: number, lineMap: ReadonlyArray<number>, code: string) {
|
||||
function getTextOfLine(line: number, lineMap: readonly number[], code: string) {
|
||||
const startPos = lineMap[line];
|
||||
const endPos = lineMap[line + 1];
|
||||
const text = code.substring(startPos, endPos);
|
||||
@@ -275,7 +275,7 @@ namespace Harness.SourceMapRecorder {
|
||||
}
|
||||
}
|
||||
|
||||
export function getSourceMapRecord(sourceMapDataList: ReadonlyArray<ts.SourceMapEmitResult>, program: ts.Program, jsFiles: ReadonlyArray<documents.TextDocument>, declarationFiles: ReadonlyArray<documents.TextDocument>) {
|
||||
export function getSourceMapRecord(sourceMapDataList: readonly ts.SourceMapEmitResult[], program: ts.Program, jsFiles: readonly documents.TextDocument[], declarationFiles: readonly documents.TextDocument[]) {
|
||||
const sourceMapRecorder = new Compiler.WriterAggregator();
|
||||
|
||||
for (let i = 0; i < sourceMapDataList.length; i++) {
|
||||
|
||||
+1
-1
@@ -1160,7 +1160,7 @@ namespace vfs {
|
||||
|
||||
export interface FileSystemCreateOptions extends FileSystemOptions {
|
||||
// Sets the documents to add to the file system.
|
||||
documents?: ReadonlyArray<documents.TextDocument>;
|
||||
documents?: readonly documents.TextDocument[];
|
||||
}
|
||||
|
||||
export type Axis = "ancestors" | "ancestors-or-self" | "self" | "descendants-or-self" | "descendants";
|
||||
|
||||
@@ -39,7 +39,7 @@ interface Array<T> {}`
|
||||
environmentVariables?: Map<string>;
|
||||
}
|
||||
|
||||
export function createWatchedSystem(fileOrFolderList: ReadonlyArray<FileOrFolderOrSymLink>, params?: TestServerHostCreationParameters): TestServerHost {
|
||||
export function createWatchedSystem(fileOrFolderList: readonly FileOrFolderOrSymLink[], params?: TestServerHostCreationParameters): TestServerHost {
|
||||
if (!params) {
|
||||
params = {};
|
||||
}
|
||||
@@ -54,7 +54,7 @@ interface Array<T> {}`
|
||||
return host;
|
||||
}
|
||||
|
||||
export function createServerHost(fileOrFolderList: ReadonlyArray<FileOrFolderOrSymLink>, params?: TestServerHostCreationParameters): TestServerHost {
|
||||
export function createServerHost(fileOrFolderList: readonly FileOrFolderOrSymLink[], params?: TestServerHostCreationParameters): TestServerHost {
|
||||
if (!params) {
|
||||
params = {};
|
||||
}
|
||||
@@ -128,7 +128,7 @@ interface Array<T> {}`
|
||||
return s && isString((<FsSymLink>s).symLink);
|
||||
}
|
||||
|
||||
function invokeWatcherCallbacks<T>(callbacks: ReadonlyArray<T> | undefined, invokeCallback: (cb: T) => void): void {
|
||||
function invokeWatcherCallbacks<T>(callbacks: readonly T[] | undefined, invokeCallback: (cb: T) => void): void {
|
||||
if (callbacks) {
|
||||
// The array copy is made to ensure that even if one of the callback removes the callbacks,
|
||||
// we dont miss any callbacks following it
|
||||
@@ -139,7 +139,7 @@ interface Array<T> {}`
|
||||
}
|
||||
}
|
||||
|
||||
function getDiffInKeys<T>(map: Map<T>, expectedKeys: ReadonlyArray<string>) {
|
||||
function getDiffInKeys<T>(map: Map<T>, expectedKeys: readonly string[]) {
|
||||
if (map.size === expectedKeys.length) {
|
||||
return "";
|
||||
}
|
||||
@@ -166,11 +166,11 @@ interface Array<T> {}`
|
||||
return `\n\nNotInActual: ${notInActual}\nDuplicates: ${duplicates}\nInActualButNotInExpected: ${inActualNotExpected}`;
|
||||
}
|
||||
|
||||
export function verifyMapSize(caption: string, map: Map<any>, expectedKeys: ReadonlyArray<string>) {
|
||||
export function verifyMapSize(caption: string, map: Map<any>, expectedKeys: readonly string[]) {
|
||||
assert.equal(map.size, expectedKeys.length, `${caption}: incorrect size of map: Actual keys: ${arrayFrom(map.keys())} Expected: ${expectedKeys}${getDiffInKeys(map, expectedKeys)}`);
|
||||
}
|
||||
|
||||
function checkMapKeys(caption: string, map: Map<any>, expectedKeys: ReadonlyArray<string>) {
|
||||
function checkMapKeys(caption: string, map: Map<any>, expectedKeys: readonly string[]) {
|
||||
verifyMapSize(caption, map, expectedKeys);
|
||||
for (const name of expectedKeys) {
|
||||
assert.isTrue(map.has(name), `${caption} is expected to contain ${name}, actual keys: ${arrayFrom(map.keys())}`);
|
||||
@@ -178,8 +178,8 @@ interface Array<T> {}`
|
||||
}
|
||||
|
||||
export function checkMultiMapKeyCount(caption: string, actual: MultiMap<any>, expectedKeys: ReadonlyMap<number>): void;
|
||||
export function checkMultiMapKeyCount(caption: string, actual: MultiMap<any>, expectedKeys: ReadonlyArray<string>, eachKeyCount: number): void;
|
||||
export function checkMultiMapKeyCount(caption: string, actual: MultiMap<any>, expectedKeysMapOrArray: ReadonlyMap<number> | ReadonlyArray<string>, eachKeyCount?: number) {
|
||||
export function checkMultiMapKeyCount(caption: string, actual: MultiMap<any>, expectedKeys: readonly string[], eachKeyCount: number): void;
|
||||
export function checkMultiMapKeyCount(caption: string, actual: MultiMap<any>, expectedKeysMapOrArray: ReadonlyMap<number> | readonly string[], eachKeyCount?: number) {
|
||||
const expectedKeys = isArray(expectedKeysMapOrArray) ? arrayToMap(expectedKeysMapOrArray, s => s, () => eachKeyCount!) : expectedKeysMapOrArray;
|
||||
verifyMapSize(caption, actual, arrayFrom(expectedKeys.keys()));
|
||||
expectedKeys.forEach((count, name) => {
|
||||
@@ -188,7 +188,7 @@ interface Array<T> {}`
|
||||
});
|
||||
}
|
||||
|
||||
export function checkArray(caption: string, actual: ReadonlyArray<string>, expected: ReadonlyArray<string>) {
|
||||
export function checkArray(caption: string, actual: readonly string[], expected: readonly string[]) {
|
||||
checkMapKeys(caption, arrayToMap(actual, identity), expected);
|
||||
assert.equal(actual.length, expected.length, `${caption}: incorrect actual number of files, expected:\r\n${expected.join("\r\n")}\r\ngot: ${actual.join("\r\n")}`);
|
||||
for (const f of expected) {
|
||||
@@ -201,8 +201,8 @@ interface Array<T> {}`
|
||||
}
|
||||
|
||||
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: ReadonlyMap<number>): void;
|
||||
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: ReadonlyArray<string>, eachFileWatchCount: number): void;
|
||||
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: ReadonlyMap<number> | ReadonlyArray<string>, eachFileWatchCount?: number) {
|
||||
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: readonly string[], eachFileWatchCount: number): void;
|
||||
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: ReadonlyMap<number> | readonly string[], eachFileWatchCount?: number) {
|
||||
if (isArray(expectedFiles)) {
|
||||
checkMultiMapKeyCount("watchedFiles", host.watchedFiles, expectedFiles, eachFileWatchCount!);
|
||||
}
|
||||
@@ -216,8 +216,8 @@ interface Array<T> {}`
|
||||
}
|
||||
|
||||
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: ReadonlyMap<number>, recursive: boolean): void;
|
||||
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: ReadonlyArray<string>, eachDirectoryWatchCount: number, recursive: boolean): void;
|
||||
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: ReadonlyMap<number> | ReadonlyArray<string>, recursiveOrEachDirectoryWatchCount: boolean | number, recursive?: boolean) {
|
||||
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: readonly string[], eachDirectoryWatchCount: number, recursive: boolean): void;
|
||||
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: ReadonlyMap<number> | readonly string[], recursiveOrEachDirectoryWatchCount: boolean | number, recursive?: boolean) {
|
||||
if (isArray(expectedDirectories)) {
|
||||
checkMultiMapKeyCount(`watchedDirectories${recursive ? " recursive" : ""}`, recursive ? host.watchedDirectoriesRecursive : host.watchedDirectories, expectedDirectories, recursiveOrEachDirectoryWatchCount as number);
|
||||
}
|
||||
@@ -227,7 +227,7 @@ interface Array<T> {}`
|
||||
}
|
||||
}
|
||||
|
||||
export function checkOutputContains(host: TestServerHost, expected: ReadonlyArray<string>) {
|
||||
export function checkOutputContains(host: TestServerHost, expected: readonly string[]) {
|
||||
const mapExpected = arrayToSet(expected);
|
||||
const mapSeen = createMap<true>();
|
||||
for (const f of host.getOutput()) {
|
||||
@@ -240,7 +240,7 @@ interface Array<T> {}`
|
||||
assert.equal(mapExpected.size, 0, `Output has missing ${JSON.stringify(arrayFrom(mapExpected.keys()))} in ${JSON.stringify(host.getOutput())}`);
|
||||
}
|
||||
|
||||
export function checkOutputDoesNotContain(host: TestServerHost, expectedToBeAbsent: string[] | ReadonlyArray<string>) {
|
||||
export function checkOutputDoesNotContain(host: TestServerHost, expectedToBeAbsent: string[] | readonly string[]) {
|
||||
const mapExpectedToBeAbsent = arrayToSet(expectedToBeAbsent);
|
||||
for (const f of host.getOutput()) {
|
||||
assert.isFalse(mapExpectedToBeAbsent.has(f), `Contains ${f} in ${JSON.stringify(host.getOutput())}`);
|
||||
@@ -348,7 +348,7 @@ interface Array<T> {}`
|
||||
private readonly customRecursiveWatchDirectory: HostWatchDirectory | undefined;
|
||||
public require: ((initialPath: string, moduleName: string) => server.RequireResult) | undefined;
|
||||
|
||||
constructor(public withSafeList: boolean, public useCaseSensitiveFileNames: boolean, executingFilePath: string, currentDirectory: string, fileOrFolderorSymLinkList: ReadonlyArray<FileOrFolderOrSymLink>, public readonly newLine = "\n", public readonly useWindowsStylePath?: boolean, private readonly environmentVariables?: Map<string>) {
|
||||
constructor(public withSafeList: boolean, public useCaseSensitiveFileNames: boolean, executingFilePath: string, currentDirectory: string, fileOrFolderorSymLinkList: readonly FileOrFolderOrSymLink[], public readonly newLine = "\n", public readonly useWindowsStylePath?: boolean, private readonly environmentVariables?: Map<string>) {
|
||||
this.getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
this.toPath = s => toPath(s, currentDirectory, this.getCanonicalFileName);
|
||||
this.executingFilePath = this.getHostSpecificPath(executingFilePath);
|
||||
@@ -429,11 +429,11 @@ interface Array<T> {}`
|
||||
return new Date(this.time);
|
||||
}
|
||||
|
||||
reloadFS(fileOrFolderOrSymLinkList: ReadonlyArray<FileOrFolderOrSymLink>, options?: Partial<ReloadWatchInvokeOptions>) {
|
||||
reloadFS(fileOrFolderOrSymLinkList: readonly FileOrFolderOrSymLink[], options?: Partial<ReloadWatchInvokeOptions>) {
|
||||
const mapNewLeaves = createMap<true>();
|
||||
const isNewFs = this.fs.size === 0;
|
||||
fileOrFolderOrSymLinkList = fileOrFolderOrSymLinkList.concat(this.withSafeList ? safeList : []);
|
||||
const filesOrFoldersToLoad: ReadonlyArray<FileOrFolderOrSymLink> = !this.useWindowsStylePath ? fileOrFolderOrSymLinkList :
|
||||
const filesOrFoldersToLoad: readonly FileOrFolderOrSymLink[] = !this.useWindowsStylePath ? fileOrFolderOrSymLinkList :
|
||||
fileOrFolderOrSymLinkList.map<FileOrFolderOrSymLink>(f => {
|
||||
const result = clone(f);
|
||||
result.path = this.getHostSpecificPath(f.path);
|
||||
@@ -826,7 +826,7 @@ interface Array<T> {}`
|
||||
return [];
|
||||
}
|
||||
|
||||
readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[] {
|
||||
readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] {
|
||||
return matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, (dir) => {
|
||||
const directories: string[] = [];
|
||||
const files: string[] = [];
|
||||
@@ -973,7 +973,7 @@ interface Array<T> {}`
|
||||
this.output.push(message);
|
||||
}
|
||||
|
||||
getOutput(): ReadonlyArray<string> {
|
||||
getOutput(): readonly string[] {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace vpath {
|
||||
return extname(path, ".map", /*ignoreCase*/ false).length > 0;
|
||||
}
|
||||
|
||||
const javaScriptSourceMapExtensions: ReadonlyArray<string> = [".js.map", ".jsx.map"];
|
||||
const javaScriptSourceMapExtensions: readonly string[] = [".js.map", ".jsx.map"];
|
||||
|
||||
export function isJavaScriptSourceMap(path: string) {
|
||||
return extname(path, javaScriptSourceMapExtensions, /*ignoreCase*/ false).length > 0;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ts.JsTyping {
|
||||
directoryExists(path: string): boolean;
|
||||
fileExists(fileName: string): boolean;
|
||||
readFile(path: string, encoding?: string): string | undefined;
|
||||
readDirectory(rootDir: string, extensions: ReadonlyArray<string>, excludes: ReadonlyArray<string> | undefined, includes: ReadonlyArray<string> | undefined, depth?: number): string[];
|
||||
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[];
|
||||
}
|
||||
|
||||
interface PackageJson {
|
||||
@@ -29,7 +29,7 @@ namespace ts.JsTyping {
|
||||
return availableVersion.compareTo(cachedTyping.version) <= 0;
|
||||
}
|
||||
|
||||
export const nodeCoreModuleList: ReadonlyArray<string> = [
|
||||
export const nodeCoreModuleList: readonly string[] = [
|
||||
"assert",
|
||||
"async_hooks",
|
||||
"buffer",
|
||||
@@ -109,7 +109,7 @@ namespace ts.JsTyping {
|
||||
safeList: SafeList,
|
||||
packageNameToTypingLocation: ReadonlyMap<CachedTyping>,
|
||||
typeAcquisition: TypeAcquisition,
|
||||
unresolvedImports: ReadonlyArray<string>,
|
||||
unresolvedImports: readonly string[],
|
||||
typesRegistry: ReadonlyMap<MapLike<string>>):
|
||||
{ cachedTypingPaths: string[], newTypingNames: string[], filesToWatch: string[] } {
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace ts.JsTyping {
|
||||
inferredTypings.set(typingName, undefined!); // TODO: GH#18217
|
||||
}
|
||||
}
|
||||
function addInferredTypings(typingNames: ReadonlyArray<string>, message: string) {
|
||||
function addInferredTypings(typingNames: readonly string[], message: string) {
|
||||
if (log) log(`${message}: ${JSON.stringify(typingNames)}`);
|
||||
forEach(typingNames, addInferredTyping);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ declare namespace ts.server {
|
||||
readonly kind: EventBeginInstallTypes | EventEndInstallTypes;
|
||||
readonly eventId: number;
|
||||
readonly typingsInstallerVersion: string;
|
||||
readonly packagesToInstall: ReadonlyArray<string>;
|
||||
readonly packagesToInstall: readonly string[];
|
||||
}
|
||||
|
||||
export interface BeginInstallTypes extends InstallTypes {
|
||||
|
||||
Vendored
+4
-4
@@ -10,7 +10,7 @@ interface Map<K, V> {
|
||||
|
||||
interface MapConstructor {
|
||||
new(): Map<any, any>;
|
||||
new<K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): Map<K, V>;
|
||||
new<K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
|
||||
readonly prototype: Map<any, any>;
|
||||
}
|
||||
declare var Map: MapConstructor;
|
||||
@@ -30,7 +30,7 @@ interface WeakMap<K extends object, V> {
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new <K extends object = object, V = any>(entries?: ReadonlyArray<[K, V]> | null): WeakMap<K, V>;
|
||||
new <K extends object = object, V = any>(entries?: readonly [K, V][] | null): WeakMap<K, V>;
|
||||
readonly prototype: WeakMap<object, any>;
|
||||
}
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
@@ -45,7 +45,7 @@ interface Set<T> {
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new <T = any>(values?: ReadonlyArray<T> | null): Set<T>;
|
||||
new <T = any>(values?: readonly T[] | null): Set<T>;
|
||||
readonly prototype: Set<any>;
|
||||
}
|
||||
declare var Set: SetConstructor;
|
||||
@@ -63,7 +63,7 @@ interface WeakSet<T extends object> {
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T extends object = object>(values?: ReadonlyArray<T> | null): WeakSet<T>;
|
||||
new <T extends object = object>(values?: readonly T[] | null): WeakSet<T>;
|
||||
readonly prototype: WeakSet<object>;
|
||||
}
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
|
||||
Vendored
+3
-3
@@ -329,8 +329,8 @@ interface ReadonlyArray<T> {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find<S extends T>(predicate: (this: void, value: T, index: number, obj: ReadonlyArray<T>) => value is S, thisArg?: any): S | undefined;
|
||||
find(predicate: (value: T, index: number, obj: ReadonlyArray<T>) => unknown, thisArg?: any): T | undefined;
|
||||
find<S extends T>(predicate: (this: void, value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined;
|
||||
find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -341,7 +341,7 @@ interface ReadonlyArray<T> {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: T, index: number, obj: ReadonlyArray<T>) => unknown, thisArg?: any): number;
|
||||
findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
|
||||
Vendored
+33
-33
@@ -11,7 +11,7 @@ interface ReadonlyArray<T> {
|
||||
* thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
flatMap<U, This = undefined> (
|
||||
callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray<U>,
|
||||
callback: (this: This, value: T, index: number, array: T[]) => U | readonly U[],
|
||||
thisArg?: This
|
||||
): U[]
|
||||
|
||||
@@ -23,26 +23,26 @@ interface ReadonlyArray<T> {
|
||||
* @param depth The maximum recursion depth
|
||||
*/
|
||||
flat<U>(this:
|
||||
ReadonlyArray<U[][][][]> |
|
||||
readonly U[][][][][] |
|
||||
|
||||
ReadonlyArray<ReadonlyArray<U[][][]>> |
|
||||
ReadonlyArray<ReadonlyArray<U[][]>[]> |
|
||||
ReadonlyArray<ReadonlyArray<U[]>[][]> |
|
||||
ReadonlyArray<ReadonlyArray<U>[][][]> |
|
||||
readonly (readonly U[][][][])[] |
|
||||
readonly readonly U[][][][][] |
|
||||
readonly readonly U[][][][][] |
|
||||
readonly readonly U[][][][][] |
|
||||
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[][]>>> |
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[][]>> |
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[][]> |
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>[]> |
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>[]> |
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>[]>> |
|
||||
readonly (readonly (readonly U[][][])[])[] |
|
||||
readonly (readonly readonly U[][][][])[] |
|
||||
readonly readonly (readonly U[])[][][][] |
|
||||
readonly readonly readonly U[][][][][] |
|
||||
readonly readonly (readonly U[][])[][][] |
|
||||
readonly (readonly readonly U[][][][])[] |
|
||||
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>>> |
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>>> |
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[]>> |
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>[]> |
|
||||
readonly (readonly (readonly (readonly U[][])[])[])[] |
|
||||
readonly (readonly (readonly readonly U[][][])[])[] |
|
||||
readonly (readonly readonly (readonly U[])[][][])[] |
|
||||
readonly readonly (readonly (readonly U[])[])[][][] |
|
||||
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>>>,
|
||||
readonly (readonly (readonly (readonly (readonly U[])[])[])[])[],
|
||||
depth: 4): U[];
|
||||
|
||||
/**
|
||||
@@ -52,17 +52,17 @@ interface ReadonlyArray<T> {
|
||||
* @param depth The maximum recursion depth
|
||||
*/
|
||||
flat<U>(this:
|
||||
ReadonlyArray<U[][][]> |
|
||||
readonly U[][][][] |
|
||||
|
||||
ReadonlyArray<ReadonlyArray<U>[][]> |
|
||||
ReadonlyArray<ReadonlyArray<U[]>[]> |
|
||||
ReadonlyArray<ReadonlyArray<U[][]>> |
|
||||
readonly readonly U[][][][] |
|
||||
readonly readonly U[][][][] |
|
||||
readonly (readonly U[][][])[] |
|
||||
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>> |
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>> |
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[]> |
|
||||
readonly (readonly (readonly U[][])[])[] |
|
||||
readonly (readonly readonly U[][][])[] |
|
||||
readonly readonly (readonly U[])[][][] |
|
||||
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>>,
|
||||
readonly (readonly (readonly (readonly U[])[])[])[],
|
||||
depth: 3): U[];
|
||||
|
||||
/**
|
||||
@@ -72,12 +72,12 @@ interface ReadonlyArray<T> {
|
||||
* @param depth The maximum recursion depth
|
||||
*/
|
||||
flat<U>(this:
|
||||
ReadonlyArray<U[][]> |
|
||||
readonly U[][][] |
|
||||
|
||||
ReadonlyArray<ReadonlyArray<U[]>> |
|
||||
ReadonlyArray<ReadonlyArray<U>[]> |
|
||||
readonly (readonly U[][])[] |
|
||||
readonly readonly U[][][] |
|
||||
|
||||
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>,
|
||||
readonly (readonly (readonly U[])[])[],
|
||||
depth: 2): U[];
|
||||
|
||||
/**
|
||||
@@ -87,8 +87,8 @@ interface ReadonlyArray<T> {
|
||||
* @param depth The maximum recursion depth
|
||||
*/
|
||||
flat<U>(this:
|
||||
ReadonlyArray<U[]> |
|
||||
ReadonlyArray<ReadonlyArray<U>>,
|
||||
readonly U[][] |
|
||||
readonly (readonly U[])[],
|
||||
depth?: 1
|
||||
): U[];
|
||||
|
||||
@@ -98,7 +98,7 @@ interface ReadonlyArray<T> {
|
||||
*
|
||||
* @param depth The maximum recursion depth
|
||||
*/
|
||||
flat<U>(this: ReadonlyArray<U>, depth: 0): U[];
|
||||
flat<U>(this: readonly U[], depth: 0): U[];
|
||||
|
||||
/**
|
||||
* Returns a new array with all sub-array elements concatenated into it recursively up to the
|
||||
@@ -122,7 +122,7 @@ interface Array<T> {
|
||||
* thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
flatMap<U, This = undefined> (
|
||||
callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray<U>,
|
||||
callback: (this: This, value: T, index: number, array: T[]) => U | readonly U[],
|
||||
thisArg?: This
|
||||
): U[]
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -11,5 +11,5 @@ interface ObjectConstructor {
|
||||
* Returns an object created by key-value entries for properties and methods
|
||||
* @param entries An iterable object that contains key-value entries for properties and methods.
|
||||
*/
|
||||
fromEntries(entries: Iterable<ReadonlyArray<any>>): any;
|
||||
fromEntries(entries: Iterable<readonly any[]>): any;
|
||||
}
|
||||
|
||||
Vendored
+14
-14
@@ -196,7 +196,7 @@ interface ObjectConstructor {
|
||||
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
freeze<T>(a: T[]): ReadonlyArray<T>;
|
||||
freeze<T>(a: T[]): readonly T[];
|
||||
|
||||
/**
|
||||
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
||||
@@ -582,7 +582,7 @@ interface NumberConstructor {
|
||||
declare var Number: NumberConstructor;
|
||||
|
||||
interface TemplateStringsArray extends ReadonlyArray<string> {
|
||||
readonly raw: ReadonlyArray<string>;
|
||||
readonly raw: readonly string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1114,63 +1114,63 @@ interface ReadonlyArray<T> {
|
||||
* @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
every(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => unknown, thisArg?: any): boolean;
|
||||
every(callbackfn: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
|
||||
/**
|
||||
* Determines whether the specified callback function returns true for any element of an array.
|
||||
* @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
some(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => unknown, thisArg?: any): boolean;
|
||||
some(callbackfn: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
forEach(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => void, thisArg?: any): void;
|
||||
forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => U, thisArg?: any): U[];
|
||||
map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[];
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
filter<S extends T>(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => value is S, thisArg?: any): S[];
|
||||
filter<S extends T>(callbackfn: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[];
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
filter(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => unknown, thisArg?: any): T[];
|
||||
filter(callbackfn: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[];
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
|
||||
*/
|
||||
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray<T>) => T): T;
|
||||
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray<T>) => T, initialValue: T): T;
|
||||
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
|
||||
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
|
||||
*/
|
||||
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: ReadonlyArray<T>) => U, initialValue: U): U;
|
||||
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
|
||||
*/
|
||||
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray<T>) => T): T;
|
||||
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray<T>) => T, initialValue: T): T;
|
||||
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
|
||||
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
|
||||
*/
|
||||
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: ReadonlyArray<T>) => U, initialValue: U): U;
|
||||
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
|
||||
|
||||
readonly [n: number]: T;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace ts.server {
|
||||
|
||||
export interface ConfigFileDiagEvent {
|
||||
eventName: typeof ConfigFileDiagEvent;
|
||||
data: { triggerFile: string, configFileName: string, diagnostics: ReadonlyArray<Diagnostic> };
|
||||
data: { triggerFile: string, configFileName: string, diagnostics: readonly Diagnostic[] };
|
||||
}
|
||||
|
||||
export interface ProjectLanguageServiceStateEvent {
|
||||
@@ -281,7 +281,7 @@ namespace ts.server {
|
||||
|
||||
export interface OpenConfiguredProjectResult {
|
||||
configFileName?: NormalizedPath;
|
||||
configFileErrors?: ReadonlyArray<Diagnostic>;
|
||||
configFileErrors?: readonly Diagnostic[];
|
||||
}
|
||||
|
||||
interface AssignProjectResult extends OpenConfiguredProjectResult {
|
||||
@@ -375,8 +375,8 @@ namespace ts.server {
|
||||
eventHandler?: ProjectServiceEventHandler;
|
||||
suppressDiagnosticEvents?: boolean;
|
||||
throttleWaitMilliseconds?: number;
|
||||
globalPlugins?: ReadonlyArray<string>;
|
||||
pluginProbeLocations?: ReadonlyArray<string>;
|
||||
globalPlugins?: readonly string[];
|
||||
pluginProbeLocations?: readonly string[];
|
||||
allowLocalPluginLoads?: boolean;
|
||||
typesMapLocation?: string;
|
||||
syntaxOnly?: boolean;
|
||||
@@ -519,8 +519,8 @@ namespace ts.server {
|
||||
private readonly eventHandler?: ProjectServiceEventHandler;
|
||||
private readonly suppressDiagnosticEvents?: boolean;
|
||||
|
||||
public readonly globalPlugins: ReadonlyArray<string>;
|
||||
public readonly pluginProbeLocations: ReadonlyArray<string>;
|
||||
public readonly globalPlugins: readonly string[];
|
||||
public readonly pluginProbeLocations: readonly string[];
|
||||
public readonly allowLocalPluginLoads: boolean;
|
||||
private currentPluginConfigOverrides: Map<any> | undefined;
|
||||
|
||||
@@ -777,7 +777,7 @@ namespace ts.server {
|
||||
this.delayEnsureProjectForOpenFiles();
|
||||
}
|
||||
|
||||
private delayUpdateProjectGraphs(projects: ReadonlyArray<Project>) {
|
||||
private delayUpdateProjectGraphs(projects: readonly Project[]) {
|
||||
if (projects.length) {
|
||||
for (const project of projects) {
|
||||
this.delayUpdateProjectGraph(project);
|
||||
@@ -2640,7 +2640,7 @@ namespace ts.server {
|
||||
|
||||
private assignProjectToOpenedScriptInfo(info: ScriptInfo): AssignProjectResult {
|
||||
let configFileName: NormalizedPath | undefined;
|
||||
let configFileErrors: ReadonlyArray<Diagnostic> | undefined;
|
||||
let configFileErrors: readonly Diagnostic[] | undefined;
|
||||
let project: ConfiguredProject | ExternalProject | undefined = this.findExternalProjectContainingOpenScriptInfo(info);
|
||||
let defaultConfigProject: ConfiguredProject | undefined;
|
||||
if (!project && !this.syntaxOnly) { // Checking syntaxOnly is an optimization
|
||||
|
||||
+16
-16
@@ -75,7 +75,7 @@ namespace ts.server {
|
||||
|
||||
/* @internal */
|
||||
export interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles {
|
||||
projectErrors: ReadonlyArray<Diagnostic>;
|
||||
projectErrors: readonly Diagnostic[];
|
||||
}
|
||||
|
||||
export interface PluginCreateInfo {
|
||||
@@ -133,7 +133,7 @@ namespace ts.server {
|
||||
* Maop does not contain entries for files that do not have unresolved imports
|
||||
* This helps in containing the set of files to invalidate
|
||||
*/
|
||||
cachedUnresolvedImportsPerFile = createMap<ReadonlyArray<string>>();
|
||||
cachedUnresolvedImportsPerFile = createMap<readonly string[]>();
|
||||
|
||||
/*@internal*/
|
||||
lastCachedUnresolvedImportsList: SortedReadonlyArray<string> | undefined;
|
||||
@@ -310,7 +310,7 @@ namespace ts.server {
|
||||
return this.projectStateVersion.toString();
|
||||
}
|
||||
|
||||
getProjectReferences(): ReadonlyArray<ProjectReference> | undefined {
|
||||
getProjectReferences(): readonly ProjectReference[] | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ namespace ts.server {
|
||||
return this.projectService.host.useCaseSensitiveFileNames;
|
||||
}
|
||||
|
||||
readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[] {
|
||||
readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] {
|
||||
return this.directoryStructureHost.readDirectory!(path, extensions, exclude, include, depth);
|
||||
}
|
||||
|
||||
@@ -497,11 +497,11 @@ namespace ts.server {
|
||||
/**
|
||||
* Get the errors that dont have any file name associated
|
||||
*/
|
||||
getGlobalProjectErrors(): ReadonlyArray<Diagnostic> {
|
||||
getGlobalProjectErrors(): readonly Diagnostic[] {
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
getAllProjectErrors(): ReadonlyArray<Diagnostic> {
|
||||
getAllProjectErrors(): readonly Diagnostic[] {
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
@@ -714,7 +714,7 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
getExcludedFiles(): ReadonlyArray<NormalizedPath> {
|
||||
getExcludedFiles(): readonly NormalizedPath[] {
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
@@ -858,7 +858,7 @@ namespace ts.server {
|
||||
const hasAddedorRemovedFiles = this.hasAddedorRemovedFiles;
|
||||
this.hasAddedorRemovedFiles = false;
|
||||
|
||||
const changedFiles: ReadonlyArray<Path> = this.resolutionCache.finishRecordingFilesWithChangedResolutions() || emptyArray;
|
||||
const changedFiles: readonly Path[] = this.resolutionCache.finishRecordingFilesWithChangedResolutions() || emptyArray;
|
||||
|
||||
for (const file of changedFiles) {
|
||||
// delete cached information for changed files
|
||||
@@ -1322,12 +1322,12 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
function getUnresolvedImports(program: Program, cachedUnresolvedImportsPerFile: Map<ReadonlyArray<string>>): SortedReadonlyArray<string> {
|
||||
function getUnresolvedImports(program: Program, cachedUnresolvedImportsPerFile: Map<readonly string[]>): SortedReadonlyArray<string> {
|
||||
const ambientModules = program.getTypeChecker().getAmbientModules().map(mod => stripQuotes(mod.getName()));
|
||||
return sortAndDeduplicate(flatMap(program.getSourceFiles(), sourceFile =>
|
||||
extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile)));
|
||||
}
|
||||
function extractUnresolvedImportsFromSourceFile(file: SourceFile, ambientModules: ReadonlyArray<string>, cachedUnresolvedImportsPerFile: Map<ReadonlyArray<string>>): ReadonlyArray<string> {
|
||||
function extractUnresolvedImportsFromSourceFile(file: SourceFile, ambientModules: readonly string[], cachedUnresolvedImportsPerFile: Map<readonly string[]>): readonly string[] {
|
||||
return getOrUpdate(cachedUnresolvedImportsPerFile, file.path, () => {
|
||||
if (!file.resolvedModules) return emptyArray;
|
||||
let unresolvedImports: string[] | undefined;
|
||||
@@ -1489,7 +1489,7 @@ namespace ts.server {
|
||||
|
||||
private projectErrors: Diagnostic[] | undefined;
|
||||
|
||||
private projectReferences: ReadonlyArray<ProjectReference> | undefined;
|
||||
private projectReferences: readonly ProjectReference[] | undefined;
|
||||
|
||||
/*@internal*/
|
||||
projectOptions?: ProjectOptions | true;
|
||||
@@ -1553,11 +1553,11 @@ namespace ts.server {
|
||||
return asNormalizedPath(this.getProjectName());
|
||||
}
|
||||
|
||||
getProjectReferences(): ReadonlyArray<ProjectReference> | undefined {
|
||||
getProjectReferences(): readonly ProjectReference[] | undefined {
|
||||
return this.projectReferences;
|
||||
}
|
||||
|
||||
updateReferences(refs: ReadonlyArray<ProjectReference> | undefined) {
|
||||
updateReferences(refs: readonly ProjectReference[] | undefined) {
|
||||
this.projectReferences = refs;
|
||||
}
|
||||
|
||||
@@ -1599,14 +1599,14 @@ namespace ts.server {
|
||||
/**
|
||||
* Get the errors that dont have any file name associated
|
||||
*/
|
||||
getGlobalProjectErrors(): ReadonlyArray<Diagnostic> {
|
||||
getGlobalProjectErrors(): readonly Diagnostic[] {
|
||||
return filter(this.projectErrors, diagnostic => !diagnostic.file) || emptyArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the project errors
|
||||
*/
|
||||
getAllProjectErrors(): ReadonlyArray<Diagnostic> {
|
||||
getAllProjectErrors(): readonly Diagnostic[] {
|
||||
return this.projectErrors || emptyArray;
|
||||
}
|
||||
|
||||
@@ -1711,7 +1711,7 @@ namespace ts.server {
|
||||
* These are created only if a host explicitly calls `openExternalProject`.
|
||||
*/
|
||||
export class ExternalProject extends Project {
|
||||
excludedFiles: ReadonlyArray<NormalizedPath> = [];
|
||||
excludedFiles: readonly NormalizedPath[] = [];
|
||||
private typeAcquisition!: TypeAcquisition; // TODO: GH#18217
|
||||
/*@internal*/
|
||||
constructor(public externalProjectName: string,
|
||||
|
||||
+11
-11
@@ -633,7 +633,7 @@ namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
export interface OrganizeImportsResponse extends Response {
|
||||
body: ReadonlyArray<FileCodeEdits>;
|
||||
body: readonly FileCodeEdits[];
|
||||
}
|
||||
|
||||
export interface GetEditsForFileRenameRequest extends Request {
|
||||
@@ -648,7 +648,7 @@ namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
export interface GetEditsForFileRenameResponse extends Response {
|
||||
body: ReadonlyArray<FileCodeEdits>;
|
||||
body: readonly FileCodeEdits[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -717,7 +717,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* Errorcodes we want to get the fixes for.
|
||||
*/
|
||||
errorCodes: ReadonlyArray<number>;
|
||||
errorCodes: readonly number[];
|
||||
}
|
||||
|
||||
export interface GetCombinedCodeFixRequestArgs {
|
||||
@@ -907,7 +907,7 @@ namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
export interface DefinitionInfoAndBoundSpan {
|
||||
definitions: ReadonlyArray<FileSpanWithContext>;
|
||||
definitions: readonly FileSpanWithContext[];
|
||||
textSpan: TextSpan;
|
||||
}
|
||||
|
||||
@@ -1067,7 +1067,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* The file locations referencing the symbol.
|
||||
*/
|
||||
refs: ReadonlyArray<ReferencesResponseItem>;
|
||||
refs: readonly ReferencesResponseItem[];
|
||||
|
||||
/**
|
||||
* The name of the symbol.
|
||||
@@ -1125,7 +1125,7 @@ namespace ts.server.protocol {
|
||||
|
||||
/* @internal */
|
||||
export interface RenameFullResponse extends Response {
|
||||
readonly body: ReadonlyArray<RenameLocation>;
|
||||
readonly body: readonly RenameLocation[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1198,7 +1198,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* An array of span groups (one per file) that refer to the item to be renamed.
|
||||
*/
|
||||
locs: ReadonlyArray<SpanGroup>;
|
||||
locs: readonly SpanGroup[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1876,8 +1876,8 @@ namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
export interface CombinedCodeActions {
|
||||
changes: ReadonlyArray<FileCodeEdits>;
|
||||
commands?: ReadonlyArray<{}>;
|
||||
changes: readonly FileCodeEdits[];
|
||||
commands?: readonly {}[];
|
||||
}
|
||||
|
||||
export interface CodeFixAction extends CodeAction {
|
||||
@@ -2106,7 +2106,7 @@ namespace ts.server.protocol {
|
||||
readonly isGlobalCompletion: boolean;
|
||||
readonly isMemberCompletion: boolean;
|
||||
readonly isNewIdentifierLocation: boolean;
|
||||
readonly entries: ReadonlyArray<CompletionEntry>;
|
||||
readonly entries: readonly CompletionEntry[];
|
||||
}
|
||||
|
||||
export interface CompletionDetailsResponse extends Response {
|
||||
@@ -2929,7 +2929,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* list of packages to install
|
||||
*/
|
||||
packages: ReadonlyArray<string>;
|
||||
packages: readonly string[];
|
||||
}
|
||||
|
||||
export interface BeginInstallTypesEventBody extends InstallTypesEventBody {
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
class LineIndexSnapshot implements IScriptSnapshot {
|
||||
constructor(readonly version: number, readonly cache: ScriptVersionCache, readonly index: LineIndex, readonly changesSincePreviousVersion: ReadonlyArray<TextChange> = emptyArray) {
|
||||
constructor(readonly version: number, readonly cache: ScriptVersionCache, readonly index: LineIndex, readonly changesSincePreviousVersion: readonly TextChange[] = emptyArray) {
|
||||
}
|
||||
|
||||
getText(rangeStart: number, rangeEnd: number) {
|
||||
|
||||
+45
-45
@@ -113,7 +113,7 @@ namespace ts.server {
|
||||
project: Project;
|
||||
}
|
||||
|
||||
function allEditsBeforePos(edits: ReadonlyArray<TextChange>, pos: number): boolean {
|
||||
function allEditsBeforePos(edits: readonly TextChange[], pos: number): boolean {
|
||||
return edits.every(edit => textSpanEnd(edit.span) < pos);
|
||||
}
|
||||
|
||||
@@ -258,8 +258,8 @@ namespace ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
type Projects = ReadonlyArray<Project> | {
|
||||
readonly projects: ReadonlyArray<Project>;
|
||||
type Projects = readonly Project[] | {
|
||||
readonly projects: readonly Project[];
|
||||
readonly symLinkedProjects: MultiMap<Project>;
|
||||
};
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace ts.server {
|
||||
defaultValue: T,
|
||||
getValue: (path: Path) => T,
|
||||
projects: Projects,
|
||||
action: (project: Project, value: T) => ReadonlyArray<U> | U | undefined,
|
||||
action: (project: Project, value: T) => readonly U[] | U | undefined,
|
||||
): U[] {
|
||||
const outputs = flatMapToMutable(isArray(projects) ? projects : projects.projects, project => action(project, defaultValue));
|
||||
if (!isArray(projects) && projects.symLinkedProjects) {
|
||||
@@ -282,7 +282,7 @@ namespace ts.server {
|
||||
return deduplicate(outputs, equateValues);
|
||||
}
|
||||
|
||||
function combineProjectOutputFromEveryProject<T>(projectService: ProjectService, action: (project: Project) => ReadonlyArray<T>, areEqual: (a: T, b: T) => boolean) {
|
||||
function combineProjectOutputFromEveryProject<T>(projectService: ProjectService, action: (project: Project) => readonly T[], areEqual: (a: T, b: T) => boolean) {
|
||||
const outputs: T[] = [];
|
||||
projectService.forEachEnabledProject(project => {
|
||||
const theseOutputs = action(project);
|
||||
@@ -294,7 +294,7 @@ namespace ts.server {
|
||||
function combineProjectOutputWhileOpeningReferencedProjects<T>(
|
||||
projects: Projects,
|
||||
defaultProject: Project,
|
||||
action: (project: Project) => ReadonlyArray<T>,
|
||||
action: (project: Project) => readonly T[],
|
||||
getLocation: (t: T) => DocumentPosition,
|
||||
resultsEqual: (a: T, b: T) => boolean,
|
||||
): T[] {
|
||||
@@ -321,7 +321,7 @@ namespace ts.server {
|
||||
findInStrings: boolean,
|
||||
findInComments: boolean,
|
||||
hostPreferences: UserPreferences
|
||||
): ReadonlyArray<RenameLocation> {
|
||||
): readonly RenameLocation[] {
|
||||
const outputs: RenameLocation[] = [];
|
||||
|
||||
combineProjectOutputWorker<DocumentPosition>(
|
||||
@@ -351,7 +351,7 @@ namespace ts.server {
|
||||
projects: Projects,
|
||||
defaultProject: Project,
|
||||
initialLocation: DocumentPosition
|
||||
): ReadonlyArray<ReferencedSymbol> {
|
||||
): readonly ReferencedSymbol[] {
|
||||
const outputs: ReferencedSymbol[] = [];
|
||||
|
||||
combineProjectOutputWorker<DocumentPosition>(
|
||||
@@ -545,8 +545,8 @@ namespace ts.server {
|
||||
throttleWaitMilliseconds?: number;
|
||||
noGetErrOnBackgroundUpdate?: boolean;
|
||||
|
||||
globalPlugins?: ReadonlyArray<string>;
|
||||
pluginProbeLocations?: ReadonlyArray<string>;
|
||||
globalPlugins?: readonly string[];
|
||||
pluginProbeLocations?: readonly string[];
|
||||
allowLocalPluginLoads?: boolean;
|
||||
typesMapLocation?: string;
|
||||
}
|
||||
@@ -763,8 +763,8 @@ namespace ts.server {
|
||||
let metadata: unknown;
|
||||
if (isArray(info)) {
|
||||
res.body = info;
|
||||
metadata = (info as WithMetadata<ReadonlyArray<any>>).metadata;
|
||||
delete (info as WithMetadata<ReadonlyArray<any>>).metadata;
|
||||
metadata = (info as WithMetadata<readonly any[]>).metadata;
|
||||
delete (info as WithMetadata<readonly any[]>).metadata;
|
||||
}
|
||||
else if (typeof info === "object") {
|
||||
if ((info as WithMetadata<{}>).metadata) {
|
||||
@@ -805,7 +805,7 @@ namespace ts.server {
|
||||
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag");
|
||||
}
|
||||
|
||||
private sendDiagnosticsEvent(file: NormalizedPath, project: Project, diagnostics: ReadonlyArray<Diagnostic>, kind: protocol.DiagnosticEventKind): void {
|
||||
private sendDiagnosticsEvent(file: NormalizedPath, project: Project, diagnostics: readonly Diagnostic[], kind: protocol.DiagnosticEventKind): void {
|
||||
try {
|
||||
this.event<protocol.DiagnosticEventBody>({ file, diagnostics: diagnostics.map(diag => formatDiag(file, project, diag)) }, kind);
|
||||
}
|
||||
@@ -927,7 +927,7 @@ namespace ts.server {
|
||||
);
|
||||
}
|
||||
|
||||
private convertToDiagnosticsWithLinePositionFromDiagnosticFile(diagnostics: ReadonlyArray<Diagnostic>): protocol.DiagnosticWithLinePosition[] {
|
||||
private convertToDiagnosticsWithLinePositionFromDiagnosticFile(diagnostics: readonly Diagnostic[]): protocol.DiagnosticWithLinePosition[] {
|
||||
return diagnostics.map<protocol.DiagnosticWithLinePosition>(d => ({
|
||||
message: flattenDiagnosticMessageText(d.messageText, this.host.newLine),
|
||||
start: d.start!, // TODO: GH#18217
|
||||
@@ -954,7 +954,7 @@ namespace ts.server {
|
||||
);
|
||||
}
|
||||
|
||||
private convertToDiagnosticsWithLinePosition(diagnostics: ReadonlyArray<Diagnostic>, scriptInfo: ScriptInfo | undefined): protocol.DiagnosticWithLinePosition[] {
|
||||
private convertToDiagnosticsWithLinePosition(diagnostics: readonly Diagnostic[], scriptInfo: ScriptInfo | undefined): protocol.DiagnosticWithLinePosition[] {
|
||||
return diagnostics.map(d => <protocol.DiagnosticWithLinePosition>{
|
||||
message: flattenDiagnosticMessageText(d.messageText, this.host.newLine),
|
||||
start: d.start,
|
||||
@@ -970,8 +970,8 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getDiagnosticsWorker(
|
||||
args: protocol.FileRequestArgs, isSemantic: boolean, selector: (project: Project, file: string) => ReadonlyArray<Diagnostic>, includeLinePosition: boolean
|
||||
): ReadonlyArray<protocol.DiagnosticWithLinePosition> | ReadonlyArray<protocol.Diagnostic> {
|
||||
args: protocol.FileRequestArgs, isSemantic: boolean, selector: (project: Project, file: string) => readonly Diagnostic[], includeLinePosition: boolean
|
||||
): readonly protocol.DiagnosticWithLinePosition[] | readonly protocol.Diagnostic[] {
|
||||
const { project, file } = this.getFileAndProject(args);
|
||||
if (isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) {
|
||||
return emptyArray;
|
||||
@@ -983,14 +983,14 @@ namespace ts.server {
|
||||
: diagnostics.map(d => formatDiag(file, project, d));
|
||||
}
|
||||
|
||||
private getDefinition(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.FileSpanWithContext> | ReadonlyArray<DefinitionInfo> {
|
||||
private getDefinition(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): readonly protocol.FileSpanWithContext[] | readonly DefinitionInfo[] {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
const definitions = this.mapDefinitionInfoLocations(project.getLanguageService().getDefinitionAtPosition(file, position) || emptyArray, project);
|
||||
return simplifiedResult ? this.mapDefinitionInfo(definitions, project) : definitions.map(Session.mapToOriginalLocation);
|
||||
}
|
||||
|
||||
private mapDefinitionInfoLocations(definitions: ReadonlyArray<DefinitionInfo>, project: Project): ReadonlyArray<DefinitionInfo> {
|
||||
private mapDefinitionInfoLocations(definitions: readonly DefinitionInfo[], project: Project): readonly DefinitionInfo[] {
|
||||
return definitions.map((info): DefinitionInfo => {
|
||||
const newDocumentSpan = getMappedDocumentSpan(info, project);
|
||||
return !newDocumentSpan ? info : {
|
||||
@@ -1038,7 +1038,7 @@ namespace ts.server {
|
||||
return project.getLanguageService().getEmitOutput(file);
|
||||
}
|
||||
|
||||
private mapDefinitionInfo(definitions: ReadonlyArray<DefinitionInfo>, project: Project): ReadonlyArray<protocol.FileSpanWithContext> {
|
||||
private mapDefinitionInfo(definitions: readonly DefinitionInfo[], project: Project): readonly protocol.FileSpanWithContext[] {
|
||||
return definitions.map(def => this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project));
|
||||
}
|
||||
|
||||
@@ -1085,7 +1085,7 @@ namespace ts.server {
|
||||
fileSpan;
|
||||
}
|
||||
|
||||
private getTypeDefinition(args: protocol.FileLocationRequestArgs): ReadonlyArray<protocol.FileSpanWithContext> {
|
||||
private getTypeDefinition(args: protocol.FileLocationRequestArgs): readonly protocol.FileSpanWithContext[] {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
|
||||
@@ -1093,7 +1093,7 @@ namespace ts.server {
|
||||
return this.mapDefinitionInfo(definitions, project);
|
||||
}
|
||||
|
||||
private mapImplementationLocations(implementations: ReadonlyArray<ImplementationLocation>, project: Project): ReadonlyArray<ImplementationLocation> {
|
||||
private mapImplementationLocations(implementations: readonly ImplementationLocation[], project: Project): readonly ImplementationLocation[] {
|
||||
return implementations.map((info): ImplementationLocation => {
|
||||
const newDocumentSpan = getMappedDocumentSpan(info, project);
|
||||
return !newDocumentSpan ? info : {
|
||||
@@ -1104,7 +1104,7 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.FileSpanWithContext> | ReadonlyArray<ImplementationLocation> {
|
||||
private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): readonly protocol.FileSpanWithContext[] | readonly ImplementationLocation[] {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
const implementations = this.mapImplementationLocations(project.getLanguageService().getImplementationAtPosition(file, position) || emptyArray, project);
|
||||
@@ -1113,7 +1113,7 @@ namespace ts.server {
|
||||
implementations.map(Session.mapToOriginalLocation);
|
||||
}
|
||||
|
||||
private getOccurrences(args: protocol.FileLocationRequestArgs): ReadonlyArray<protocol.OccurrencesResponseItem> {
|
||||
private getOccurrences(args: protocol.FileLocationRequestArgs): readonly protocol.OccurrencesResponseItem[] {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
const occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position);
|
||||
@@ -1131,7 +1131,7 @@ namespace ts.server {
|
||||
emptyArray;
|
||||
}
|
||||
|
||||
private getSyntacticDiagnosticsSync(args: protocol.SyntacticDiagnosticsSyncRequestArgs): ReadonlyArray<protocol.Diagnostic> | ReadonlyArray<protocol.DiagnosticWithLinePosition> {
|
||||
private getSyntacticDiagnosticsSync(args: protocol.SyntacticDiagnosticsSyncRequestArgs): readonly protocol.Diagnostic[] | readonly protocol.DiagnosticWithLinePosition[] {
|
||||
const { configFile } = this.getConfigFileAndProject(args);
|
||||
if (configFile) {
|
||||
// all the config file errors are reported as part of semantic check so nothing to report here
|
||||
@@ -1141,7 +1141,7 @@ namespace ts.server {
|
||||
return this.getDiagnosticsWorker(args, /*isSemantic*/ false, (project, file) => project.getLanguageService().getSyntacticDiagnostics(file), !!args.includeLinePosition);
|
||||
}
|
||||
|
||||
private getSemanticDiagnosticsSync(args: protocol.SemanticDiagnosticsSyncRequestArgs): ReadonlyArray<protocol.Diagnostic> | ReadonlyArray<protocol.DiagnosticWithLinePosition> {
|
||||
private getSemanticDiagnosticsSync(args: protocol.SemanticDiagnosticsSyncRequestArgs): readonly protocol.Diagnostic[] | readonly protocol.DiagnosticWithLinePosition[] {
|
||||
const { configFile, project } = this.getConfigFileAndProject(args);
|
||||
if (configFile) {
|
||||
return this.getConfigFileDiagnostics(configFile, project!, !!args.includeLinePosition); // TODO: GH#18217
|
||||
@@ -1149,7 +1149,7 @@ namespace ts.server {
|
||||
return this.getDiagnosticsWorker(args, /*isSemantic*/ true, (project, file) => project.getLanguageService().getSemanticDiagnostics(file), !!args.includeLinePosition);
|
||||
}
|
||||
|
||||
private getSuggestionDiagnosticsSync(args: protocol.SuggestionDiagnosticsSyncRequestArgs): ReadonlyArray<protocol.Diagnostic> | ReadonlyArray<protocol.DiagnosticWithLinePosition> {
|
||||
private getSuggestionDiagnosticsSync(args: protocol.SuggestionDiagnosticsSyncRequestArgs): readonly protocol.Diagnostic[] | readonly protocol.DiagnosticWithLinePosition[] {
|
||||
const { configFile } = this.getConfigFileAndProject(args);
|
||||
if (configFile) {
|
||||
// Currently there are no info diagnostics for config files.
|
||||
@@ -1166,7 +1166,7 @@ namespace ts.server {
|
||||
return tag === undefined ? undefined : { newText: tag.newText, caretOffset: 0 };
|
||||
}
|
||||
|
||||
private getDocumentHighlights(args: protocol.DocumentHighlightsRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.DocumentHighlightsItem> | ReadonlyArray<DocumentHighlights> {
|
||||
private getDocumentHighlights(args: protocol.DocumentHighlightsRequestArgs, simplifiedResult: boolean): readonly protocol.DocumentHighlightsItem[] | readonly DocumentHighlights[] {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
const documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch);
|
||||
@@ -1212,7 +1212,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getProjects(args: protocol.FileRequestArgs, getScriptInfoEnsuringProjectsUptoDate?: boolean, ignoreNoProjectError?: boolean): Projects {
|
||||
let projects: ReadonlyArray<Project> | undefined;
|
||||
let projects: readonly Project[] | undefined;
|
||||
let symLinkedProjects: MultiMap<Project> | undefined;
|
||||
if (args.projectFileName) {
|
||||
const project = this.getProject(args.projectFileName);
|
||||
@@ -1252,7 +1252,7 @@ namespace ts.server {
|
||||
return info.getDefaultProject();
|
||||
}
|
||||
|
||||
private getRenameLocations(args: protocol.RenameRequestArgs, simplifiedResult: boolean): protocol.RenameResponseBody | ReadonlyArray<RenameLocation> {
|
||||
private getRenameLocations(args: protocol.RenameRequestArgs, simplifiedResult: boolean): protocol.RenameResponseBody | readonly RenameLocation[] {
|
||||
const file = toNormalizedPath(args.file);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
const projects = this.getProjects(args);
|
||||
@@ -1283,7 +1283,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
private toSpanGroups(locations: ReadonlyArray<RenameLocation>): ReadonlyArray<protocol.SpanGroup> {
|
||||
private toSpanGroups(locations: readonly RenameLocation[]): readonly protocol.SpanGroup[] {
|
||||
const map = createMap<protocol.SpanGroup>();
|
||||
for (const { fileName, textSpan, contextSpan, originalContextSpan: _2, originalTextSpan: _, originalFileName: _1, ...prefixSuffixText } of locations) {
|
||||
let group = map.get(fileName);
|
||||
@@ -1294,7 +1294,7 @@ namespace ts.server {
|
||||
return arrayFrom(map.values());
|
||||
}
|
||||
|
||||
private getReferences(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.ReferencesResponseBody | undefined | ReadonlyArray<ReferencedSymbol> {
|
||||
private getReferences(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.ReferencesResponseBody | undefined | readonly ReferencedSymbol[] {
|
||||
const file = toNormalizedPath(args.file);
|
||||
const projects = this.getProjects(args);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
@@ -1313,7 +1313,7 @@ namespace ts.server {
|
||||
const nameSpan = nameInfo && nameInfo.textSpan;
|
||||
const symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0;
|
||||
const symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, textSpanEnd(nameSpan)) : "";
|
||||
const refs: ReadonlyArray<protocol.ReferencesResponseItem> = flatMap(references, referencedSymbol =>
|
||||
const refs: readonly protocol.ReferencesResponseItem[] = flatMap(references, referencedSymbol =>
|
||||
referencedSymbol.references.map(({ fileName, textSpan, contextSpan, isWriteAccess, isDefinition }): protocol.ReferencesResponseItem => {
|
||||
const scriptInfo = Debug.assertDefined(this.projectService.getScriptInfo(fileName));
|
||||
const span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo);
|
||||
@@ -1547,7 +1547,7 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
private getCompletions(args: protocol.CompletionsRequestArgs, kind: protocol.CommandTypes.CompletionInfo | protocol.CommandTypes.Completions | protocol.CommandTypes.CompletionsFull): WithMetadata<ReadonlyArray<protocol.CompletionEntry>> | protocol.CompletionInfo | CompletionInfo | undefined {
|
||||
private getCompletions(args: protocol.CompletionsRequestArgs, kind: protocol.CommandTypes.CompletionInfo | protocol.CommandTypes.Completions | protocol.CommandTypes.CompletionsFull): WithMetadata<readonly protocol.CompletionEntry[]> | protocol.CompletionInfo | CompletionInfo | undefined {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!;
|
||||
const position = this.getPosition(args, scriptInfo);
|
||||
@@ -1573,7 +1573,7 @@ namespace ts.server {
|
||||
}).sort((a, b) => compareStringsCaseSensitiveUI(a.name, b.name));
|
||||
|
||||
if (kind === protocol.CommandTypes.Completions) {
|
||||
if (completions.metadata) (entries as WithMetadata<ReadonlyArray<protocol.CompletionEntry>>).metadata = completions.metadata;
|
||||
if (completions.metadata) (entries as WithMetadata<readonly protocol.CompletionEntry[]>).metadata = completions.metadata;
|
||||
return entries;
|
||||
}
|
||||
|
||||
@@ -1584,7 +1584,7 @@ namespace ts.server {
|
||||
return res;
|
||||
}
|
||||
|
||||
private getCompletionEntryDetails(args: protocol.CompletionDetailsRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.CompletionEntryDetails> | ReadonlyArray<CompletionEntryDetails> {
|
||||
private getCompletionEntryDetails(args: protocol.CompletionDetailsRequestArgs, simplifiedResult: boolean): readonly protocol.CompletionEntryDetails[] | readonly CompletionEntryDetails[] {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!;
|
||||
const position = this.getPosition(args, scriptInfo);
|
||||
@@ -1599,7 +1599,7 @@ namespace ts.server {
|
||||
: result;
|
||||
}
|
||||
|
||||
private getCompileOnSaveAffectedFileList(args: protocol.FileRequestArgs): ReadonlyArray<protocol.CompileOnSaveAffectedFileListSingleProject> {
|
||||
private getCompileOnSaveAffectedFileList(args: protocol.FileRequestArgs): readonly protocol.CompileOnSaveAffectedFileListSingleProject[] {
|
||||
const projects = this.getProjects(args, /*getScriptInfoEnsuringProjectsUptoDate*/ true, /*ignoreNoProjectError*/ true);
|
||||
const info = this.projectService.getScriptInfo(args.file);
|
||||
if (!info) {
|
||||
@@ -1773,7 +1773,7 @@ namespace ts.server {
|
||||
: tree;
|
||||
}
|
||||
|
||||
private getNavigateToItems(args: protocol.NavtoRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.NavtoItem> | ReadonlyArray<NavigateToItem> {
|
||||
private getNavigateToItems(args: protocol.NavtoRequestArgs, simplifiedResult: boolean): readonly protocol.NavtoItem[] | readonly NavigateToItem[] {
|
||||
const full = this.getFullNavigateToItems(args);
|
||||
return !simplifiedResult ? full : full.map((navItem) => {
|
||||
const { file, project } = this.getFileAndProject({ file: navItem.fileName });
|
||||
@@ -1800,7 +1800,7 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
private getFullNavigateToItems(args: protocol.NavtoRequestArgs): ReadonlyArray<NavigateToItem> {
|
||||
private getFullNavigateToItems(args: protocol.NavtoRequestArgs): readonly NavigateToItem[] {
|
||||
const { currentFileOnly, searchValue, maxResultCount } = args;
|
||||
if (currentFileOnly) {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
@@ -1899,7 +1899,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
private organizeImports({ scope }: protocol.OrganizeImportsRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.FileCodeEdits> | ReadonlyArray<FileTextChanges> {
|
||||
private organizeImports({ scope }: protocol.OrganizeImportsRequestArgs, simplifiedResult: boolean): readonly protocol.FileCodeEdits[] | readonly FileTextChanges[] {
|
||||
Debug.assert(scope.type === "file");
|
||||
const { file, project } = this.getFileAndProject(scope.args);
|
||||
const changes = project.getLanguageService().organizeImports({ type: "file", fileName: file }, this.getFormatOptions(file), this.getPreferences(file));
|
||||
@@ -1911,7 +1911,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
private getEditsForFileRename(args: protocol.GetEditsForFileRenameRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.FileCodeEdits> | ReadonlyArray<FileTextChanges> {
|
||||
private getEditsForFileRename(args: protocol.GetEditsForFileRenameRequestArgs, simplifiedResult: boolean): readonly protocol.FileCodeEdits[] | readonly FileTextChanges[] {
|
||||
const oldPath = toNormalizedPath(args.oldFilePath);
|
||||
const newPath = toNormalizedPath(args.newFilePath);
|
||||
const formatOptions = this.getHostFormatOptions();
|
||||
@@ -1923,7 +1923,7 @@ namespace ts.server {
|
||||
return simplifiedResult ? changes.map(c => this.mapTextChangeToCodeEdit(c)) : changes;
|
||||
}
|
||||
|
||||
private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.CodeFixAction> | ReadonlyArray<CodeFixAction> | undefined {
|
||||
private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): readonly protocol.CodeFixAction[] | readonly CodeFixAction[] | undefined {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
|
||||
const scriptInfo = project.getScriptInfoForNormalizedPath(file)!;
|
||||
@@ -1986,7 +1986,7 @@ namespace ts.server {
|
||||
return { fixName, description, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId, fixAllDescription };
|
||||
}
|
||||
|
||||
private mapTextChangesToCodeEdits(textChanges: ReadonlyArray<FileTextChanges>): protocol.FileCodeEdits[] {
|
||||
private mapTextChangesToCodeEdits(textChanges: readonly FileTextChanges[]): protocol.FileCodeEdits[] {
|
||||
return textChanges.map(change => this.mapTextChangeToCodeEdit(change));
|
||||
}
|
||||
|
||||
@@ -2628,13 +2628,13 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
/* @internal */ // Exported only for tests
|
||||
export function getLocationInNewDocument(oldText: string, renameFilename: string, renameLocation: number, edits: ReadonlyArray<FileTextChanges>): protocol.Location {
|
||||
export function getLocationInNewDocument(oldText: string, renameFilename: string, renameLocation: number, edits: readonly FileTextChanges[]): protocol.Location {
|
||||
const newText = applyEdits(oldText, renameFilename, edits);
|
||||
const { line, character } = computeLineAndCharacterOfPosition(computeLineStarts(newText), renameLocation);
|
||||
return { line: line + 1, offset: character + 1 };
|
||||
}
|
||||
|
||||
function applyEdits(text: string, textFilename: string, edits: ReadonlyArray<FileTextChanges>): string {
|
||||
function applyEdits(text: string, textFilename: string, edits: readonly FileTextChanges[]): string {
|
||||
for (const { fileName, textChanges } of edits) {
|
||||
if (fileName !== textFilename) {
|
||||
continue;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
export interface CodeFixRegistration {
|
||||
errorCodes: ReadonlyArray<number>;
|
||||
errorCodes: readonly number[];
|
||||
getCodeActions(context: CodeFixContext): CodeFixAction[] | undefined;
|
||||
fixIds?: ReadonlyArray<string>;
|
||||
fixIds?: readonly string[];
|
||||
getAllCodeActions?(context: CodeFixAllContext): CombinedCodeActions;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace ts {
|
||||
export type DiagnosticAndArguments = DiagnosticMessage | [DiagnosticMessage, string] | [DiagnosticMessage, string, string];
|
||||
function diagnosticToString(diag: DiagnosticAndArguments): string {
|
||||
return isArray(diag)
|
||||
? formatStringFromArgs(getLocaleSpecificMessage(diag[0]), diag.slice(1) as ReadonlyArray<string>)
|
||||
? formatStringFromArgs(getLocaleSpecificMessage(diag[0]), diag.slice(1) as readonly string[])
|
||||
: getLocaleSpecificMessage(diag);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace ts {
|
||||
return arrayFrom(errorCodeToFixes.keys());
|
||||
}
|
||||
|
||||
export function getFixes(context: CodeFixContext): ReadonlyArray<CodeFixAction> {
|
||||
export function getFixes(context: CodeFixContext): readonly CodeFixAction[] {
|
||||
return flatMap(errorCodeToFixes.get(String(context.errorCode)) || emptyArray, f => f.getCodeActions(context));
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace ts {
|
||||
return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands);
|
||||
}
|
||||
|
||||
export function eachDiagnostic({ program, sourceFile, cancellationToken }: CodeFixAllContext, errorCodes: ReadonlyArray<number>, cb: (diag: DiagnosticWithLocation) => void): void {
|
||||
export function eachDiagnostic({ program, sourceFile, cancellationToken }: CodeFixAllContext, errorCodes: readonly number[], cb: (diag: DiagnosticWithLocation) => void): void {
|
||||
for (const diag of program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(computeSuggestionDiagnostics(sourceFile, program, cancellationToken))) {
|
||||
if (contains(errorCodes, diag.code)) {
|
||||
cb(diag as DiagnosticWithLocation);
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function getModifierKindFromSource(source: Node, kind: SyntaxKind): ReadonlyArray<Modifier> | undefined {
|
||||
function getModifierKindFromSource(source: Node, kind: SyntaxKind): readonly Modifier[] | undefined {
|
||||
return filter(source.modifiers, modifier => modifier.kind === kind);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ts.codefix {
|
||||
|
||||
interface SynthBindingPattern {
|
||||
readonly kind: SynthBindingNameKind.BindingPattern;
|
||||
readonly elements: ReadonlyArray<SynthBindingName>;
|
||||
readonly elements: readonly SynthBindingName[];
|
||||
readonly bindingPattern: BindingPattern;
|
||||
readonly types: Type[];
|
||||
}
|
||||
@@ -43,7 +43,7 @@ namespace ts.codefix {
|
||||
interface Transformer {
|
||||
readonly checker: TypeChecker;
|
||||
readonly synthNamesMap: Map<SynthIdentifier>; // keys are the symbol id of the identifier
|
||||
readonly allVarNames: ReadonlyArray<SymbolAndIdentifier>;
|
||||
readonly allVarNames: readonly SymbolAndIdentifier[];
|
||||
readonly setOfExpressionsToReturn: ReadonlyMap<true>; // keys are the node ids of the expressions
|
||||
readonly constIdentifiers: Identifier[];
|
||||
readonly originalTypeMap: ReadonlyMap<Type>; // keys are the node id of the identifier
|
||||
@@ -102,7 +102,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function getReturnStatementsWithPromiseHandlers(body: Block): ReadonlyArray<ReturnStatement> {
|
||||
function getReturnStatementsWithPromiseHandlers(body: Block): readonly ReturnStatement[] {
|
||||
const res: ReturnStatement[] = [];
|
||||
forEachReturnStatement(body, ret => {
|
||||
if (isReturnStatementWithFixablePromiseHandler(ret)) res.push(ret);
|
||||
@@ -281,7 +281,7 @@ namespace ts.codefix {
|
||||
|
||||
// dispatch function to recursively build the refactoring
|
||||
// should be kept up to date with isFixablePromiseHandler in suggestionDiagnostics.ts
|
||||
function transformExpression(node: Expression, transformer: Transformer, outermostParent: CallExpression, prevArgName?: SynthBindingName): ReadonlyArray<Statement> {
|
||||
function transformExpression(node: Expression, transformer: Transformer, outermostParent: CallExpression, prevArgName?: SynthBindingName): readonly Statement[] {
|
||||
if (!node) {
|
||||
return emptyArray;
|
||||
}
|
||||
@@ -306,7 +306,7 @@ namespace ts.codefix {
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
function transformCatch(node: CallExpression, transformer: Transformer, prevArgName?: SynthBindingName): ReadonlyArray<Statement> {
|
||||
function transformCatch(node: CallExpression, transformer: Transformer, prevArgName?: SynthBindingName): readonly Statement[] {
|
||||
const func = node.arguments[0];
|
||||
const argName = getArgBindingName(func, transformer);
|
||||
const shouldReturn = transformer.setOfExpressionsToReturn.get(getNodeId(node).toString());
|
||||
@@ -365,7 +365,7 @@ namespace ts.codefix {
|
||||
return compact([varDeclList, tryStatement, destructuredResult]);
|
||||
}
|
||||
|
||||
function getIdentifierTextsFromBindingName(bindingName: BindingName): ReadonlyArray<string> {
|
||||
function getIdentifierTextsFromBindingName(bindingName: BindingName): readonly string[] {
|
||||
if (isIdentifier(bindingName)) return [bindingName.text];
|
||||
return flatMap(bindingName.elements, element => {
|
||||
if (isOmittedExpression(element)) return [];
|
||||
@@ -378,7 +378,7 @@ namespace ts.codefix {
|
||||
return createSynthIdentifier(renamedPrevArg);
|
||||
}
|
||||
|
||||
function transformThen(node: CallExpression, transformer: Transformer, outermostParent: CallExpression, prevArgName?: SynthBindingName): ReadonlyArray<Statement> {
|
||||
function transformThen(node: CallExpression, transformer: Transformer, outermostParent: CallExpression, prevArgName?: SynthBindingName): readonly Statement[] {
|
||||
const [res, rej] = node.arguments;
|
||||
|
||||
if (!res) {
|
||||
@@ -405,13 +405,13 @@ namespace ts.codefix {
|
||||
return transformExpression(node.expression, transformer, node, argNameRes).concat(transformationBody);
|
||||
}
|
||||
|
||||
function getFlagOfBindingName(bindingName: SynthBindingName, constIdentifiers: ReadonlyArray<Identifier>): NodeFlags {
|
||||
function getFlagOfBindingName(bindingName: SynthBindingName, constIdentifiers: readonly Identifier[]): NodeFlags {
|
||||
const identifiers = getIdentifierTextsFromBindingName(getNode(bindingName));
|
||||
const inArr: boolean = constIdentifiers.some(elem => contains(identifiers, elem.text));
|
||||
return inArr ? NodeFlags.Const : NodeFlags.Let;
|
||||
}
|
||||
|
||||
function transformPromiseCall(node: Expression, transformer: Transformer, prevArgName?: SynthBindingName): ReadonlyArray<Statement> {
|
||||
function transformPromiseCall(node: Expression, transformer: Transformer, prevArgName?: SynthBindingName): readonly Statement[] {
|
||||
const shouldReturn = transformer.setOfExpressionsToReturn.get(getNodeId(node).toString());
|
||||
// the identifier is empty when the handler (.then()) ignores the argument - In this situation we do not need to save the result of the promise returning call
|
||||
const originalNodeParent = node.original ? node.original.parent : node.parent;
|
||||
@@ -425,7 +425,7 @@ namespace ts.codefix {
|
||||
return [createReturn(getSynthesizedDeepClone(node))];
|
||||
}
|
||||
|
||||
function createTransformedStatement(prevArgName: SynthBindingName | undefined, rightHandSide: Expression, transformer: Transformer): ReadonlyArray<Statement> {
|
||||
function createTransformedStatement(prevArgName: SynthBindingName | undefined, rightHandSide: Expression, transformer: Transformer): readonly Statement[] {
|
||||
if (!prevArgName || isEmpty(prevArgName)) {
|
||||
// if there's no argName to assign to, there still might be side effects
|
||||
return [createStatement(rightHandSide)];
|
||||
@@ -441,7 +441,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
// should be kept up to date with isFixablePromiseArgument in suggestionDiagnostics.ts
|
||||
function getTransformationBody(func: Expression, prevArgName: SynthBindingName | undefined, argName: SynthBindingName | undefined, parent: CallExpression, transformer: Transformer): ReadonlyArray<Statement> {
|
||||
function getTransformationBody(func: Expression, prevArgName: SynthBindingName | undefined, argName: SynthBindingName | undefined, parent: CallExpression, transformer: Transformer): readonly Statement[] {
|
||||
|
||||
const shouldReturn = transformer.setOfExpressionsToReturn.get(getNodeId(parent).toString());
|
||||
switch (func.kind) {
|
||||
@@ -539,7 +539,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
|
||||
function removeReturns(stmts: ReadonlyArray<Statement>, prevArgName: SynthBindingName | undefined, transformer: Transformer, seenReturnStatement: boolean): ReadonlyArray<Statement> {
|
||||
function removeReturns(stmts: readonly Statement[], prevArgName: SynthBindingName | undefined, transformer: Transformer, seenReturnStatement: boolean): readonly Statement[] {
|
||||
const ret: Statement[] = [];
|
||||
for (const stmt of stmts) {
|
||||
if (isReturnStatement(stmt)) {
|
||||
@@ -569,7 +569,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
|
||||
function getInnerTransformationBody(transformer: Transformer, innerRetStmts: ReadonlyArray<Node>, prevArgName?: SynthBindingName) {
|
||||
function getInnerTransformationBody(transformer: Transformer, innerRetStmts: readonly Node[], prevArgName?: SynthBindingName) {
|
||||
|
||||
let innerCbBody: Statement[] = [];
|
||||
for (const stmt of innerRetStmts) {
|
||||
@@ -663,7 +663,7 @@ namespace ts.codefix {
|
||||
return { kind: SynthBindingNameKind.Identifier, identifier, types, numberOfAssignmentsOriginal };
|
||||
}
|
||||
|
||||
function createSynthBindingPattern(bindingPattern: BindingPattern, elements: ReadonlyArray<SynthBindingName> = emptyArray, types: Type[] = []): SynthBindingPattern {
|
||||
function createSynthBindingPattern(bindingPattern: BindingPattern, elements: readonly SynthBindingName[] = emptyArray, types: Type[] = []): SynthBindingPattern {
|
||||
return { kind: SynthBindingNameKind.BindingPattern, bindingPattern, elements, types };
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
/** Converts `const name = require("moduleSpecifier").propertyName` */
|
||||
function convertPropertyAccessImport(name: BindingName, propertyName: string, moduleSpecifier: StringLiteralLike, identifiers: Identifiers, quotePreference: QuotePreference): ReadonlyArray<Node> {
|
||||
function convertPropertyAccessImport(name: BindingName, propertyName: string, moduleSpecifier: StringLiteralLike, identifiers: Identifiers, quotePreference: QuotePreference): readonly Node[] {
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
case SyntaxKind.ArrayBindingPattern: {
|
||||
@@ -224,7 +224,7 @@ namespace ts.codefix {
|
||||
* Convert `module.exports = { ... }` to individual exports..
|
||||
* We can't always do this if the module has interesting members -- then it will be a default export instead.
|
||||
*/
|
||||
function tryChangeModuleExportsObject(object: ObjectLiteralExpression): [ReadonlyArray<Statement>, ModuleExportsChanged] | undefined {
|
||||
function tryChangeModuleExportsObject(object: ObjectLiteralExpression): [readonly Statement[], ModuleExportsChanged] | undefined {
|
||||
const statements = mapAllOrFail(object.properties, prop => {
|
||||
switch (prop.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
@@ -270,7 +270,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function convertReExportAll(reExported: StringLiteralLike, checker: TypeChecker): [ReadonlyArray<Statement>, ModuleExportsChanged] {
|
||||
function convertReExportAll(reExported: StringLiteralLike, checker: TypeChecker): [readonly Statement[], ModuleExportsChanged] {
|
||||
// `module.exports = require("x");` ==> `export * from "x"; export { default } from "x";`
|
||||
const moduleSpecifier = reExported.text;
|
||||
const moduleSymbol = checker.getSymbolAtLocation(reExported);
|
||||
@@ -349,7 +349,7 @@ namespace ts.codefix {
|
||||
identifiers: Identifiers,
|
||||
target: ScriptTarget,
|
||||
quotePreference: QuotePreference,
|
||||
): ReadonlyArray<Node> {
|
||||
): readonly Node[] {
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.ObjectBindingPattern: {
|
||||
const importSpecifiers = mapAllOrFail(name.elements, e =>
|
||||
@@ -385,7 +385,7 @@ namespace ts.codefix {
|
||||
* Convert `import x = require("x").`
|
||||
* Also converts uses like `x.y()` to `y()` and uses a named import.
|
||||
*/
|
||||
function convertSingleIdentifierImport(file: SourceFile, name: Identifier, moduleSpecifier: StringLiteralLike, changes: textChanges.ChangeTracker, checker: TypeChecker, identifiers: Identifiers, quotePreference: QuotePreference): ReadonlyArray<Node> {
|
||||
function convertSingleIdentifierImport(file: SourceFile, name: Identifier, moduleSpecifier: StringLiteralLike, changes: textChanges.ChangeTracker, checker: TypeChecker, identifiers: Identifiers, quotePreference: QuotePreference): readonly Node[] {
|
||||
const nameSymbol = checker.getSymbolAtLocation(name);
|
||||
// Maps from module property name to name actually used. (The same if there isn't shadowing.)
|
||||
const namedBindingsNames = createMap<string>();
|
||||
@@ -444,7 +444,7 @@ namespace ts.codefix {
|
||||
readonly additional: Map<true>;
|
||||
}
|
||||
|
||||
type FreeIdentifiers = ReadonlyMap<ReadonlyArray<Identifier>>;
|
||||
type FreeIdentifiers = ReadonlyMap<readonly Identifier[]>;
|
||||
function collectFreeIdentifiers(file: SourceFile): FreeIdentifiers {
|
||||
const map = createMultiMap<Identifier>();
|
||||
forEachFreeIdentifier(file, id => map.add(id.text, id));
|
||||
@@ -476,7 +476,7 @@ namespace ts.codefix {
|
||||
|
||||
// Node helpers
|
||||
|
||||
function functionExpressionToDeclaration(name: string | undefined, additionalModifiers: ReadonlyArray<Modifier>, fn: FunctionExpression | ArrowFunction | MethodDeclaration): FunctionDeclaration {
|
||||
function functionExpressionToDeclaration(name: string | undefined, additionalModifiers: readonly Modifier[], fn: FunctionExpression | ArrowFunction | MethodDeclaration): FunctionDeclaration {
|
||||
return createFunctionDeclaration(
|
||||
getSynthesizedDeepClones(fn.decorators), // TODO: GH#19915 Don't think this is even legal.
|
||||
concatenate(additionalModifiers, getSynthesizedDeepClones(fn.modifiers)),
|
||||
@@ -488,7 +488,7 @@ namespace ts.codefix {
|
||||
convertToFunctionBody(getSynthesizedDeepClone(fn.body!)));
|
||||
}
|
||||
|
||||
function classExpressionToDeclaration(name: string | undefined, additionalModifiers: ReadonlyArray<Modifier>, cls: ClassExpression): ClassDeclaration {
|
||||
function classExpressionToDeclaration(name: string | undefined, additionalModifiers: readonly Modifier[], cls: ClassExpression): ClassDeclaration {
|
||||
return createClassDeclaration(
|
||||
getSynthesizedDeepClones(cls.decorators), // TODO: GH#19915 Don't think this is even legal.
|
||||
concatenate(additionalModifiers, getSynthesizedDeepClones(cls.modifiers)),
|
||||
@@ -508,7 +508,7 @@ namespace ts.codefix {
|
||||
return createImportSpecifier(propertyName !== undefined && propertyName !== name ? createIdentifier(propertyName) : undefined, createIdentifier(name));
|
||||
}
|
||||
|
||||
function makeConst(modifiers: ReadonlyArray<Modifier> | undefined, name: string | BindingName, init: Expression): VariableStatement {
|
||||
function makeConst(modifiers: readonly Modifier[] | undefined, name: string | BindingName, init: Expression): VariableStatement {
|
||||
return createVariableStatement(
|
||||
modifiers,
|
||||
createVariableDeclarationList(
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace ts.codefix {
|
||||
const fixName = "disableJsDiagnostics";
|
||||
const fixId = "disableJsDiagnostics";
|
||||
const errorCodes = mapDefined(Object.keys(Diagnostics) as ReadonlyArray<keyof typeof Diagnostics>, key => {
|
||||
const errorCodes = mapDefined(Object.keys(Diagnostics) as readonly (keyof typeof Diagnostics)[], key => {
|
||||
const diag = Diagnostics[key];
|
||||
return diag.category === DiagnosticCategory.Error ? diag.code : undefined;
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace ts.codefix {
|
||||
},
|
||||
});
|
||||
|
||||
function getAllSupers(decl: ClassOrInterface | undefined, checker: TypeChecker): ReadonlyArray<ClassOrInterface> {
|
||||
function getAllSupers(decl: ClassOrInterface | undefined, checker: TypeChecker): readonly ClassOrInterface[] {
|
||||
const res: ClassLikeDeclaration[] = [];
|
||||
while (decl) {
|
||||
const superElement = getClassExtendsHeritageElement(decl);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace ts.codefix {
|
||||
return extendsToken.kind === SyntaxKind.ExtendsKeyword ? { extendsToken, heritageClauses } : undefined;
|
||||
}
|
||||
|
||||
function doChanges(changes: textChanges.ChangeTracker, sourceFile: SourceFile, extendsToken: Node, heritageClauses: ReadonlyArray<HeritageClause>): void {
|
||||
function doChanges(changes: textChanges.ChangeTracker, sourceFile: SourceFile, extendsToken: Node, heritageClauses: readonly HeritageClause[]): void {
|
||||
changes.replaceNode(sourceFile, extendsToken, createToken(SyntaxKind.ImplementsKeyword));
|
||||
|
||||
// If there is already an implements clause, replace the implements keyword with a comma.
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function lastWhere<T>(a: ReadonlyArray<T>, pred: (value: T) => boolean): T | undefined {
|
||||
function lastWhere<T>(a: readonly T[], pred: (value: T) => boolean): T | undefined {
|
||||
let last: T | undefined;
|
||||
for (const value of a) {
|
||||
if (!pred(value)) break;
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace ts.codefix {
|
||||
return token.kind === SyntaxKind.ImportKeyword ? tryCast(token.parent, isImportDeclaration) : undefined;
|
||||
}
|
||||
|
||||
function tryDeleteFullDestructure(token: Node, changes: textChanges.ChangeTracker, sourceFile: SourceFile, checker: TypeChecker, sourceFiles: ReadonlyArray<SourceFile>, isFixAll: boolean): boolean {
|
||||
function tryDeleteFullDestructure(token: Node, changes: textChanges.ChangeTracker, sourceFile: SourceFile, checker: TypeChecker, sourceFiles: readonly SourceFile[], isFixAll: boolean): boolean {
|
||||
if (token.kind !== SyntaxKind.OpenBraceToken || !isObjectBindingPattern(token.parent)) return false;
|
||||
const decl = token.parent.parent;
|
||||
if (decl.kind === SyntaxKind.Parameter) {
|
||||
@@ -174,7 +174,7 @@ namespace ts.codefix {
|
||||
return false;
|
||||
}
|
||||
|
||||
function tryDeleteDeclaration(sourceFile: SourceFile, token: Node, changes: textChanges.ChangeTracker, checker: TypeChecker, sourceFiles: ReadonlyArray<SourceFile>, isFixAll: boolean) {
|
||||
function tryDeleteDeclaration(sourceFile: SourceFile, token: Node, changes: textChanges.ChangeTracker, checker: TypeChecker, sourceFiles: readonly SourceFile[], isFixAll: boolean) {
|
||||
tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll);
|
||||
if (isIdentifier(token)) deleteAssignments(changes, sourceFile, token, checker);
|
||||
}
|
||||
@@ -188,7 +188,7 @@ namespace ts.codefix {
|
||||
});
|
||||
}
|
||||
|
||||
function tryDeleteDeclarationWorker(token: Node, changes: textChanges.ChangeTracker, sourceFile: SourceFile, checker: TypeChecker, sourceFiles: ReadonlyArray<SourceFile>, isFixAll: boolean): void {
|
||||
function tryDeleteDeclarationWorker(token: Node, changes: textChanges.ChangeTracker, sourceFile: SourceFile, checker: TypeChecker, sourceFiles: readonly SourceFile[], isFixAll: boolean): void {
|
||||
const { parent } = token;
|
||||
if (isParameter(parent)) {
|
||||
tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, isFixAll);
|
||||
@@ -198,7 +198,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function tryDeleteParameter(changes: textChanges.ChangeTracker, sourceFile: SourceFile, p: ParameterDeclaration, checker: TypeChecker, sourceFiles: ReadonlyArray<SourceFile>, isFixAll: boolean): void {
|
||||
function tryDeleteParameter(changes: textChanges.ChangeTracker, sourceFile: SourceFile, p: ParameterDeclaration, checker: TypeChecker, sourceFiles: readonly SourceFile[], isFixAll: boolean): void {
|
||||
if (mayDeleteParameter(p, checker, isFixAll)) {
|
||||
if (p.modifiers && p.modifiers.length > 0
|
||||
&& (!isIdentifier(p.name) || FindAllReferences.Core.isSymbolReferencedInFile(p.name, checker, sourceFile))) {
|
||||
@@ -246,7 +246,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function deleteUnusedArguments(changes: textChanges.ChangeTracker, sourceFile: SourceFile, deletedParameter: ParameterDeclaration, sourceFiles: ReadonlyArray<SourceFile>, checker: TypeChecker): void {
|
||||
function deleteUnusedArguments(changes: textChanges.ChangeTracker, sourceFile: SourceFile, deletedParameter: ParameterDeclaration, sourceFiles: readonly SourceFile[], checker: TypeChecker): void {
|
||||
FindAllReferences.Core.eachSignatureCall(deletedParameter.parent, sourceFiles, checker, call => {
|
||||
const index = deletedParameter.parent.parameters.indexOf(deletedParameter);
|
||||
if (call.arguments.length > index) { // Just in case the call didn't provide enough arguments.
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace ts.codefix {
|
||||
* @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for.
|
||||
* @returns Empty string iff there are no member insertions.
|
||||
*/
|
||||
export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: ReadonlyArray<Symbol>, context: TypeConstructionContext, preferences: UserPreferences, out: (node: ClassElement) => void): void {
|
||||
export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: readonly Symbol[], context: TypeConstructionContext, preferences: UserPreferences, out: (node: ClassElement) => void): void {
|
||||
const classMembers = classDeclaration.symbol.members!;
|
||||
for (const symbol of possiblyMissingSymbols) {
|
||||
if (!classMembers.has(symbol.escapedName)) {
|
||||
@@ -186,10 +186,10 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
function createMethodImplementingSignatures(
|
||||
signatures: ReadonlyArray<Signature>,
|
||||
signatures: readonly Signature[],
|
||||
name: PropertyName,
|
||||
optional: boolean,
|
||||
modifiers: ReadonlyArray<Modifier> | undefined,
|
||||
modifiers: readonly Modifier[] | undefined,
|
||||
preferences: UserPreferences,
|
||||
): MethodDeclaration {
|
||||
/** This is *a* signature with the maximal number of arguments,
|
||||
@@ -237,11 +237,11 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
function createStubbedMethod(
|
||||
modifiers: ReadonlyArray<Modifier> | undefined,
|
||||
modifiers: readonly Modifier[] | undefined,
|
||||
name: PropertyName,
|
||||
optional: boolean,
|
||||
typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined,
|
||||
parameters: ReadonlyArray<ParameterDeclaration>,
|
||||
typeParameters: readonly TypeParameterDeclaration[] | undefined,
|
||||
parameters: readonly ParameterDeclaration[],
|
||||
returnType: TypeNode | undefined,
|
||||
preferences: UserPreferences
|
||||
): MethodDeclaration {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
export const importFixId = "fixMissingImport";
|
||||
const errorCodes: ReadonlyArray<number> = [
|
||||
const errorCodes: readonly number[] = [
|
||||
Diagnostics.Cannot_find_name_0.code,
|
||||
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
||||
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
||||
@@ -176,7 +176,7 @@ namespace ts.codefix {
|
||||
return { description, changes, commands };
|
||||
}
|
||||
|
||||
function getAllReExportingModules(importingFile: SourceFile, exportedSymbol: Symbol, exportingModuleSymbol: Symbol, symbolName: string, sourceFile: SourceFile, compilerOptions: CompilerOptions, checker: TypeChecker, allSourceFiles: ReadonlyArray<SourceFile>): ReadonlyArray<SymbolExportInfo> {
|
||||
function getAllReExportingModules(importingFile: SourceFile, exportedSymbol: Symbol, exportingModuleSymbol: Symbol, symbolName: string, sourceFile: SourceFile, compilerOptions: CompilerOptions, checker: TypeChecker, allSourceFiles: readonly SourceFile[]): readonly SymbolExportInfo[] {
|
||||
const result: SymbolExportInfo[] = [];
|
||||
forEachExternalModule(checker, allSourceFiles, (moduleSymbol, moduleFile) => {
|
||||
// Don't import from a re-export when looking "up" like to `./index` or `../index`.
|
||||
@@ -203,14 +203,14 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
function getFixForImport(
|
||||
exportInfos: ReadonlyArray<SymbolExportInfo>,
|
||||
exportInfos: readonly SymbolExportInfo[],
|
||||
symbolName: string,
|
||||
position: number | undefined,
|
||||
program: Program,
|
||||
sourceFile: SourceFile,
|
||||
host: LanguageServiceHost,
|
||||
preferences: UserPreferences,
|
||||
): ReadonlyArray<ImportFix> {
|
||||
): readonly ImportFix[] {
|
||||
const checker = program.getTypeChecker();
|
||||
const existingImports = flatMap(exportInfos, info => getExistingImportDeclarations(info, checker, sourceFile));
|
||||
const useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker);
|
||||
@@ -220,7 +220,7 @@ namespace ts.codefix {
|
||||
return [...(useNamespace ? [useNamespace] : emptyArray), ...addImport];
|
||||
}
|
||||
|
||||
function tryUseExistingNamespaceImport(existingImports: ReadonlyArray<FixAddToExistingImportInfo>, symbolName: string, position: number, checker: TypeChecker): FixUseNamespaceImport | undefined {
|
||||
function tryUseExistingNamespaceImport(existingImports: readonly FixAddToExistingImportInfo[], symbolName: string, position: number, checker: TypeChecker): FixUseNamespaceImport | undefined {
|
||||
// It is possible that multiple import statements with the same specifier exist in the file.
|
||||
// e.g.
|
||||
//
|
||||
@@ -244,7 +244,7 @@ namespace ts.codefix {
|
||||
});
|
||||
}
|
||||
|
||||
function tryAddToExistingImport(existingImports: ReadonlyArray<FixAddToExistingImportInfo>): FixAddToExistingImport | undefined {
|
||||
function tryAddToExistingImport(existingImports: readonly FixAddToExistingImportInfo[]): FixAddToExistingImport | undefined {
|
||||
return firstDefined(existingImports, ({ declaration, importKind }): FixAddToExistingImport | undefined => {
|
||||
if (declaration.kind !== SyntaxKind.ImportDeclaration) return undefined;
|
||||
const { importClause } = declaration;
|
||||
@@ -266,7 +266,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function getExistingImportDeclarations({ moduleSymbol, importKind, exportedSymbolIsTypeOnly }: SymbolExportInfo, checker: TypeChecker, sourceFile: SourceFile): ReadonlyArray<FixAddToExistingImportInfo> {
|
||||
function getExistingImportDeclarations({ moduleSymbol, importKind, exportedSymbolIsTypeOnly }: SymbolExportInfo, checker: TypeChecker, sourceFile: SourceFile): readonly FixAddToExistingImportInfo[] {
|
||||
// Can't use an es6 import for a type in JS.
|
||||
return exportedSymbolIsTypeOnly && isSourceFileJS(sourceFile) ? emptyArray : mapDefined<StringLiteralLike, FixAddToExistingImportInfo>(sourceFile.imports, moduleSpecifier => {
|
||||
const i = importFromModuleSpecifier(moduleSpecifier);
|
||||
@@ -279,10 +279,10 @@ namespace ts.codefix {
|
||||
program: Program,
|
||||
sourceFile: SourceFile,
|
||||
position: number | undefined,
|
||||
moduleSymbols: ReadonlyArray<SymbolExportInfo>,
|
||||
moduleSymbols: readonly SymbolExportInfo[],
|
||||
host: LanguageServiceHost,
|
||||
preferences: UserPreferences,
|
||||
): ReadonlyArray<FixAddNewImport | FixUseImportType> {
|
||||
): readonly (FixAddNewImport | FixUseImportType)[] {
|
||||
const isJs = isSourceFileJS(sourceFile);
|
||||
const choicesForEachExportingModule = flatMap(moduleSymbols, ({ moduleSymbol, importKind, exportedSymbolIsTypeOnly }) =>
|
||||
moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap)
|
||||
@@ -294,14 +294,14 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
function getFixesForAddImport(
|
||||
exportInfos: ReadonlyArray<SymbolExportInfo>,
|
||||
existingImports: ReadonlyArray<FixAddToExistingImportInfo>,
|
||||
exportInfos: readonly SymbolExportInfo[],
|
||||
existingImports: readonly FixAddToExistingImportInfo[],
|
||||
program: Program,
|
||||
sourceFile: SourceFile,
|
||||
position: number | undefined,
|
||||
host: LanguageServiceHost,
|
||||
preferences: UserPreferences,
|
||||
): ReadonlyArray<FixAddNewImport | FixUseImportType> {
|
||||
): readonly (FixAddNewImport | FixUseImportType)[] {
|
||||
const existingDeclaration = firstDefined(existingImports, newImportInfoFromExistingSpecifier);
|
||||
return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences);
|
||||
}
|
||||
@@ -315,7 +315,7 @@ namespace ts.codefix {
|
||||
return expression && isStringLiteral(expression) ? { kind: ImportFixKind.AddNew, moduleSpecifier: expression.text, importKind } : undefined;
|
||||
}
|
||||
|
||||
interface FixesInfo { readonly fixes: ReadonlyArray<ImportFix>; readonly symbolName: string; }
|
||||
interface FixesInfo { readonly fixes: readonly ImportFix[]; readonly symbolName: string; }
|
||||
function getFixesInfo(context: CodeFixContextBase, errorCode: number, pos: number): FixesInfo | undefined {
|
||||
const symbolToken = getTokenAtPosition(context.sourceFile, pos);
|
||||
const info = errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
|
||||
@@ -330,7 +330,7 @@ namespace ts.codefix {
|
||||
if (!umdSymbol) return undefined;
|
||||
const symbol = checker.getAliasedSymbol(umdSymbol);
|
||||
const symbolName = umdSymbol.name;
|
||||
const exportInfos: ReadonlyArray<SymbolExportInfo> = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }];
|
||||
const exportInfos: readonly SymbolExportInfo[] = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }];
|
||||
const fixes = getFixForImport(exportInfos, symbolName, isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences);
|
||||
return { fixes, symbolName };
|
||||
}
|
||||
@@ -397,7 +397,7 @@ namespace ts.codefix {
|
||||
sourceFile: SourceFile,
|
||||
checker: TypeChecker,
|
||||
program: Program,
|
||||
): ReadonlyMap<ReadonlyArray<SymbolExportInfo>> {
|
||||
): ReadonlyMap<readonly SymbolExportInfo[]> {
|
||||
// For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
|
||||
// Maps symbol id to info for modules providing that symbol (original export + re-exports).
|
||||
const originalSymbolToExportInfos = createMultiMap<SymbolExportInfo>();
|
||||
@@ -525,7 +525,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function doAddExistingFix(changes: textChanges.ChangeTracker, sourceFile: SourceFile, clause: ImportClause, defaultImport: string | undefined, namedImports: ReadonlyArray<string>): void {
|
||||
function doAddExistingFix(changes: textChanges.ChangeTracker, sourceFile: SourceFile, clause: ImportClause, defaultImport: string | undefined, namedImports: readonly string[]): void {
|
||||
if (defaultImport) {
|
||||
Debug.assert(!clause.name);
|
||||
changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), createIdentifier(defaultImport), { suffix: ", " });
|
||||
@@ -605,7 +605,7 @@ namespace ts.codefix {
|
||||
return some(declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning));
|
||||
}
|
||||
|
||||
export function forEachExternalModuleToImportFrom(checker: TypeChecker, from: SourceFile, allSourceFiles: ReadonlyArray<SourceFile>, cb: (module: Symbol) => void) {
|
||||
export function forEachExternalModuleToImportFrom(checker: TypeChecker, from: SourceFile, allSourceFiles: readonly SourceFile[], cb: (module: Symbol) => void) {
|
||||
forEachExternalModule(checker, allSourceFiles, (module, sourceFile) => {
|
||||
if (sourceFile === undefined || sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) {
|
||||
cb(module);
|
||||
@@ -613,7 +613,7 @@ namespace ts.codefix {
|
||||
});
|
||||
}
|
||||
|
||||
function forEachExternalModule(checker: TypeChecker, allSourceFiles: ReadonlyArray<SourceFile>, cb: (module: Symbol, sourceFile: SourceFile | undefined) => void) {
|
||||
function forEachExternalModule(checker: TypeChecker, allSourceFiles: readonly SourceFile[], cb: (module: Symbol, sourceFile: SourceFile | undefined) => void) {
|
||||
for (const ambient of checker.getAmbientModules()) {
|
||||
cb(ambient, /*sourceFile*/ undefined);
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function annotateJSDocParameters(changes: textChanges.ChangeTracker, sourceFile: SourceFile, parameterInferences: ReadonlyArray<ParameterInference>, program: Program, host: LanguageServiceHost): void {
|
||||
function annotateJSDocParameters(changes: textChanges.ChangeTracker, sourceFile: SourceFile, parameterInferences: readonly ParameterInference[], program: Program, host: LanguageServiceHost): void {
|
||||
const signature = parameterInferences.length && parameterInferences[0].declaration.parent;
|
||||
if (!signature) {
|
||||
return;
|
||||
@@ -310,7 +310,7 @@ namespace ts.codefix {
|
||||
addJSDocTags(changes, sourceFile, signature, paramTags);
|
||||
}
|
||||
|
||||
function addJSDocTags(changes: textChanges.ChangeTracker, sourceFile: SourceFile, parent: HasJSDoc, newTags: ReadonlyArray<JSDocTag>): void {
|
||||
function addJSDocTags(changes: textChanges.ChangeTracker, sourceFile: SourceFile, parent: HasJSDoc, newTags: readonly JSDocTag[]): void {
|
||||
const comments = mapDefined(parent.jsDoc, j => j.comment);
|
||||
const oldTags = flatMapToMutable(parent.jsDoc, j => j.tags);
|
||||
const unmergedNewTags = newTags.filter(newTag => !oldTags || !oldTags.some((tag, i) => {
|
||||
@@ -349,7 +349,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function getReferences(token: PropertyName | Token<SyntaxKind.ConstructorKeyword>, program: Program, cancellationToken: CancellationToken): ReadonlyArray<Identifier> {
|
||||
function getReferences(token: PropertyName | Token<SyntaxKind.ConstructorKeyword>, program: Program, cancellationToken: CancellationToken): readonly Identifier[] {
|
||||
// Position shouldn't matter since token is not a SourceFile.
|
||||
return mapDefined(FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), entry =>
|
||||
entry.kind !== FindAllReferences.EntryKind.Span ? tryCast(entry.node, isIdentifier) : undefined);
|
||||
@@ -362,7 +362,7 @@ namespace ts.codefix {
|
||||
return InferFromReference.unifyFromContext(types, checker);
|
||||
}
|
||||
|
||||
function inferFunctionReferencesFromUsage(containingFunction: FunctionLike, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): ReadonlyArray<Identifier> | undefined {
|
||||
function inferFunctionReferencesFromUsage(containingFunction: FunctionLike, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): readonly Identifier[] | undefined {
|
||||
let searchToken;
|
||||
switch (containingFunction.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -415,7 +415,7 @@ namespace ts.codefix {
|
||||
candidateThisTypes?: Type[];
|
||||
}
|
||||
|
||||
export function inferTypesFromReferences(references: ReadonlyArray<Identifier>, checker: TypeChecker, cancellationToken: CancellationToken): Type[] {
|
||||
export function inferTypesFromReferences(references: readonly Identifier[], checker: TypeChecker, cancellationToken: CancellationToken): Type[] {
|
||||
const usageContext: UsageContext = {};
|
||||
for (const reference of references) {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
@@ -424,7 +424,7 @@ namespace ts.codefix {
|
||||
return inferFromContext(usageContext, checker);
|
||||
}
|
||||
|
||||
export function inferTypeForParametersFromReferences(references: ReadonlyArray<Identifier> | undefined, declaration: FunctionLike, program: Program, cancellationToken: CancellationToken): ParameterInference[] | undefined {
|
||||
export function inferTypeForParametersFromReferences(references: readonly Identifier[] | undefined, declaration: FunctionLike, program: Program, cancellationToken: CancellationToken): ParameterInference[] | undefined {
|
||||
if (references === undefined || references.length === 0 || !declaration.parameters) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -467,7 +467,7 @@ namespace ts.codefix {
|
||||
});
|
||||
}
|
||||
|
||||
export function inferTypeForThisFromReferences(references: ReadonlyArray<Identifier>, program: Program, cancellationToken: CancellationToken) {
|
||||
export function inferTypeForThisFromReferences(references: readonly Identifier[], program: Program, cancellationToken: CancellationToken) {
|
||||
if (references.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -742,7 +742,7 @@ namespace ts.codefix {
|
||||
low: (t: Type) => boolean;
|
||||
}
|
||||
|
||||
function removeLowPriorityInferences(inferences: ReadonlyArray<Type>, priorities: Priority[]): Type[] {
|
||||
function removeLowPriorityInferences(inferences: readonly Type[], priorities: Priority[]): Type[] {
|
||||
const toRemove: ((t: Type) => boolean)[] = [];
|
||||
for (const i of inferences) {
|
||||
for (const { high, low } of priorities) {
|
||||
@@ -755,7 +755,7 @@ namespace ts.codefix {
|
||||
return inferences.filter(i => toRemove.every(f => !f(i)));
|
||||
}
|
||||
|
||||
export function unifyFromContext(inferences: ReadonlyArray<Type>, checker: TypeChecker, fallback = checker.getAnyType()): Type {
|
||||
export function unifyFromContext(inferences: readonly Type[], checker: TypeChecker, fallback = checker.getAnyType()): Type {
|
||||
if (!inferences.length) return fallback;
|
||||
|
||||
// 1. string or number individually override string | number
|
||||
|
||||
+10
-10
@@ -304,7 +304,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
export function getCompletionEntriesFromSymbols(
|
||||
symbols: ReadonlyArray<Symbol>,
|
||||
symbols: readonly Symbol[],
|
||||
entries: Push<CompletionEntry>,
|
||||
location: Node | undefined,
|
||||
sourceFile: SourceFile,
|
||||
@@ -567,7 +567,7 @@ namespace ts.Completions {
|
||||
type IsJsxInitializer = boolean | Identifier;
|
||||
interface CompletionData {
|
||||
readonly kind: CompletionDataKind.Data;
|
||||
readonly symbols: ReadonlyArray<Symbol>;
|
||||
readonly symbols: readonly Symbol[];
|
||||
readonly completionKind: CompletionKind;
|
||||
readonly isInSnippetScope: boolean;
|
||||
/** Note that the presence of this alone doesn't mean that we need a conversion. Only do that if the completion is not an ordinary identifier. */
|
||||
@@ -575,7 +575,7 @@ namespace ts.Completions {
|
||||
readonly isNewIdentifierLocation: boolean;
|
||||
readonly location: Node | undefined;
|
||||
readonly keywordFilters: KeywordCompletionFilters;
|
||||
readonly literals: ReadonlyArray<string | number | PseudoBigInt>;
|
||||
readonly literals: readonly (string | number | PseudoBigInt)[];
|
||||
readonly symbolToOriginInfoMap: SymbolOriginInfoMap;
|
||||
readonly recommendedCompletion: Symbol | undefined;
|
||||
readonly previousToken: Node | undefined;
|
||||
@@ -1466,7 +1466,7 @@ namespace ts.Completions {
|
||||
completionKind = CompletionKind.ObjectPropertyDeclaration;
|
||||
|
||||
let typeMembers: Symbol[] | undefined;
|
||||
let existingMembers: ReadonlyArray<Declaration> | undefined;
|
||||
let existingMembers: readonly Declaration[] | undefined;
|
||||
|
||||
if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
const typeForObject = typeChecker.getContextualType(objectLikeContainer);
|
||||
@@ -1876,7 +1876,7 @@ namespace ts.Completions {
|
||||
* @returns Symbols to be suggested in an object binding pattern or object literal expression, barring those whose declarations
|
||||
* do not occur at the current position and have not otherwise been typed.
|
||||
*/
|
||||
function filterObjectMembersList(contextualMemberSymbols: Symbol[], existingMembers: ReadonlyArray<Declaration>): Symbol[] {
|
||||
function filterObjectMembersList(contextualMemberSymbols: Symbol[], existingMembers: readonly Declaration[]): Symbol[] {
|
||||
if (existingMembers.length === 0) {
|
||||
return contextualMemberSymbols;
|
||||
}
|
||||
@@ -1925,7 +1925,7 @@ namespace ts.Completions {
|
||||
*
|
||||
* @returns Symbols to be suggested in an class element depending on existing memebers and symbol flags
|
||||
*/
|
||||
function filterClassMembersList(baseSymbols: ReadonlyArray<Symbol>, existingMembers: ReadonlyArray<ClassElement>, currentClassElementModifierFlags: ModifierFlags): Symbol[] {
|
||||
function filterClassMembersList(baseSymbols: readonly Symbol[], existingMembers: readonly ClassElement[], currentClassElementModifierFlags: ModifierFlags): Symbol[] {
|
||||
const existingMemberNames = createUnderscoreEscapedMap<true>();
|
||||
for (const m of existingMembers) {
|
||||
// Ignore omitted expressions for missing members
|
||||
@@ -2031,8 +2031,8 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
// A cache of completion entries for keywords, these do not change between sessions
|
||||
const _keywordCompletions: ReadonlyArray<CompletionEntry>[] = [];
|
||||
const allKeywordsCompletions: () => ReadonlyArray<CompletionEntry> = memoize(() => {
|
||||
const _keywordCompletions: CompletionEntry[][] = [];
|
||||
const allKeywordsCompletions: () => readonly CompletionEntry[] = memoize(() => {
|
||||
const res: CompletionEntry[] = [];
|
||||
for (let i = SyntaxKind.FirstKeyword; i <= SyntaxKind.LastKeyword; i++) {
|
||||
res.push({
|
||||
@@ -2045,7 +2045,7 @@ namespace ts.Completions {
|
||||
return res;
|
||||
});
|
||||
|
||||
function getKeywordCompletions(keywordFilter: KeywordCompletionFilters, filterOutTsOnlyKeywords: boolean): ReadonlyArray<CompletionEntry> {
|
||||
function getKeywordCompletions(keywordFilter: KeywordCompletionFilters, filterOutTsOnlyKeywords: boolean): readonly CompletionEntry[] {
|
||||
if (!filterOutTsOnlyKeywords) return getTypescriptKeywordCompletions(keywordFilter);
|
||||
|
||||
const index = keywordFilter + KeywordCompletionFilters.Last + 1;
|
||||
@@ -2055,7 +2055,7 @@ namespace ts.Completions {
|
||||
);
|
||||
}
|
||||
|
||||
function getTypescriptKeywordCompletions(keywordFilter: KeywordCompletionFilters): ReadonlyArray<CompletionEntry> {
|
||||
function getTypescriptKeywordCompletions(keywordFilter: KeywordCompletionFilters): readonly CompletionEntry[] {
|
||||
return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(entry => {
|
||||
const kind = stringToToken(entry.name)!;
|
||||
switch (keywordFilter) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* @internal */
|
||||
namespace ts.DocumentHighlights {
|
||||
export function getDocumentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: ReadonlyArray<SourceFile>): DocumentHighlights[] | undefined {
|
||||
export function getDocumentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: readonly SourceFile[]): DocumentHighlights[] | undefined {
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
|
||||
if (node.parent && (isJsxOpeningElement(node.parent) && node.parent.tagName === node || isJsxClosingElement(node.parent))) {
|
||||
@@ -21,7 +21,7 @@ namespace ts.DocumentHighlights {
|
||||
};
|
||||
}
|
||||
|
||||
function getSemanticDocumentHighlights(position: number, node: Node, program: Program, cancellationToken: CancellationToken, sourceFilesToSearch: ReadonlyArray<SourceFile>): DocumentHighlights[] | undefined {
|
||||
function getSemanticDocumentHighlights(position: number, node: Node, program: Program, cancellationToken: CancellationToken, sourceFilesToSearch: readonly SourceFile[]): DocumentHighlights[] | undefined {
|
||||
const sourceFilesSet = arrayToSet(sourceFilesToSearch, f => f.fileName);
|
||||
const referenceEntries = FindAllReferences.getReferenceEntriesForNode(position, node, program, sourceFilesToSearch, cancellationToken, /*options*/ undefined, sourceFilesSet);
|
||||
if (!referenceEntries) return undefined;
|
||||
@@ -86,16 +86,16 @@ namespace ts.DocumentHighlights {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function getFromAllDeclarations<T extends Node>(nodeTest: (node: Node) => node is T, keywords: ReadonlyArray<SyntaxKind>): HighlightSpan[] | undefined {
|
||||
function getFromAllDeclarations<T extends Node>(nodeTest: (node: Node) => node is T, keywords: readonly SyntaxKind[]): HighlightSpan[] | undefined {
|
||||
return useParent(node.parent, nodeTest, decl => mapDefined(decl.symbol.declarations, d =>
|
||||
nodeTest(d) ? find(d.getChildren(sourceFile), c => contains(keywords, c.kind)) : undefined));
|
||||
}
|
||||
|
||||
function useParent<T extends Node>(node: Node, nodeTest: (node: Node) => node is T, getNodes: (node: T, sourceFile: SourceFile) => ReadonlyArray<Node> | undefined): HighlightSpan[] | undefined {
|
||||
function useParent<T extends Node>(node: Node, nodeTest: (node: Node) => node is T, getNodes: (node: T, sourceFile: SourceFile) => readonly Node[] | undefined): HighlightSpan[] | undefined {
|
||||
return nodeTest(node) ? highlightSpans(getNodes(node, sourceFile)) : undefined;
|
||||
}
|
||||
|
||||
function highlightSpans(nodes: ReadonlyArray<Node> | undefined): HighlightSpan[] | undefined {
|
||||
function highlightSpans(nodes: readonly Node[] | undefined): HighlightSpan[] | undefined {
|
||||
return nodes && nodes.map(node => getHighlightSpanForNode(node, sourceFile));
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ namespace ts.DocumentHighlights {
|
||||
* Aggregates all throw-statements within this node *without* crossing
|
||||
* into function boundaries and try-blocks with catch-clauses.
|
||||
*/
|
||||
function aggregateOwnedThrowStatements(node: Node): ReadonlyArray<ThrowStatement> | undefined {
|
||||
function aggregateOwnedThrowStatements(node: Node): readonly ThrowStatement[] | undefined {
|
||||
if (isThrowStatement(node)) {
|
||||
return [node];
|
||||
}
|
||||
@@ -145,11 +145,11 @@ namespace ts.DocumentHighlights {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function aggregateAllBreakAndContinueStatements(node: Node): ReadonlyArray<BreakOrContinueStatement> | undefined {
|
||||
function aggregateAllBreakAndContinueStatements(node: Node): readonly BreakOrContinueStatement[] | undefined {
|
||||
return isBreakOrContinueStatement(node) ? [node] : isFunctionLike(node) ? undefined : flatMapChildren(node, aggregateAllBreakAndContinueStatements);
|
||||
}
|
||||
|
||||
function flatMapChildren<T>(node: Node, cb: (child: Node) => ReadonlyArray<T> | T | undefined): ReadonlyArray<T> {
|
||||
function flatMapChildren<T>(node: Node, cb: (child: Node) => readonly T[] | T | undefined): readonly T[] {
|
||||
const result: T[] = [];
|
||||
node.forEachChild(child => {
|
||||
const value = cb(child);
|
||||
@@ -192,7 +192,7 @@ namespace ts.DocumentHighlights {
|
||||
return mapDefined(getNodesToSearchForModifier(declaration, modifierToFlag(modifier)), node => findModifier(node, modifier));
|
||||
}
|
||||
|
||||
function getNodesToSearchForModifier(declaration: Node, modifierFlag: ModifierFlags): ReadonlyArray<Node> | undefined {
|
||||
function getNodesToSearchForModifier(declaration: Node, modifierFlag: ModifierFlags): readonly Node[] | undefined {
|
||||
// Types of node whose children might have modifiers.
|
||||
const container = declaration.parent as ModuleBlock | SourceFile | Block | CaseClause | DefaultClause | ConstructorDeclaration | MethodDeclaration | FunctionDeclaration | ObjectTypeDeclaration;
|
||||
switch (container.kind) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace ts.FindAllReferences {
|
||||
export interface SymbolAndEntries {
|
||||
readonly definition: Definition | undefined;
|
||||
readonly references: ReadonlyArray<Entry>;
|
||||
readonly references: readonly Entry[];
|
||||
}
|
||||
|
||||
export const enum DefinitionKind { Symbol, Label, Keyword, This, String }
|
||||
@@ -189,7 +189,7 @@ namespace ts.FindAllReferences {
|
||||
readonly providePrefixAndSuffixTextForRename?: boolean;
|
||||
}
|
||||
|
||||
export function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray<SourceFile>, sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined {
|
||||
export function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: readonly SourceFile[], sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined {
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
const referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken);
|
||||
const checker = program.getTypeChecker();
|
||||
@@ -201,14 +201,14 @@ namespace ts.FindAllReferences {
|
||||
});
|
||||
}
|
||||
|
||||
export function getImplementationsAtPosition(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray<SourceFile>, sourceFile: SourceFile, position: number): ImplementationLocation[] | undefined {
|
||||
export function getImplementationsAtPosition(program: Program, cancellationToken: CancellationToken, sourceFiles: readonly SourceFile[], sourceFile: SourceFile, position: number): ImplementationLocation[] | undefined {
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
const referenceEntries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position);
|
||||
const checker = program.getTypeChecker();
|
||||
return map(referenceEntries, entry => toImplementationLocation(entry, checker));
|
||||
}
|
||||
|
||||
function getImplementationReferenceEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray<SourceFile>, node: Node, position: number): ReadonlyArray<Entry> | undefined {
|
||||
function getImplementationReferenceEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: readonly SourceFile[], node: Node, position: number): readonly Entry[] | undefined {
|
||||
if (node.kind === SyntaxKind.SourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -234,7 +234,7 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
|
||||
export function findReferenceOrRenameEntries<T>(
|
||||
program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray<SourceFile>, node: Node, position: number, options: Options | undefined,
|
||||
program: Program, cancellationToken: CancellationToken, sourceFiles: readonly SourceFile[], node: Node, position: number, options: Options | undefined,
|
||||
convertEntry: ToReferenceOrRenameEntry<T>,
|
||||
): T[] | undefined {
|
||||
return map(flattenEntries(Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options)), entry => convertEntry(entry, node, program.getTypeChecker()));
|
||||
@@ -246,15 +246,15 @@ namespace ts.FindAllReferences {
|
||||
position: number,
|
||||
node: Node,
|
||||
program: Program,
|
||||
sourceFiles: ReadonlyArray<SourceFile>,
|
||||
sourceFiles: readonly SourceFile[],
|
||||
cancellationToken: CancellationToken,
|
||||
options: Options = {},
|
||||
sourceFilesSet: ReadonlyMap<true> = arrayToSet(sourceFiles, f => f.fileName),
|
||||
): ReadonlyArray<Entry> | undefined {
|
||||
): readonly Entry[] | undefined {
|
||||
return flattenEntries(Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options, sourceFilesSet));
|
||||
}
|
||||
|
||||
function flattenEntries(referenceSymbols: ReadonlyArray<SymbolAndEntries> | undefined): ReadonlyArray<Entry> | undefined {
|
||||
function flattenEntries(referenceSymbols: readonly SymbolAndEntries[] | undefined): readonly Entry[] | undefined {
|
||||
return referenceSymbols && flatMap(referenceSymbols, r => r.references);
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ namespace ts.FindAllReferences {
|
||||
// eslint-disable-next-line no-redeclare
|
||||
namespace ts.FindAllReferences.Core {
|
||||
/** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */
|
||||
export function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray<SourceFile>, cancellationToken: CancellationToken, options: Options = {}, sourceFilesSet: ReadonlyMap<true> = arrayToSet(sourceFiles, f => f.fileName)): ReadonlyArray<SymbolAndEntries> | undefined {
|
||||
export function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken, options: Options = {}, sourceFilesSet: ReadonlyMap<true> = arrayToSet(sourceFiles, f => f.fileName)): readonly SymbolAndEntries[] | undefined {
|
||||
if (isSourceFile(node)) {
|
||||
const reference = GoToDefinition.getReferenceAtPosition(node, position, program);
|
||||
const moduleSymbol = reference && program.getTypeChecker().getMergedSymbol(reference.file.symbol);
|
||||
@@ -584,7 +584,7 @@ namespace ts.FindAllReferences.Core {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol: Symbol, program: Program, sourceFiles: ReadonlyArray<SourceFile>, cancellationToken: CancellationToken, options: Options, sourceFilesSet: ReadonlyMap<true>) {
|
||||
function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol: Symbol, program: Program, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken, options: Options, sourceFilesSet: ReadonlyMap<true>) {
|
||||
const moduleSourceFile = symbol.flags & SymbolFlags.Module ? find(symbol.declarations, isSourceFile) : undefined;
|
||||
if (!moduleSourceFile) return undefined;
|
||||
const exportEquals = symbol.exports!.get(InternalSymbolName.ExportEquals);
|
||||
@@ -651,7 +651,7 @@ namespace ts.FindAllReferences.Core {
|
||||
return program.getSourceFiles().indexOf(sourceFile);
|
||||
}
|
||||
|
||||
function getReferencedSymbolsForModule(program: Program, symbol: Symbol, excludeImportTypeOfExportEquals: boolean, sourceFiles: ReadonlyArray<SourceFile>, sourceFilesSet: ReadonlyMap<true>): SymbolAndEntries[] {
|
||||
function getReferencedSymbolsForModule(program: Program, symbol: Symbol, excludeImportTypeOfExportEquals: boolean, sourceFiles: readonly SourceFile[], sourceFilesSet: ReadonlyMap<true>): SymbolAndEntries[] {
|
||||
Debug.assert(!!symbol.valueDeclaration);
|
||||
|
||||
const references = mapDefined<ModuleReference, Entry>(findModuleReferences(program, sourceFiles, symbol), reference => {
|
||||
@@ -716,7 +716,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
|
||||
/** getReferencedSymbols for special node kinds. */
|
||||
function getReferencedSymbolsSpecial(node: Node, sourceFiles: ReadonlyArray<SourceFile>, cancellationToken: CancellationToken): SymbolAndEntries[] | undefined {
|
||||
function getReferencedSymbolsSpecial(node: Node, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken): SymbolAndEntries[] | undefined {
|
||||
if (isTypeKeyword(node.kind)) {
|
||||
// A modifier readonly (like on a property declaration) is not special;
|
||||
// a readonly type keyword (like `readonly string[]`) is.
|
||||
@@ -756,7 +756,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
|
||||
/** Core find-all-references algorithm for a normal symbol. */
|
||||
function getReferencedSymbolsForSymbol(originalSymbol: Symbol, node: Node | undefined, sourceFiles: ReadonlyArray<SourceFile>, sourceFilesSet: ReadonlyMap<true>, checker: TypeChecker, cancellationToken: CancellationToken, options: Options): SymbolAndEntries[] {
|
||||
function getReferencedSymbolsForSymbol(originalSymbol: Symbol, node: Node | undefined, sourceFiles: readonly SourceFile[], sourceFilesSet: ReadonlyMap<true>, checker: TypeChecker, cancellationToken: CancellationToken, options: Options): SymbolAndEntries[] {
|
||||
const symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol;
|
||||
|
||||
// Compute the meaning from the location and the symbol it references
|
||||
@@ -845,8 +845,8 @@ namespace ts.FindAllReferences.Core {
|
||||
readonly text: string;
|
||||
readonly escapedText: __String;
|
||||
/** Only set if `options.implementations` is true. These are the symbols checked to get the implementations of a property access. */
|
||||
readonly parents: ReadonlyArray<Symbol> | undefined;
|
||||
readonly allSearchSymbols: ReadonlyArray<Symbol>;
|
||||
readonly parents: readonly Symbol[] | undefined;
|
||||
readonly allSearchSymbols: readonly Symbol[];
|
||||
|
||||
/**
|
||||
* Whether a symbol is in the search set.
|
||||
@@ -898,7 +898,7 @@ namespace ts.FindAllReferences.Core {
|
||||
readonly markSeenReExportRHS = nodeSeenTracker();
|
||||
|
||||
constructor(
|
||||
readonly sourceFiles: ReadonlyArray<SourceFile>,
|
||||
readonly sourceFiles: readonly SourceFile[],
|
||||
readonly sourceFilesSet: ReadonlyMap<true>,
|
||||
readonly specialSearchKind: SpecialSearchKind,
|
||||
readonly checker: TypeChecker,
|
||||
@@ -960,7 +960,7 @@ namespace ts.FindAllReferences.Core {
|
||||
// Source file ID → symbol ID → Whether the symbol has been searched for in the source file.
|
||||
private readonly sourceFileToSeenSymbols: Map<true>[] = [];
|
||||
/** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */
|
||||
markSearchedSymbols(sourceFile: SourceFile, symbols: ReadonlyArray<Symbol>): boolean {
|
||||
markSearchedSymbols(sourceFile: SourceFile, symbols: readonly Symbol[]): boolean {
|
||||
const sourceId = getNodeId(sourceFile);
|
||||
const seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = createMap<true>());
|
||||
|
||||
@@ -1011,7 +1011,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
|
||||
export function eachExportReference(
|
||||
sourceFiles: ReadonlyArray<SourceFile>,
|
||||
sourceFiles: readonly SourceFile[],
|
||||
checker: TypeChecker,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
exportSymbol: Symbol,
|
||||
@@ -1162,7 +1162,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
}
|
||||
|
||||
export function eachSignatureCall(signature: SignatureDeclaration, sourceFiles: ReadonlyArray<SourceFile>, checker: TypeChecker, cb: (call: CallExpression) => void): void {
|
||||
export function eachSignatureCall(signature: SignatureDeclaration, sourceFiles: readonly SourceFile[], checker: TypeChecker, cb: (call: CallExpression) => void): void {
|
||||
if (!signature.name || !isIdentifier(signature.name)) return;
|
||||
|
||||
const symbol = Debug.assertDefined(checker.getSymbolAtLocation(signature.name));
|
||||
@@ -1181,11 +1181,11 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
}
|
||||
|
||||
function getPossibleSymbolReferenceNodes(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): ReadonlyArray<Node> {
|
||||
function getPossibleSymbolReferenceNodes(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): readonly Node[] {
|
||||
return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(pos => getTouchingPropertyName(sourceFile, pos));
|
||||
}
|
||||
|
||||
function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): ReadonlyArray<number> {
|
||||
function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): readonly number[] {
|
||||
const positions: number[] = [];
|
||||
|
||||
/// TODO: Cache symbol existence for files to save text search
|
||||
@@ -1252,7 +1252,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
}
|
||||
|
||||
function getAllReferencesForKeyword(sourceFiles: ReadonlyArray<SourceFile>, keywordKind: SyntaxKind, cancellationToken: CancellationToken, filter?: (node: Node) => boolean): SymbolAndEntries[] | undefined {
|
||||
function getAllReferencesForKeyword(sourceFiles: readonly SourceFile[], keywordKind: SyntaxKind, cancellationToken: CancellationToken, filter?: (node: Node) => boolean): SymbolAndEntries[] | undefined {
|
||||
const references = flatMap(sourceFiles, sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
return mapDefined(getPossibleSymbolReferenceNodes(sourceFile, tokenToString(keywordKind)!, sourceFile), referenceLocation => {
|
||||
@@ -1743,7 +1743,7 @@ namespace ts.FindAllReferences.Core {
|
||||
return node.kind === SyntaxKind.Identifier && node.parent.kind === SyntaxKind.Parameter && (<ParameterDeclaration>node.parent).name === node;
|
||||
}
|
||||
|
||||
function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: ReadonlyArray<SourceFile>, cancellationToken: CancellationToken): SymbolAndEntries[] | undefined {
|
||||
function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken): SymbolAndEntries[] | undefined {
|
||||
let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false);
|
||||
|
||||
// Whether 'this' occurs in a static context within a class.
|
||||
@@ -1810,7 +1810,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}];
|
||||
}
|
||||
|
||||
function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: ReadonlyArray<SourceFile>, cancellationToken: CancellationToken): SymbolAndEntries[] {
|
||||
function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken): SymbolAndEntries[] {
|
||||
const references = flatMap(sourceFiles, sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
return mapDefined(getPossibleSymbolReferenceNodes(sourceFile, node.text), ref =>
|
||||
@@ -2031,7 +2031,7 @@ namespace ts.FindAllReferences.Core {
|
||||
* symbol may have a different parent symbol if the local type's symbol does not declare the property
|
||||
* being accessed (i.e. it is declared in some parent class or interface)
|
||||
*/
|
||||
function getParentSymbolsOfPropertyAccess(location: Node, symbol: Symbol, checker: TypeChecker): ReadonlyArray<Symbol> | undefined {
|
||||
function getParentSymbolsOfPropertyAccess(location: Node, symbol: Symbol, checker: TypeChecker): readonly Symbol[] | undefined {
|
||||
const propertyAccessExpression = isRightSideOfPropertyAccess(location) ? <PropertyAccessExpression>location.parent : undefined;
|
||||
const lhsType = propertyAccessExpression && checker.getTypeAtLocation(propertyAccessExpression.expression);
|
||||
const res = mapDefined(lhsType && (lhsType.isUnionOrIntersection() ? lhsType.types : lhsType.symbol === symbol.parent ? undefined : [lhsType]), t =>
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace ts.formatting {
|
||||
* This function will return a predicate that for a given text range will tell
|
||||
* if there are any parse errors that overlap with the range.
|
||||
*/
|
||||
function prepareRangeContainsErrorFunction(errors: ReadonlyArray<Diagnostic>, originalRange: TextRange): (r: TextRange) => boolean {
|
||||
function prepareRangeContainsErrorFunction(errors: readonly Diagnostic[], originalRange: TextRange): (r: TextRange) => boolean {
|
||||
if (!errors.length) {
|
||||
return rangeHasNoErrors;
|
||||
}
|
||||
@@ -1222,7 +1222,7 @@ namespace ts.formatting {
|
||||
position === range.end && (range.kind === SyntaxKind.SingleLineCommentTrivia || position === sourceFile.getFullWidth()));
|
||||
}
|
||||
|
||||
function getOpenTokenForList(node: Node, list: ReadonlyArray<Node>) {
|
||||
function getOpenTokenForList(node: Node, list: readonly Node[]) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
|
||||
@@ -3,13 +3,13 @@ namespace ts.formatting {
|
||||
export interface Rule {
|
||||
// Used for debugging to identify each rule based on the property name it's assigned to.
|
||||
readonly debugName: string;
|
||||
readonly context: ReadonlyArray<ContextPredicate>;
|
||||
readonly context: readonly ContextPredicate[];
|
||||
readonly action: RuleAction;
|
||||
readonly flags: RuleFlags;
|
||||
}
|
||||
|
||||
export type ContextPredicate = (context: FormattingContext) => boolean;
|
||||
export const anyContext: ReadonlyArray<ContextPredicate> = emptyArray;
|
||||
export const anyContext: readonly ContextPredicate[] = emptyArray;
|
||||
|
||||
export const enum RuleAction {
|
||||
Ignore = 1 << 0,
|
||||
@@ -24,7 +24,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
export interface TokenRange {
|
||||
readonly tokens: ReadonlyArray<SyntaxKind>;
|
||||
readonly tokens: readonly SyntaxKind[];
|
||||
readonly isSpecific: boolean;
|
||||
}
|
||||
}
|
||||
@@ -364,24 +364,24 @@ namespace ts.formatting {
|
||||
*/
|
||||
function rule(
|
||||
debugName: string,
|
||||
left: SyntaxKind | ReadonlyArray<SyntaxKind> | TokenRange,
|
||||
right: SyntaxKind | ReadonlyArray<SyntaxKind> | TokenRange,
|
||||
context: ReadonlyArray<ContextPredicate>,
|
||||
left: SyntaxKind | readonly SyntaxKind[] | TokenRange,
|
||||
right: SyntaxKind | readonly SyntaxKind[] | TokenRange,
|
||||
context: readonly ContextPredicate[],
|
||||
action: RuleAction,
|
||||
flags: RuleFlags = RuleFlags.None,
|
||||
): RuleSpec {
|
||||
return { leftTokenRange: toTokenRange(left), rightTokenRange: toTokenRange(right), rule: { debugName, context, action, flags } };
|
||||
}
|
||||
|
||||
function tokenRangeFrom(tokens: ReadonlyArray<SyntaxKind>): TokenRange {
|
||||
function tokenRangeFrom(tokens: readonly SyntaxKind[]): TokenRange {
|
||||
return { tokens, isSpecific: true };
|
||||
}
|
||||
|
||||
function toTokenRange(arg: SyntaxKind | ReadonlyArray<SyntaxKind> | TokenRange): TokenRange {
|
||||
function toTokenRange(arg: SyntaxKind | readonly SyntaxKind[] | TokenRange): TokenRange {
|
||||
return typeof arg === "number" ? tokenRangeFrom([arg]) : isArray(arg) ? tokenRangeFrom(arg) : arg;
|
||||
}
|
||||
|
||||
function tokenRangeFromRange(from: SyntaxKind, to: SyntaxKind, except: ReadonlyArray<SyntaxKind> = []): TokenRange {
|
||||
function tokenRangeFromRange(from: SyntaxKind, to: SyntaxKind, except: readonly SyntaxKind[] = []): TokenRange {
|
||||
const tokens: SyntaxKind[] = [];
|
||||
for (let token = from; token <= to; token++) {
|
||||
if (!contains(except, token)) {
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
export type RulesMap = (context: FormattingContext) => Rule | undefined;
|
||||
function createRulesMap(rules: ReadonlyArray<RuleSpec>): RulesMap {
|
||||
function createRulesMap(rules: readonly RuleSpec[]): RulesMap {
|
||||
const map = buildMap(rules);
|
||||
return context => {
|
||||
const bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)];
|
||||
@@ -22,7 +22,7 @@ namespace ts.formatting {
|
||||
};
|
||||
}
|
||||
|
||||
function buildMap(rules: ReadonlyArray<RuleSpec>): ReadonlyArray<ReadonlyArray<Rule>> {
|
||||
function buildMap(rules: readonly RuleSpec[]): readonly (readonly Rule[])[] {
|
||||
// Map from bucket index to array of rules
|
||||
const map: Rule[][] = new Array(mapRowLength * mapRowLength);
|
||||
// This array is used only during construction of the rulesbucket in the map
|
||||
|
||||
@@ -430,7 +430,7 @@ namespace ts.formatting {
|
||||
return Value.Unknown;
|
||||
}
|
||||
|
||||
function deriveActualIndentationFromList(list: ReadonlyArray<Node>, index: number, sourceFile: SourceFile, options: EditorSettings): number {
|
||||
function deriveActualIndentationFromList(list: readonly Node[], index: number, sourceFile: SourceFile, options: EditorSettings): number {
|
||||
Debug.assert(index >= 0 && index < list.length);
|
||||
const node = list[index];
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ts {
|
||||
formatContext: formatting.FormatContext,
|
||||
_preferences: UserPreferences,
|
||||
sourceMapper: SourceMapper,
|
||||
): ReadonlyArray<FileTextChanges> {
|
||||
): readonly FileTextChanges[] {
|
||||
const useCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames(host);
|
||||
const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
const oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper);
|
||||
@@ -91,7 +91,7 @@ namespace ts {
|
||||
|
||||
function updatePaths(property: PropertyAssignment): boolean {
|
||||
// Type annotation needed due to #7294
|
||||
const elements: ReadonlyArray<Expression> = isArrayLiteralExpression(property.initializer) ? property.initializer.elements : [property.initializer];
|
||||
const elements: readonly Expression[] = isArrayLiteralExpression(property.initializer) ? property.initializer.elements : [property.initializer];
|
||||
let foundExactMatch = false;
|
||||
for (const element of elements) {
|
||||
foundExactMatch = tryUpdateString(element) || foundExactMatch;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* @internal */
|
||||
namespace ts.GoToDefinition {
|
||||
export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): ReadonlyArray<DefinitionInfo> | undefined {
|
||||
export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): readonly DefinitionInfo[] | undefined {
|
||||
const reference = getReferenceAtPosition(sourceFile, position, program);
|
||||
if (reference) {
|
||||
return [getDefinitionInfoForFileReference(reference.fileName, reference.file.fileName)];
|
||||
@@ -129,7 +129,7 @@ namespace ts.GoToDefinition {
|
||||
}
|
||||
|
||||
/// Goto type
|
||||
export function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): ReadonlyArray<DefinitionInfo> | undefined {
|
||||
export function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): readonly DefinitionInfo[] | undefined {
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
@@ -145,7 +145,7 @@ namespace ts.GoToDefinition {
|
||||
return fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
|
||||
}
|
||||
|
||||
function definitionFromType(type: Type, checker: TypeChecker, node: Node): ReadonlyArray<DefinitionInfo> {
|
||||
function definitionFromType(type: Type, checker: TypeChecker, node: Node): readonly DefinitionInfo[] {
|
||||
return flatMap(type.isUnion() && !(type.flags & TypeFlags.Enum) ? type.types : [type], t =>
|
||||
t.symbol && getDefinitionFromSymbol(checker, t.symbol, node));
|
||||
}
|
||||
@@ -253,7 +253,7 @@ namespace ts.GoToDefinition {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function getSignatureDefinition(signatureDeclarations: ReadonlyArray<Declaration> | undefined, selectConstructors: boolean): DefinitionInfo[] | undefined {
|
||||
function getSignatureDefinition(signatureDeclarations: readonly Declaration[] | undefined, selectConstructors: boolean): DefinitionInfo[] | undefined {
|
||||
if (!signatureDeclarations) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ namespace ts.GoToDefinition {
|
||||
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
|
||||
}
|
||||
|
||||
export function findReferenceInPosition(refs: ReadonlyArray<FileReference>, pos: number): FileReference | undefined {
|
||||
export function findReferenceInPosition(refs: readonly FileReference[], pos: number): FileReference | undefined {
|
||||
return find(refs, ref => textRangeContainsPositionInclusive(ref, pos));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
namespace ts.FindAllReferences {
|
||||
export interface ImportsResult {
|
||||
/** For every import of the symbol, the location and local symbol for the import. */
|
||||
importSearches: ReadonlyArray<[Identifier, Symbol]>;
|
||||
importSearches: readonly [Identifier, Symbol][];
|
||||
/** For rename imports/exports `{ foo as bar }`, `foo` is not a local, so it may be added as a reference immediately without further searching. */
|
||||
singleReferences: ReadonlyArray<Identifier | StringLiteral>;
|
||||
singleReferences: readonly (Identifier | StringLiteral)[];
|
||||
/** List of source files that may (or may not) use the symbol via a namespace. (For UMD modules this is every file.) */
|
||||
indirectUsers: ReadonlyArray<SourceFile>;
|
||||
indirectUsers: readonly SourceFile[];
|
||||
}
|
||||
export type ImportTracker = (exportSymbol: Symbol, exportInfo: ExportInfo, isForRename: boolean) => ImportsResult;
|
||||
|
||||
/** Creates the imports map and returns an ImportTracker that uses it. Call this lazily to avoid calling `getDirectImportsMap` unnecessarily. */
|
||||
export function createImportTracker(sourceFiles: ReadonlyArray<SourceFile>, sourceFilesSet: ReadonlyMap<true>, checker: TypeChecker, cancellationToken: CancellationToken | undefined): ImportTracker {
|
||||
export function createImportTracker(sourceFiles: readonly SourceFile[], sourceFilesSet: ReadonlyMap<true>, checker: TypeChecker, cancellationToken: CancellationToken | undefined): ImportTracker {
|
||||
const allDirectImports = getDirectImportsMap(sourceFiles, checker, cancellationToken);
|
||||
return (exportSymbol, exportInfo, isForRename) => {
|
||||
const { directImports, indirectUsers } = getImportersForExport(sourceFiles, sourceFilesSet, allDirectImports, exportInfo, checker, cancellationToken);
|
||||
@@ -38,13 +38,13 @@ namespace ts.FindAllReferences {
|
||||
|
||||
/** Returns import statements that directly reference the exporting module, and a list of files that may access the module through a namespace. */
|
||||
function getImportersForExport(
|
||||
sourceFiles: ReadonlyArray<SourceFile>,
|
||||
sourceFiles: readonly SourceFile[],
|
||||
sourceFilesSet: ReadonlyMap<true>,
|
||||
allDirectImports: Map<ImporterOrCallExpression[]>,
|
||||
{ exportingModuleSymbol, exportKind }: ExportInfo,
|
||||
checker: TypeChecker,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
): { directImports: Importer[], indirectUsers: ReadonlyArray<SourceFile> } {
|
||||
): { directImports: Importer[], indirectUsers: readonly SourceFile[] } {
|
||||
const markSeenDirectImport = nodeSeenTracker<ImporterOrCallExpression>();
|
||||
const markSeenIndirectUser = nodeSeenTracker<SourceFileLike>();
|
||||
const directImports: Importer[] = [];
|
||||
@@ -55,7 +55,7 @@ namespace ts.FindAllReferences {
|
||||
|
||||
return { directImports, indirectUsers: getIndirectUsers() };
|
||||
|
||||
function getIndirectUsers(): ReadonlyArray<SourceFile> {
|
||||
function getIndirectUsers(): readonly SourceFile[] {
|
||||
if (isAvailableThroughGlobal) {
|
||||
// It has `export as namespace`, so anything could potentially use it.
|
||||
return sourceFiles;
|
||||
@@ -333,7 +333,7 @@ namespace ts.FindAllReferences {
|
||||
| { kind: "import", literal: StringLiteralLike }
|
||||
/** <reference path> or <reference types> */
|
||||
| { kind: "reference", referencingFile: SourceFile, ref: FileReference };
|
||||
export function findModuleReferences(program: Program, sourceFiles: ReadonlyArray<SourceFile>, searchModuleSymbol: Symbol): ModuleReference[] {
|
||||
export function findModuleReferences(program: Program, sourceFiles: readonly SourceFile[], searchModuleSymbol: Symbol): ModuleReference[] {
|
||||
const refs: ModuleReference[] = [];
|
||||
const checker = program.getTypeChecker();
|
||||
for (const referencingFile of sourceFiles) {
|
||||
@@ -363,7 +363,7 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
|
||||
/** Returns a map from a module symbol Id to all import statements that directly reference the module. */
|
||||
function getDirectImportsMap(sourceFiles: ReadonlyArray<SourceFile>, checker: TypeChecker, cancellationToken: CancellationToken | undefined): Map<ImporterOrCallExpression[]> {
|
||||
function getDirectImportsMap(sourceFiles: readonly SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken | undefined): Map<ImporterOrCallExpression[]> {
|
||||
const map = createMap<ImporterOrCallExpression[]>();
|
||||
|
||||
for (const sourceFile of sourceFiles) {
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace ts.JsDoc {
|
||||
let jsDocTagNameCompletionEntries: CompletionEntry[];
|
||||
let jsDocTagCompletionEntries: CompletionEntry[];
|
||||
|
||||
export function getJsDocCommentsFromDeclarations(declarations: ReadonlyArray<Declaration>): SymbolDisplayPart[] {
|
||||
export function getJsDocCommentsFromDeclarations(declarations: readonly Declaration[]): SymbolDisplayPart[] {
|
||||
// Only collect doc comments from duplicate declarations once:
|
||||
// In case of a union property there might be same declaration multiple times
|
||||
// which only varies in type parameter
|
||||
@@ -102,7 +102,7 @@ namespace ts.JsDoc {
|
||||
return documentationComment;
|
||||
}
|
||||
|
||||
function getCommentHavingNodes(declaration: Declaration): ReadonlyArray<JSDoc | JSDocTag> {
|
||||
function getCommentHavingNodes(declaration: Declaration): readonly (JSDoc | JSDocTag)[] {
|
||||
switch (declaration.kind) {
|
||||
case SyntaxKind.JSDocParameterTag:
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
@@ -163,7 +163,7 @@ namespace ts.JsDoc {
|
||||
* returns a truthy value, then returns that value.
|
||||
* If no such value is found, the callback is applied to each element of array and undefined is returned.
|
||||
*/
|
||||
function forEachUnique<T, U>(array: ReadonlyArray<T> | undefined, callback: (element: T, index: number) => U): U | undefined {
|
||||
function forEachUnique<T, U>(array: readonly T[] | undefined, callback: (element: T, index: number) => U): U | undefined {
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array.indexOf(array[i]) === i) {
|
||||
@@ -327,7 +327,7 @@ namespace ts.JsDoc {
|
||||
return text.slice(lineStart, pos);
|
||||
}
|
||||
|
||||
function parameterDocComments(parameters: ReadonlyArray<ParameterDeclaration>, isJavaScriptFile: boolean, indentationStr: string, newLine: string): string {
|
||||
function parameterDocComments(parameters: readonly ParameterDeclaration[], isJavaScriptFile: boolean, indentationStr: string, newLine: string): string {
|
||||
return parameters.map(({ name, dotDotDotToken }, i) => {
|
||||
const paramName = name.kind === SyntaxKind.Identifier ? name.text : "param" + i;
|
||||
const type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : "";
|
||||
@@ -337,7 +337,7 @@ namespace ts.JsDoc {
|
||||
|
||||
interface CommentOwnerInfo {
|
||||
readonly commentOwner: Node;
|
||||
readonly parameters?: ReadonlyArray<ParameterDeclaration>;
|
||||
readonly parameters?: readonly ParameterDeclaration[];
|
||||
}
|
||||
function getCommentOwnerInfo(tokenAtPos: Node): CommentOwnerInfo | undefined {
|
||||
return forEachAncestor(tokenAtPos, getCommentOwnerInfoWorker);
|
||||
@@ -400,7 +400,7 @@ namespace ts.JsDoc {
|
||||
* @param rightHandSide the expression which may contain an appropriate set of parameters
|
||||
* @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'.
|
||||
*/
|
||||
function getParametersFromRightHandSideOfAssignment(rightHandSide: Expression): ReadonlyArray<ParameterDeclaration> {
|
||||
function getParametersFromRightHandSideOfAssignment(rightHandSide: Expression): readonly ParameterDeclaration[] {
|
||||
while (rightHandSide.kind === SyntaxKind.ParenthesizedExpression) {
|
||||
rightHandSide = (<ParenthesizedExpression>rightHandSide).expression;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ts.NavigateTo {
|
||||
readonly declaration: Declaration;
|
||||
}
|
||||
|
||||
export function getNavigateToItems(sourceFiles: ReadonlyArray<SourceFile>, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number | undefined, excludeDtsFiles: boolean): NavigateToItem[] {
|
||||
export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number | undefined, excludeDtsFiles: boolean): NavigateToItem[] {
|
||||
const patternMatcher = createPatternMatcher(searchValue);
|
||||
if (!patternMatcher) return emptyArray;
|
||||
const rawItems: RawNavigateToItem[] = [];
|
||||
@@ -30,7 +30,7 @@ namespace ts.NavigateTo {
|
||||
return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
|
||||
}
|
||||
|
||||
function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: ReadonlyArray<Declaration>, checker: TypeChecker, fileName: string, rawItems: Push<RawNavigateToItem>): void {
|
||||
function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: readonly Declaration[], checker: TypeChecker, fileName: string, rawItems: Push<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);
|
||||
@@ -84,7 +84,7 @@ namespace ts.NavigateTo {
|
||||
return isPropertyNameLiteral(node) && (containers.push(getTextOfIdentifierOrLiteral(node)), true);
|
||||
}
|
||||
|
||||
function getContainers(declaration: Declaration): ReadonlyArray<string> {
|
||||
function getContainers(declaration: Declaration): readonly string[] {
|
||||
const containers: string[] = [];
|
||||
|
||||
// First, if we started with a computed property name, then add all but the last
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace ts.OrganizeImports {
|
||||
|
||||
const changeTracker = textChanges.ChangeTracker.fromContext({ host, formatContext });
|
||||
|
||||
const coalesceAndOrganizeImports = (importGroup: ReadonlyArray<ImportDeclaration>) => coalesceImports(removeUnusedImports(importGroup, sourceFile, program));
|
||||
const coalesceAndOrganizeImports = (importGroup: readonly ImportDeclaration[]) => coalesceImports(removeUnusedImports(importGroup, sourceFile, program));
|
||||
|
||||
// All of the old ImportDeclarations in the file, in syntactic order.
|
||||
const topLevelImportDecls = sourceFile.statements.filter(isImportDeclaration);
|
||||
@@ -40,8 +40,8 @@ namespace ts.OrganizeImports {
|
||||
return changeTracker.getChanges();
|
||||
|
||||
function organizeImportsWorker<T extends ImportDeclaration | ExportDeclaration>(
|
||||
oldImportDecls: ReadonlyArray<T>,
|
||||
coalesce: (group: ReadonlyArray<T>) => ReadonlyArray<T>) {
|
||||
oldImportDecls: readonly T[],
|
||||
coalesce: (group: readonly T[]) => readonly T[]) {
|
||||
|
||||
if (length(oldImportDecls) === 0) {
|
||||
return;
|
||||
@@ -81,7 +81,7 @@ namespace ts.OrganizeImports {
|
||||
}
|
||||
}
|
||||
|
||||
function removeUnusedImports(oldImports: ReadonlyArray<ImportDeclaration>, sourceFile: SourceFile, program: Program) {
|
||||
function removeUnusedImports(oldImports: readonly ImportDeclaration[], sourceFile: SourceFile, program: Program) {
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
||||
const jsxElementsPresent = !!(sourceFile.transformFlags & TransformFlags.ContainsJsx);
|
||||
@@ -169,7 +169,7 @@ namespace ts.OrganizeImports {
|
||||
/**
|
||||
* @param importGroup a list of ImportDeclarations, all with the same module name.
|
||||
*/
|
||||
export function coalesceImports(importGroup: ReadonlyArray<ImportDeclaration>) {
|
||||
export function coalesceImports(importGroup: readonly ImportDeclaration[]) {
|
||||
if (importGroup.length === 0) {
|
||||
return importGroup;
|
||||
}
|
||||
@@ -246,7 +246,7 @@ namespace ts.OrganizeImports {
|
||||
*
|
||||
* NB: There may be overlap between `defaultImports` and `namespaceImports`/`namedImports`.
|
||||
*/
|
||||
function getCategorizedImports(importGroup: ReadonlyArray<ImportDeclaration>) {
|
||||
function getCategorizedImports(importGroup: readonly ImportDeclaration[]) {
|
||||
let importWithoutClause: ImportDeclaration | undefined;
|
||||
const defaultImports: ImportDeclaration[] = [];
|
||||
const namespaceImports: ImportDeclaration[] = [];
|
||||
@@ -289,7 +289,7 @@ namespace ts.OrganizeImports {
|
||||
/**
|
||||
* @param exportGroup a list of ExportDeclarations, all with the same module name.
|
||||
*/
|
||||
export function coalesceExports(exportGroup: ReadonlyArray<ExportDeclaration>) {
|
||||
export function coalesceExports(exportGroup: readonly ExportDeclaration[]) {
|
||||
if (exportGroup.length === 0) {
|
||||
return exportGroup;
|
||||
}
|
||||
@@ -327,7 +327,7 @@ namespace ts.OrganizeImports {
|
||||
* may lack parent pointers. The desired parts can easily be recovered based on the
|
||||
* categorization.
|
||||
*/
|
||||
function getCategorizedExports(exportGroup: ReadonlyArray<ExportDeclaration>) {
|
||||
function getCategorizedExports(exportGroup: readonly ExportDeclaration[]) {
|
||||
let exportWithoutClause: ExportDeclaration | undefined;
|
||||
const namedExports: ExportDeclaration[] = [];
|
||||
|
||||
@@ -362,7 +362,7 @@ namespace ts.OrganizeImports {
|
||||
importDeclaration.moduleSpecifier);
|
||||
}
|
||||
|
||||
function sortSpecifiers<T extends ImportOrExportSpecifier>(specifiers: ReadonlyArray<T>) {
|
||||
function sortSpecifiers<T extends ImportOrExportSpecifier>(specifiers: readonly T[]) {
|
||||
return stableSort(specifiers, (s1, s2) =>
|
||||
compareIdentifiers(s1.propertyName || s1.name, s2.propertyName || s2.name) ||
|
||||
compareIdentifiers(s1.name, s2.name));
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace ts {
|
||||
// Fully checks a candidate, with an dotted container, against the search pattern.
|
||||
// The candidate must match the last part of the search pattern, and the dotted container
|
||||
// must match the preceding segments of the pattern.
|
||||
getFullMatch(candidateContainers: ReadonlyArray<string>, candidate: string): PatternMatch | undefined;
|
||||
getFullMatch(candidateContainers: readonly string[], candidate: string): PatternMatch | undefined;
|
||||
|
||||
// Whether or not the pattern contained dots or not. Clients can use this to determine
|
||||
// If they should call getMatches, or if getMatchesForLastSegmentOfPattern is sufficient.
|
||||
@@ -115,7 +115,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function getFullMatch(candidateContainers: ReadonlyArray<string>, candidate: string, dotSeparatedSegments: ReadonlyArray<Segment>, stringToWordSpans: Map<TextSpan[]>): PatternMatch | undefined {
|
||||
function getFullMatch(candidateContainers: readonly string[], candidate: string, dotSeparatedSegments: readonly Segment[], stringToWordSpans: Map<TextSpan[]>): PatternMatch | undefined {
|
||||
// First, check that the last part of the dot separated pattern matches the name of the
|
||||
// candidate. If not, then there's no point in proceeding and doing the more
|
||||
// expensive work.
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ts {
|
||||
getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined;
|
||||
|
||||
/** Compute (quickly) which actions are available here */
|
||||
getAvailableActions(context: RefactorContext): ReadonlyArray<ApplicableRefactorInfo>;
|
||||
getAvailableActions(context: RefactorContext): readonly ApplicableRefactorInfo[];
|
||||
}
|
||||
|
||||
export interface RefactorContext extends textChanges.TextChangesContext {
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction {
|
||||
addBraces: boolean;
|
||||
}
|
||||
|
||||
function getAvailableActions(context: RefactorContext): ReadonlyArray<ApplicableRefactorInfo> {
|
||||
function getAvailableActions(context: RefactorContext): readonly ApplicableRefactorInfo[] {
|
||||
const { file, startPosition } = context;
|
||||
const info = getConvertibleArrowFunctionAtPosition(file, startPosition);
|
||||
if (!info) return emptyArray;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace ts.refactor {
|
||||
const actionNameDefaultToNamed = "Convert default export to named export";
|
||||
const actionNameNamedToDefault = "Convert named export to default export";
|
||||
registerRefactor(refactorName, {
|
||||
getAvailableActions(context): ReadonlyArray<ApplicableRefactorInfo> {
|
||||
getAvailableActions(context): readonly ApplicableRefactorInfo[] {
|
||||
const info = getInfo(context);
|
||||
if (!info) return emptyArray;
|
||||
const description = info.wasDefault ? Diagnostics.Convert_default_export_to_named_export.message : Diagnostics.Convert_named_export_to_default_export.message;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace ts.refactor {
|
||||
const actionNameNamespaceToNamed = "Convert namespace import to named imports";
|
||||
const actionNameNamedToNamespace = "Convert named imports to namespace import";
|
||||
registerRefactor(refactorName, {
|
||||
getAvailableActions(context): ReadonlyArray<ApplicableRefactorInfo> {
|
||||
getAvailableActions(context): readonly ApplicableRefactorInfo[] {
|
||||
const i = getImportToConvert(context);
|
||||
if (!i) return emptyArray;
|
||||
const description = i.kind === SyntaxKind.NamespaceImport ? Diagnostics.Convert_namespace_import_to_named_imports.message : Diagnostics.Convert_named_imports_to_namespace_import.message;
|
||||
@@ -123,7 +123,7 @@ namespace ts.refactor {
|
||||
}
|
||||
}
|
||||
|
||||
function updateImport(old: ImportDeclaration, defaultImportName: Identifier | undefined, elements: ReadonlyArray<ImportSpecifier> | undefined): ImportDeclaration {
|
||||
function updateImport(old: ImportDeclaration, defaultImportName: Identifier | undefined, elements: readonly ImportSpecifier[] | undefined): ImportDeclaration {
|
||||
return createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined,
|
||||
createImportClause(defaultImportName, elements && elements.length ? createNamedImports(elements) : undefined), old.moduleSpecifier);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ts.refactor.convertParamsToDestructuredObject {
|
||||
registerRefactor(refactorName, { getEditsForAction, getAvailableActions });
|
||||
|
||||
|
||||
function getAvailableActions(context: RefactorContext): ReadonlyArray<ApplicableRefactorInfo> {
|
||||
function getAvailableActions(context: RefactorContext): readonly ApplicableRefactorInfo[] {
|
||||
const { file, startPosition } = context;
|
||||
const isJSFile = isSourceFileJS(file);
|
||||
if (isJSFile) return emptyArray; // TODO: GH#30113
|
||||
@@ -87,7 +87,7 @@ namespace ts.refactor.convertParamsToDestructuredObject {
|
||||
|
||||
return groupedReferences;
|
||||
|
||||
function groupReferences(referenceEntries: ReadonlyArray<FindAllReferences.Entry>): GroupedReferences {
|
||||
function groupReferences(referenceEntries: readonly FindAllReferences.Entry[]): GroupedReferences {
|
||||
const classReferences: ClassReferences = { accessExpressions: [], typeUsages: [] };
|
||||
const groupedReferences: GroupedReferences = { functionCalls: [], declarations: [], classReferences, valid: true };
|
||||
const functionSymbols = map(functionNames, getSymbolTargetAtLocation);
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ts.refactor.extractSymbol {
|
||||
* Compute the associated code actions
|
||||
* Exported for tests.
|
||||
*/
|
||||
export function getAvailableActions(context: RefactorContext): ReadonlyArray<ApplicableRefactorInfo> {
|
||||
export function getAvailableActions(context: RefactorContext): readonly ApplicableRefactorInfo[] {
|
||||
const rangeToExtract = getRangeToExtract(context.file, getRefactorContextSpan(context));
|
||||
|
||||
const targetRange = rangeToExtract.targetRange;
|
||||
@@ -167,7 +167,7 @@ namespace ts.refactor.extractSymbol {
|
||||
*/
|
||||
type RangeToExtract = {
|
||||
readonly targetRange?: never;
|
||||
readonly errors: ReadonlyArray<Diagnostic>;
|
||||
readonly errors: readonly Diagnostic[];
|
||||
} | {
|
||||
readonly targetRange: TargetRange;
|
||||
readonly errors?: never;
|
||||
@@ -576,7 +576,7 @@ namespace ts.refactor.extractSymbol {
|
||||
|
||||
interface Extraction {
|
||||
readonly description: string;
|
||||
readonly errors: ReadonlyArray<Diagnostic>;
|
||||
readonly errors: readonly Diagnostic[];
|
||||
}
|
||||
|
||||
interface ScopeExtractions {
|
||||
@@ -589,7 +589,7 @@ namespace ts.refactor.extractSymbol {
|
||||
* Each returned ExtractResultForScope corresponds to a possible target scope and is either a set of changes
|
||||
* or an error explaining why we can't extract into that scope.
|
||||
*/
|
||||
function getPossibleExtractions(targetRange: TargetRange, context: RefactorContext): ReadonlyArray<ScopeExtractions> | undefined {
|
||||
function getPossibleExtractions(targetRange: TargetRange, context: RefactorContext): readonly ScopeExtractions[] | undefined {
|
||||
const { scopes, readsAndWrites: { functionErrorsPerScope, constantErrorsPerScope } } = getPossibleExtractionsWorker(targetRange, context);
|
||||
// Need the inner type annotation to avoid https://github.com/Microsoft/TypeScript/issues/7547
|
||||
const extractions = scopes.map((scope, i): ScopeExtractions => {
|
||||
@@ -708,7 +708,7 @@ namespace ts.refactor.extractSymbol {
|
||||
node: Statement | Expression | Block,
|
||||
scope: Scope,
|
||||
{ usages: usagesInScope, typeParameterUsages, substitutions }: ScopeUsages,
|
||||
exposedVariableDeclarations: ReadonlyArray<VariableDeclaration>,
|
||||
exposedVariableDeclarations: readonly VariableDeclaration[],
|
||||
range: TargetRange,
|
||||
context: RefactorContext): RefactorEditInfo {
|
||||
|
||||
@@ -752,13 +752,13 @@ namespace ts.refactor.extractSymbol {
|
||||
const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values()).map(type => ({ type, declaration: getFirstDeclaration(type) }));
|
||||
const sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder);
|
||||
|
||||
const typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined = sortedTypeParametersAndDeclarations.length === 0
|
||||
const typeParameters: readonly TypeParameterDeclaration[] | undefined = sortedTypeParametersAndDeclarations.length === 0
|
||||
? undefined
|
||||
: sortedTypeParametersAndDeclarations.map(t => t.declaration as TypeParameterDeclaration);
|
||||
|
||||
// Strictly speaking, we should check whether each name actually binds to the appropriate type
|
||||
// parameter. In cases of shadowing, they may not.
|
||||
const callTypeArguments: ReadonlyArray<TypeNode> | undefined = typeParameters !== undefined
|
||||
const callTypeArguments: readonly TypeNode[] | undefined = typeParameters !== undefined
|
||||
? typeParameters.map(decl => createTypeReferenceNode(decl.name, /*typeArguments*/ undefined))
|
||||
: undefined;
|
||||
|
||||
@@ -1157,7 +1157,7 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
}
|
||||
|
||||
function transformFunctionBody(body: Node, exposedVariableDeclarations: ReadonlyArray<VariableDeclaration>, writes: ReadonlyArray<UsageEntry> | undefined, substitutions: ReadonlyMap<Node>, hasReturn: boolean): { body: Block, returnValueProperty: string | undefined } {
|
||||
function transformFunctionBody(body: Node, exposedVariableDeclarations: readonly VariableDeclaration[], writes: readonly UsageEntry[] | undefined, substitutions: ReadonlyMap<Node>, hasReturn: boolean): { body: Block, returnValueProperty: string | undefined } {
|
||||
const hasWritesOrVariableDeclarations = writes !== undefined || exposedVariableDeclarations.length > 0;
|
||||
if (isBlock(body) && !hasWritesOrVariableDeclarations && substitutions.size === 0) {
|
||||
// already block, no declarations or writes to propagate back, no substitutions - can use node as is
|
||||
@@ -1224,7 +1224,7 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
}
|
||||
|
||||
function getStatementsOrClassElements(scope: Scope): ReadonlyArray<Statement> | ReadonlyArray<ClassElement> {
|
||||
function getStatementsOrClassElements(scope: Scope): readonly Statement[] | readonly ClassElement[] {
|
||||
if (isFunctionLikeDeclaration(scope)) {
|
||||
const body = scope.body!; // TODO: GH#18217
|
||||
if (isBlock(body)) {
|
||||
@@ -1314,8 +1314,8 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
|
||||
function getPropertyAssignmentsForWritesAndVariableDeclarations(
|
||||
exposedVariableDeclarations: ReadonlyArray<VariableDeclaration>,
|
||||
writes: ReadonlyArray<UsageEntry> | undefined
|
||||
exposedVariableDeclarations: readonly VariableDeclaration[],
|
||||
writes: readonly UsageEntry[] | undefined
|
||||
): ShorthandPropertyAssignment[] {
|
||||
const variableAssignments = map(exposedVariableDeclarations, v => createShorthandPropertyAssignment(v.symbol.name));
|
||||
const writeAssignments = map(writes, w => createShorthandPropertyAssignment(w.symbol.name));
|
||||
@@ -1328,7 +1328,7 @@ namespace ts.refactor.extractSymbol {
|
||||
: variableAssignments.concat(writeAssignments);
|
||||
}
|
||||
|
||||
function isReadonlyArray(v: any): v is ReadonlyArray<any> {
|
||||
function isReadonlyArray(v: any): v is readonly any[] {
|
||||
return isArray(v);
|
||||
}
|
||||
|
||||
@@ -1368,10 +1368,10 @@ namespace ts.refactor.extractSymbol {
|
||||
|
||||
interface ReadsAndWrites {
|
||||
readonly target: Expression | Block;
|
||||
readonly usagesPerScope: ReadonlyArray<ScopeUsages>;
|
||||
readonly functionErrorsPerScope: ReadonlyArray<ReadonlyArray<Diagnostic>>;
|
||||
readonly constantErrorsPerScope: ReadonlyArray<ReadonlyArray<Diagnostic>>;
|
||||
readonly exposedVariableDeclarations: ReadonlyArray<VariableDeclaration>;
|
||||
readonly usagesPerScope: readonly ScopeUsages[];
|
||||
readonly functionErrorsPerScope: readonly (readonly Diagnostic[])[];
|
||||
readonly constantErrorsPerScope: readonly (readonly Diagnostic[])[];
|
||||
readonly exposedVariableDeclarations: readonly VariableDeclaration[];
|
||||
}
|
||||
function collectReadsAndWrites(
|
||||
targetRange: TargetRange,
|
||||
@@ -1399,7 +1399,7 @@ namespace ts.refactor.extractSymbol {
|
||||
|
||||
let expressionDiagnostic: Diagnostic | undefined;
|
||||
if (expression === undefined) {
|
||||
const statements = targetRange.range as ReadonlyArray<Statement>;
|
||||
const statements = targetRange.range as readonly Statement[];
|
||||
const start = first(statements).getStart();
|
||||
const end = last(statements).end;
|
||||
expressionDiagnostic = createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected);
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace ts.refactor {
|
||||
const extractToTypeAlias = "Extract to type alias";
|
||||
const extractToTypeDef = "Extract to typedef";
|
||||
registerRefactor(refactorName, {
|
||||
getAvailableActions(context): ReadonlyArray<ApplicableRefactorInfo> {
|
||||
getAvailableActions(context): readonly ApplicableRefactorInfo[] {
|
||||
const info = getRangeToExtract(context);
|
||||
if (!info) return emptyArray;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace ts.refactor {
|
||||
}
|
||||
});
|
||||
|
||||
interface Info { isJS: boolean; selection: TypeNode; firstStatement: Statement; typeParameters: ReadonlyArray<TypeParameterDeclaration>; }
|
||||
interface Info { isJS: boolean; selection: TypeNode; firstStatement: Statement; typeParameters: readonly TypeParameterDeclaration[]; }
|
||||
|
||||
function getRangeToExtract(context: RefactorContext): Info | undefined {
|
||||
const { file, startPosition } = context;
|
||||
@@ -107,7 +107,7 @@ namespace ts.refactor {
|
||||
}
|
||||
}
|
||||
|
||||
function doTypeAliasChange(changes: textChanges.ChangeTracker, file: SourceFile, name: string, firstStatement: Statement, selection: TypeNode, typeParameters: ReadonlyArray<TypeParameterDeclaration>) {
|
||||
function doTypeAliasChange(changes: textChanges.ChangeTracker, file: SourceFile, name: string, firstStatement: Statement, selection: TypeNode, typeParameters: readonly TypeParameterDeclaration[]) {
|
||||
const newTypeNode = createTypeAliasDeclaration(
|
||||
/* decorators */ undefined,
|
||||
/* modifiers */ undefined,
|
||||
@@ -119,7 +119,7 @@ namespace ts.refactor {
|
||||
changes.replaceNode(file, selection, createTypeReferenceNode(name, typeParameters.map(id => createTypeReferenceNode(id.name, /* typeArguments */ undefined))));
|
||||
}
|
||||
|
||||
function doTypedefChange(changes: textChanges.ChangeTracker, file: SourceFile, name: string, firstStatement: Statement, selection: TypeNode, typeParameters: ReadonlyArray<TypeParameterDeclaration>) {
|
||||
function doTypedefChange(changes: textChanges.ChangeTracker, file: SourceFile, name: string, firstStatement: Statement, selection: TypeNode, typeParameters: readonly TypeParameterDeclaration[]) {
|
||||
const node = <JSDocTypedefTag>createNode(SyntaxKind.JSDocTypedefTag);
|
||||
node.tagName = createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539
|
||||
node.fullName = createIdentifier(name);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
|
||||
readonly renameAccessor: boolean;
|
||||
}
|
||||
|
||||
function getAvailableActions(context: RefactorContext): ReadonlyArray<ApplicableRefactorInfo> {
|
||||
function getAvailableActions(context: RefactorContext): readonly ApplicableRefactorInfo[] {
|
||||
if (!getConvertibleFieldAtPosition(context)) return emptyArray;
|
||||
|
||||
return [{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace ts.refactor {
|
||||
const refactorName = "Move to a new file";
|
||||
registerRefactor(refactorName, {
|
||||
getAvailableActions(context): ReadonlyArray<ApplicableRefactorInfo> {
|
||||
getAvailableActions(context): readonly ApplicableRefactorInfo[] {
|
||||
if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) return emptyArray;
|
||||
const description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
|
||||
return [{ name: refactorName, description, actions: [{ name: refactorName, description }] }];
|
||||
@@ -15,7 +15,7 @@ namespace ts.refactor {
|
||||
}
|
||||
});
|
||||
|
||||
interface RangeToMove { readonly toMove: ReadonlyArray<Statement>; readonly afterLast: Statement | undefined; }
|
||||
interface RangeToMove { readonly toMove: readonly Statement[]; readonly afterLast: Statement | undefined; }
|
||||
function getRangeToMove(context: RefactorContext): RangeToMove | undefined {
|
||||
const { file } = context;
|
||||
const range = createTextRangeFromSpan(getRefactorContextSpan(context));
|
||||
@@ -61,8 +61,8 @@ namespace ts.refactor {
|
||||
readonly afterLast: Statement | undefined;
|
||||
}
|
||||
interface ToMove {
|
||||
readonly all: ReadonlyArray<Statement>;
|
||||
readonly ranges: ReadonlyArray<StatementRange>;
|
||||
readonly all: readonly Statement[];
|
||||
readonly ranges: readonly StatementRange[];
|
||||
}
|
||||
|
||||
// Filters imports out of the range of statements to move. Imports will be copied to the new file anyway, and may still be needed in the old file.
|
||||
@@ -109,7 +109,7 @@ namespace ts.refactor {
|
||||
|
||||
function getNewStatementsAndRemoveFromOldFile(
|
||||
oldFile: SourceFile, usage: UsageInfo, changes: textChanges.ChangeTracker, toMove: ToMove, program: Program, newModuleName: string, preferences: UserPreferences,
|
||||
): ReadonlyArray<Statement> {
|
||||
): readonly Statement[] {
|
||||
const checker = program.getTypeChecker();
|
||||
|
||||
if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
|
||||
@@ -135,13 +135,13 @@ namespace ts.refactor {
|
||||
];
|
||||
}
|
||||
|
||||
function deleteMovedStatements(sourceFile: SourceFile, moved: ReadonlyArray<StatementRange>, changes: textChanges.ChangeTracker) {
|
||||
function deleteMovedStatements(sourceFile: SourceFile, moved: readonly StatementRange[], changes: textChanges.ChangeTracker) {
|
||||
for (const { first, afterLast } of moved) {
|
||||
changes.deleteNodeRangeExcludingEnd(sourceFile, first, afterLast);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteUnusedOldImports(oldFile: SourceFile, toMove: ReadonlyArray<Statement>, changes: textChanges.ChangeTracker, toDelete: ReadonlySymbolSet, checker: TypeChecker) {
|
||||
function deleteUnusedOldImports(oldFile: SourceFile, toMove: readonly Statement[], changes: textChanges.ChangeTracker, toDelete: ReadonlySymbolSet, checker: TypeChecker) {
|
||||
for (const statement of oldFile.statements) {
|
||||
if (contains(toMove, statement)) continue;
|
||||
forEachImportInStatement(statement, i => deleteUnusedImports(oldFile, i, changes, name => toDelete.has(checker.getSymbolAtLocation(name)!)));
|
||||
@@ -283,7 +283,7 @@ namespace ts.refactor {
|
||||
return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports, quotePreference);
|
||||
}
|
||||
|
||||
function makeImportOrRequire(defaultImport: Identifier | undefined, imports: ReadonlyArray<string>, path: string, useEs6Imports: boolean, quotePreference: QuotePreference): Statement | undefined {
|
||||
function makeImportOrRequire(defaultImport: Identifier | undefined, imports: readonly string[], path: string, useEs6Imports: boolean, quotePreference: QuotePreference): Statement | undefined {
|
||||
path = ensurePathIsNonModuleName(path);
|
||||
if (useEs6Imports) {
|
||||
const specifiers = imports.map(i => createImportSpecifier(/*propertyName*/ undefined, createIdentifier(i)));
|
||||
@@ -306,7 +306,7 @@ namespace ts.refactor {
|
||||
return createCall(createIdentifier("require"), /*typeArguments*/ undefined, [moduleSpecifier]);
|
||||
}
|
||||
|
||||
function addExports(sourceFile: SourceFile, toMove: ReadonlyArray<Statement>, needExport: ReadonlySymbolSet, useEs6Exports: boolean): ReadonlyArray<Statement> {
|
||||
function addExports(sourceFile: SourceFile, toMove: readonly Statement[], needExport: ReadonlySymbolSet, useEs6Exports: boolean): readonly Statement[] {
|
||||
return flatMap(toMove, statement => {
|
||||
if (isTopLevelDeclarationStatement(statement) &&
|
||||
!isExported(sourceFile, statement, useEs6Exports) &&
|
||||
@@ -398,7 +398,7 @@ namespace ts.refactor {
|
||||
checker: TypeChecker,
|
||||
useEs6ModuleSyntax: boolean,
|
||||
quotePreference: QuotePreference,
|
||||
): ReadonlyArray<SupportedImportStatement> {
|
||||
): readonly SupportedImportStatement[] {
|
||||
const copiedOldImports: SupportedImportStatement[] = [];
|
||||
for (const oldStatement of oldFile.statements) {
|
||||
forEachImportInStatement(oldStatement, i => {
|
||||
@@ -459,7 +459,7 @@ namespace ts.refactor {
|
||||
// Subset of oldImportsNeededByNewFile that are will no longer be used in the old file.
|
||||
readonly unusedImportsFromOldFile: ReadonlySymbolSet;
|
||||
}
|
||||
function getUsageInfo(oldFile: SourceFile, toMove: ReadonlyArray<Statement>, checker: TypeChecker): UsageInfo {
|
||||
function getUsageInfo(oldFile: SourceFile, toMove: readonly Statement[], checker: TypeChecker): UsageInfo {
|
||||
const movedSymbols = new SymbolSet();
|
||||
const oldImportsNeededByNewFile = new SymbolSet();
|
||||
const newFileImportsFromOldFile = new SymbolSet();
|
||||
@@ -743,7 +743,7 @@ namespace ts.refactor {
|
||||
}
|
||||
}
|
||||
|
||||
function addExport(decl: TopLevelDeclarationStatement, useEs6Exports: boolean): ReadonlyArray<Statement> | undefined {
|
||||
function addExport(decl: TopLevelDeclarationStatement, useEs6Exports: boolean): readonly Statement[] | undefined {
|
||||
return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl);
|
||||
}
|
||||
function addEs6Export(d: TopLevelDeclarationStatement): TopLevelDeclarationStatement {
|
||||
@@ -771,10 +771,10 @@ namespace ts.refactor {
|
||||
return Debug.assertNever(d);
|
||||
}
|
||||
}
|
||||
function addCommonjsExport(decl: TopLevelDeclarationStatement): ReadonlyArray<Statement> | undefined {
|
||||
function addCommonjsExport(decl: TopLevelDeclarationStatement): readonly Statement[] | undefined {
|
||||
return [decl, ...getNamesToExportInCommonJS(decl).map(createExportAssignment)];
|
||||
}
|
||||
function getNamesToExportInCommonJS(decl: TopLevelDeclarationStatement): ReadonlyArray<string> {
|
||||
function getNamesToExportInCommonJS(decl: TopLevelDeclarationStatement): readonly string[] {
|
||||
switch (decl.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
|
||||
+16
-16
@@ -396,10 +396,10 @@ namespace ts {
|
||||
getApparentProperties(): Symbol[] {
|
||||
return this.checker.getAugmentedPropertiesOfType(this);
|
||||
}
|
||||
getCallSignatures(): ReadonlyArray<Signature> {
|
||||
getCallSignatures(): readonly Signature[] {
|
||||
return this.checker.getSignaturesOfType(this, SignatureKind.Call);
|
||||
}
|
||||
getConstructSignatures(): ReadonlyArray<Signature> {
|
||||
getConstructSignatures(): readonly Signature[] {
|
||||
return this.checker.getSignaturesOfType(this, SignatureKind.Construct);
|
||||
}
|
||||
getStringIndexType(): Type | undefined {
|
||||
@@ -509,7 +509,7 @@ namespace ts {
|
||||
return getJSDocTags(node).some(tag => tag.tagName.text === "inheritDoc");
|
||||
}
|
||||
|
||||
function getDocumentationComment(declarations: ReadonlyArray<Declaration> | undefined, checker: TypeChecker | undefined): SymbolDisplayPart[] {
|
||||
function getDocumentationComment(declarations: readonly Declaration[] | undefined, checker: TypeChecker | undefined): SymbolDisplayPart[] {
|
||||
if (!declarations) return emptyArray;
|
||||
|
||||
let doc = JsDoc.getJsDocCommentsFromDeclarations(declarations);
|
||||
@@ -531,7 +531,7 @@ namespace ts {
|
||||
* @param typeChecker A TypeChecker, used to find inherited properties.
|
||||
* @returns A filled array of documentation comments if any were found, otherwise an empty array.
|
||||
*/
|
||||
function findInheritedJSDocComments(declaration: Declaration, propertyName: string, typeChecker: TypeChecker): ReadonlyArray<SymbolDisplayPart> | undefined {
|
||||
function findInheritedJSDocComments(declaration: Declaration, propertyName: string, typeChecker: TypeChecker): readonly SymbolDisplayPart[] | undefined {
|
||||
return firstDefined(declaration.parent ? getAllSuperTypeNodes(declaration.parent) : emptyArray, superTypeNode => {
|
||||
const superType = typeChecker.getTypeAtLocation(superTypeNode);
|
||||
const baseProperty = superType && typeChecker.getPropertyOfType(superType, propertyName);
|
||||
@@ -549,7 +549,7 @@ namespace ts {
|
||||
public originalFileName!: string;
|
||||
public text!: string;
|
||||
public scriptSnapshot!: IScriptSnapshot;
|
||||
public lineMap!: ReadonlyArray<number>;
|
||||
public lineMap!: readonly number[];
|
||||
|
||||
public statements!: NodeArray<Statement>;
|
||||
public endOfFileToken!: Token<SyntaxKind.EndOfFileToken>;
|
||||
@@ -581,7 +581,7 @@ namespace ts {
|
||||
public nameTable: UnderscoreEscapedMap<number> | undefined;
|
||||
public resolvedModules: Map<ResolvedModuleFull> | undefined;
|
||||
public resolvedTypeReferenceDirectiveNames!: Map<ResolvedTypeReferenceDirective>;
|
||||
public imports!: ReadonlyArray<StringLiteralLike>;
|
||||
public imports!: readonly StringLiteralLike[];
|
||||
public moduleAugmentations!: StringLiteral[];
|
||||
private namedDeclarations: Map<Declaration[]> | undefined;
|
||||
public ambientModuleNames!: string[];
|
||||
@@ -603,7 +603,7 @@ namespace ts {
|
||||
return getLineAndCharacterOfPosition(this, position);
|
||||
}
|
||||
|
||||
public getLineStarts(): ReadonlyArray<number> {
|
||||
public getLineStarts(): readonly number[] {
|
||||
return getLineStarts(this);
|
||||
}
|
||||
|
||||
@@ -895,7 +895,7 @@ namespace ts {
|
||||
return this._compilationSettings;
|
||||
}
|
||||
|
||||
public getProjectReferences(): ReadonlyArray<ProjectReference> | undefined {
|
||||
public getProjectReferences(): readonly ProjectReference[] | undefined {
|
||||
return this.host.getProjectReferences && this.host.getProjectReferences();
|
||||
}
|
||||
|
||||
@@ -1519,7 +1519,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/// Goto definition
|
||||
function getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray<DefinitionInfo> | undefined {
|
||||
function getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined {
|
||||
synchronizeHostData();
|
||||
return GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
|
||||
}
|
||||
@@ -1529,7 +1529,7 @@ namespace ts {
|
||||
return GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
|
||||
}
|
||||
|
||||
function getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray<DefinitionInfo> | undefined {
|
||||
function getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined {
|
||||
synchronizeHostData();
|
||||
return GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position);
|
||||
}
|
||||
@@ -1542,7 +1542,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/// References and Occurrences
|
||||
function getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray<ReferenceEntry> | undefined {
|
||||
function getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined {
|
||||
return flatMap(
|
||||
getDocumentHighlights(fileName, position, [fileName]),
|
||||
entry => entry.highlightSpans.map<ReferenceEntry>(highlightSpan => ({
|
||||
@@ -1556,7 +1556,7 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
function getDocumentHighlights(fileName: string, position: number, filesToSearch: ReadonlyArray<string>): DocumentHighlights[] | undefined {
|
||||
function getDocumentHighlights(fileName: string, position: number, filesToSearch: readonly string[]): DocumentHighlights[] | undefined {
|
||||
const normalizedFileName = normalizePath(fileName);
|
||||
Debug.assert(filesToSearch.some(f => normalizePath(f) === normalizedFileName));
|
||||
synchronizeHostData();
|
||||
@@ -1809,7 +1809,7 @@ namespace ts {
|
||||
return [];
|
||||
}
|
||||
|
||||
function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): ReadonlyArray<CodeFixAction> {
|
||||
function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): readonly CodeFixAction[] {
|
||||
synchronizeHostData();
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
const span = createTextSpanFromBounds(start, end);
|
||||
@@ -1830,7 +1830,7 @@ namespace ts {
|
||||
return codefix.getAllFixes({ fixId, sourceFile, program, host, cancellationToken, formatContext, preferences });
|
||||
}
|
||||
|
||||
function organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): ReadonlyArray<FileTextChanges> {
|
||||
function organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): readonly FileTextChanges[] {
|
||||
synchronizeHostData();
|
||||
Debug.assert(scope.type === "file");
|
||||
const sourceFile = getValidSourceFile(scope.fileName);
|
||||
@@ -1839,7 +1839,7 @@ namespace ts {
|
||||
return OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences);
|
||||
}
|
||||
|
||||
function getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): ReadonlyArray<FileTextChanges> {
|
||||
function getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): readonly FileTextChanges[] {
|
||||
return ts.getEditsForFileRename(getProgram()!, oldFilePath, newFilePath, host, formatting.getFormatContext(formatOptions), preferences, sourceMapper);
|
||||
}
|
||||
|
||||
@@ -2252,7 +2252,7 @@ namespace ts {
|
||||
|
||||
/** Gets all symbols for one property. Does not get symbols for every property. */
|
||||
/* @internal */
|
||||
export function getPropertySymbolsFromContextualType(node: ObjectLiteralElementWithName, checker: TypeChecker, contextualType: Type, unionSymbolOk: boolean): ReadonlyArray<Symbol> {
|
||||
export function getPropertySymbolsFromContextualType(node: ObjectLiteralElementWithName, checker: TypeChecker, contextualType: Type, unionSymbolOk: boolean): readonly Symbol[] {
|
||||
const name = getNameFromPropertyName(node.name);
|
||||
if (!name) return emptyArray;
|
||||
if (!contextualType.isUnion()) {
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace ts {
|
||||
packageNameToTypingLocation: Map<JsTyping.CachedTyping>; // The map of package names to their cached typing locations and installed versions
|
||||
typeAcquisition: TypeAcquisition; // Used to customize the type acquisition process
|
||||
compilerOptions: CompilerOptions; // Used as a source for typing inference
|
||||
unresolvedImports: ReadonlyArray<string>; // List of unresolved module ids from imports
|
||||
unresolvedImports: readonly string[]; // List of unresolved module ids from imports
|
||||
typesRegistry: ReadonlyMap<MapLike<string>>; // The map of available typings in npm to maps of TS versions to their latest supported versions
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ namespace ts {
|
||||
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
|
||||
}
|
||||
|
||||
public readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: string[], include?: string[], depth?: number): string[] {
|
||||
public readDirectory(path: string, extensions?: readonly string[], exclude?: string[], include?: string[], depth?: number): string[] {
|
||||
const pattern = getFileMatcherPatterns(path, exclude, include,
|
||||
this.shimHost.useCaseSensitiveFileNames!(), this.shimHost.getCurrentDirectory()); // TODO: GH#18217
|
||||
return JSON.parse(this.shimHost.readDirectory(
|
||||
@@ -510,7 +510,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
public readDirectory(rootDir: string, extensions: ReadonlyArray<string>, exclude: ReadonlyArray<string>, include: ReadonlyArray<string>, depth?: number): string[] {
|
||||
public readDirectory(rootDir: string, extensions: readonly string[], exclude: readonly string[], include: readonly string[], depth?: number): string[] {
|
||||
const pattern = getFileMatcherPatterns(rootDir, exclude, include,
|
||||
this.shimHost.useCaseSensitiveFileNames!(), this.shimHost.getCurrentDirectory()); // TODO: GH#18217
|
||||
return JSON.parse(this.shimHost.readDirectory(
|
||||
@@ -598,7 +598,7 @@ namespace ts {
|
||||
code: number;
|
||||
reportsUnnecessary?: {};
|
||||
}
|
||||
export function realizeDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, newLine: string): RealizedDiagnostic[] {
|
||||
export function realizeDiagnostics(diagnostics: readonly Diagnostic[], newLine: string): RealizedDiagnostic[] {
|
||||
return diagnostics.map(d => realizeDiagnostic(d, newLine));
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
private realizeDiagnostics(diagnostics: ReadonlyArray<Diagnostic>): { message: string; start: number; length: number; category: string; }[] {
|
||||
private realizeDiagnostics(diagnostics: readonly Diagnostic[]): { message: string; start: number; length: number; category: string; }[] {
|
||||
const newLine = getNewLineOrDefaultFromHost(this.host);
|
||||
return realizeDiagnostics(diagnostics, newLine);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ts.SignatureHelp {
|
||||
const enum CandidateOrTypeKind { Candidate, Type }
|
||||
interface CandidateInfo {
|
||||
readonly kind: CandidateOrTypeKind.Candidate;
|
||||
readonly candidates: ReadonlyArray<Signature>;
|
||||
readonly candidates: readonly Signature[];
|
||||
readonly resolvedSignature: Signature;
|
||||
}
|
||||
interface TypeInfo {
|
||||
@@ -491,7 +491,7 @@ namespace ts.SignatureHelp {
|
||||
|
||||
const signatureHelpNodeBuilderFlags = NodeBuilderFlags.OmitParameterModifiers | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope;
|
||||
function createSignatureHelpItems(
|
||||
candidates: ReadonlyArray<Signature>,
|
||||
candidates: readonly Signature[],
|
||||
resolvedSignature: Signature,
|
||||
{ isTypeParameterList, argumentCount, argumentsSpan: applicableSpan, invocation, argumentIndex }: ArgumentListInfo,
|
||||
sourceFile: SourceFile,
|
||||
@@ -524,7 +524,7 @@ namespace ts.SignatureHelp {
|
||||
return { items, applicableSpan, selectedItemIndex: 0, argumentIndex, argumentCount };
|
||||
}
|
||||
|
||||
function getTypeHelpItem(symbol: Symbol, typeParameters: ReadonlyArray<TypeParameter>, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItem {
|
||||
function getTypeHelpItem(symbol: Symbol, typeParameters: readonly TypeParameter[], checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItem {
|
||||
const typeSymbolDisplay = symbolToDisplayParts(checker, symbol);
|
||||
|
||||
const printer = createPrinter({ removeComments: true });
|
||||
@@ -538,7 +538,7 @@ namespace ts.SignatureHelp {
|
||||
|
||||
const separatorDisplayParts: SymbolDisplayPart[] = [punctuationPart(SyntaxKind.CommaToken), spacePart()];
|
||||
|
||||
function getSignatureHelpItem(candidateSignature: Signature, callTargetDisplayParts: ReadonlyArray<SymbolDisplayPart>, isTypeParameterList: boolean, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItem {
|
||||
function getSignatureHelpItem(candidateSignature: Signature, callTargetDisplayParts: readonly SymbolDisplayPart[], isTypeParameterList: boolean, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItem {
|
||||
const { isVariadic, parameters, prefix, suffix } = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile);
|
||||
const prefixDisplayParts = [...callTargetDisplayParts, ...prefix];
|
||||
const suffixDisplayParts = [...suffix, ...returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)];
|
||||
@@ -547,7 +547,7 @@ namespace ts.SignatureHelp {
|
||||
return { isVariadic, prefixDisplayParts, suffixDisplayParts, separatorDisplayParts, parameters, documentation, tags };
|
||||
}
|
||||
|
||||
function returnTypeToDisplayParts(candidateSignature: Signature, enclosingDeclaration: Node, checker: TypeChecker): ReadonlyArray<SymbolDisplayPart> {
|
||||
function returnTypeToDisplayParts(candidateSignature: Signature, enclosingDeclaration: Node, checker: TypeChecker): readonly SymbolDisplayPart[] {
|
||||
return mapToDisplayParts(writer => {
|
||||
writer.writePunctuation(":");
|
||||
writer.writeSpace(" ");
|
||||
@@ -561,7 +561,7 @@ namespace ts.SignatureHelp {
|
||||
});
|
||||
}
|
||||
|
||||
interface SignatureHelpItemInfo { readonly isVariadic: boolean; readonly parameters: SignatureHelpParameter[]; readonly prefix: ReadonlyArray<SymbolDisplayPart>; readonly suffix: ReadonlyArray<SymbolDisplayPart>; }
|
||||
interface SignatureHelpItemInfo { readonly isVariadic: boolean; readonly parameters: SignatureHelpParameter[]; readonly prefix: readonly SymbolDisplayPart[]; readonly suffix: readonly SymbolDisplayPart[]; }
|
||||
|
||||
function itemInfoForTypeParameters(candidateSignature: Signature, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItemInfo {
|
||||
const typeParameters = (candidateSignature.target || candidateSignature).typeParameters;
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace ts.SmartSelectionRange {
|
||||
* selected all together, even though in the AST they’re just siblings of each
|
||||
* other as well as of other top-level statements and declarations.
|
||||
*/
|
||||
function getSelectionChildren(node: Node): ReadonlyArray<Node> {
|
||||
function getSelectionChildren(node: Node): readonly Node[] {
|
||||
// Group top-level imports
|
||||
if (isSourceFile(node)) {
|
||||
return groupChildren(node.getChildAt(0).getChildren(), isImport);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace ts.Completions.StringCompletions {
|
||||
}
|
||||
}
|
||||
|
||||
function convertPathCompletions(pathCompletions: ReadonlyArray<PathCompletion>): CompletionInfo {
|
||||
function convertPathCompletions(pathCompletions: readonly PathCompletion[]): CompletionInfo {
|
||||
const isGlobalCompletion = false; // We don't want the editor to offer any other completions, such as snippets, inside a comment.
|
||||
const isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of.
|
||||
const entries = pathCompletions.map(({ name, kind, span, extension }): CompletionEntry =>
|
||||
@@ -91,15 +91,15 @@ namespace ts.Completions.StringCompletions {
|
||||
const enum StringLiteralCompletionKind { Paths, Properties, Types }
|
||||
interface StringLiteralCompletionsFromProperties {
|
||||
readonly kind: StringLiteralCompletionKind.Properties;
|
||||
readonly symbols: ReadonlyArray<Symbol>;
|
||||
readonly symbols: readonly Symbol[];
|
||||
readonly hasIndexSignature: boolean;
|
||||
}
|
||||
interface StringLiteralCompletionsFromTypes {
|
||||
readonly kind: StringLiteralCompletionKind.Types;
|
||||
readonly types: ReadonlyArray<StringLiteralType>;
|
||||
readonly types: readonly StringLiteralType[];
|
||||
readonly isNewIdentifier: boolean;
|
||||
}
|
||||
type StringLiteralCompletion = { readonly kind: StringLiteralCompletionKind.Paths, readonly paths: ReadonlyArray<PathCompletion> } | StringLiteralCompletionsFromProperties | StringLiteralCompletionsFromTypes;
|
||||
type StringLiteralCompletion = { readonly kind: StringLiteralCompletionKind.Paths, readonly paths: readonly PathCompletion[] } | StringLiteralCompletionsFromProperties | StringLiteralCompletionsFromTypes;
|
||||
function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringLiteralLike, position: number, typeChecker: TypeChecker, compilerOptions: CompilerOptions, host: LanguageServiceHost): StringLiteralCompletion | undefined {
|
||||
const { parent } = node;
|
||||
switch (parent.kind) {
|
||||
@@ -192,7 +192,7 @@ namespace ts.Completions.StringCompletions {
|
||||
}
|
||||
}
|
||||
|
||||
function getAlreadyUsedTypesInStringLiteralUnion(union: UnionTypeNode, current: LiteralTypeNode): ReadonlyArray<string> {
|
||||
function getAlreadyUsedTypesInStringLiteralUnion(union: UnionTypeNode, current: LiteralTypeNode): readonly string[] {
|
||||
return mapDefined(union.types, type =>
|
||||
type !== current && isLiteralTypeNode(type) && isStringLiteral(type.literal) ? type.literal.text : undefined);
|
||||
}
|
||||
@@ -217,7 +217,7 @@ namespace ts.Completions.StringCompletions {
|
||||
return type && { kind: StringLiteralCompletionKind.Properties, symbols: type.getApparentProperties(), hasIndexSignature: hasIndexSignature(type) };
|
||||
}
|
||||
|
||||
function getStringLiteralTypes(type: Type | undefined, uniques = createMap<true>()): ReadonlyArray<StringLiteralType> {
|
||||
function getStringLiteralTypes(type: Type | undefined, uniques = createMap<true>()): readonly StringLiteralType[] {
|
||||
if (!type) return emptyArray;
|
||||
type = skipConstraint(type);
|
||||
return type.isUnion() ? flatMap(type.types, t => getStringLiteralTypes(t, uniques)) :
|
||||
@@ -240,16 +240,16 @@ namespace ts.Completions.StringCompletions {
|
||||
return nameAndKind(name, ScriptElementKind.directory, /*extension*/ undefined);
|
||||
}
|
||||
|
||||
function addReplacementSpans(text: string, textStart: number, names: ReadonlyArray<NameAndKind>): ReadonlyArray<PathCompletion> {
|
||||
function addReplacementSpans(text: string, textStart: number, names: readonly NameAndKind[]): readonly PathCompletion[] {
|
||||
const span = getDirectoryFragmentTextSpan(text, textStart);
|
||||
return names.map(({ name, kind, extension }): PathCompletion => ({ name, kind, extension, span }));
|
||||
}
|
||||
|
||||
function getStringLiteralCompletionsFromModuleNames(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): ReadonlyArray<PathCompletion> {
|
||||
function getStringLiteralCompletionsFromModuleNames(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): readonly PathCompletion[] {
|
||||
return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker));
|
||||
}
|
||||
|
||||
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): ReadonlyArray<NameAndKind> {
|
||||
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): readonly NameAndKind[] {
|
||||
const literalValue = normalizeSlashes(node.text);
|
||||
|
||||
const scriptPath = sourceFile.path;
|
||||
@@ -261,7 +261,7 @@ namespace ts.Completions.StringCompletions {
|
||||
}
|
||||
|
||||
interface ExtensionOptions {
|
||||
readonly extensions: ReadonlyArray<Extension>;
|
||||
readonly extensions: readonly Extension[];
|
||||
readonly includeExtensions: boolean;
|
||||
}
|
||||
function getExtensionOptions(compilerOptions: CompilerOptions, includeExtensions = false): ExtensionOptions {
|
||||
@@ -278,7 +278,7 @@ namespace ts.Completions.StringCompletions {
|
||||
}
|
||||
}
|
||||
|
||||
function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): ReadonlyArray<Extension> {
|
||||
function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): readonly Extension[] {
|
||||
const extensions = getSupportedExtensions(compilerOptions);
|
||||
return compilerOptions.resolveJsonModule && getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs ?
|
||||
extensions.concat(Extension.Json) :
|
||||
@@ -289,7 +289,7 @@ namespace ts.Completions.StringCompletions {
|
||||
* Takes a script path and returns paths for all potential folders that could be merged with its
|
||||
* containing folder via the "rootDirs" compiler option
|
||||
*/
|
||||
function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptDirectory: string, ignoreCase: boolean): ReadonlyArray<string> {
|
||||
function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptDirectory: string, ignoreCase: boolean): readonly string[] {
|
||||
// Make all paths absolute/normalized if they are not already
|
||||
rootDirs = rootDirs.map(rootDirectory => normalizePath(isRootedDiskPath(rootDirectory) ? rootDirectory : combinePaths(basePath, rootDirectory)));
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace ts.Completions.StringCompletions {
|
||||
compareStringsCaseSensitive);
|
||||
}
|
||||
|
||||
function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptDirectory: string, extensionOptions: ExtensionOptions, compilerOptions: CompilerOptions, host: LanguageServiceHost, exclude: string): ReadonlyArray<NameAndKind> {
|
||||
function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptDirectory: string, extensionOptions: ExtensionOptions, compilerOptions: CompilerOptions, host: LanguageServiceHost, exclude: string): readonly NameAndKind[] {
|
||||
const basePath = compilerOptions.project || host.getCurrentDirectory();
|
||||
const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
||||
const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
|
||||
@@ -398,7 +398,7 @@ namespace ts.Completions.StringCompletions {
|
||||
return result;
|
||||
}
|
||||
|
||||
function addCompletionEntriesFromPaths(result: NameAndKind[], fragment: string, baseDirectory: string, fileExtensions: ReadonlyArray<string>, paths: MapLike<string[]>, host: LanguageServiceHost) {
|
||||
function addCompletionEntriesFromPaths(result: NameAndKind[], fragment: string, baseDirectory: string, fileExtensions: readonly string[], paths: MapLike<string[]>, host: LanguageServiceHost) {
|
||||
for (const path in paths) {
|
||||
if (!hasProperty(paths, path)) continue;
|
||||
const patterns = paths[path];
|
||||
@@ -420,7 +420,7 @@ namespace ts.Completions.StringCompletions {
|
||||
* Modules from node_modules (i.e. those listed in package.json)
|
||||
* This includes all files that are found in node_modules/moduleName/ with acceptable file extensions
|
||||
*/
|
||||
function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): ReadonlyArray<NameAndKind> {
|
||||
function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): readonly NameAndKind[] {
|
||||
const { baseUrl, paths } = compilerOptions;
|
||||
|
||||
const result: NameAndKind[] = [];
|
||||
@@ -472,8 +472,8 @@ namespace ts.Completions.StringCompletions {
|
||||
}
|
||||
|
||||
function getCompletionsForPathMapping(
|
||||
path: string, patterns: ReadonlyArray<string>, fragment: string, baseUrl: string, fileExtensions: ReadonlyArray<string>, host: LanguageServiceHost,
|
||||
): ReadonlyArray<NameAndKind> {
|
||||
path: string, patterns: readonly string[], fragment: string, baseUrl: string, fileExtensions: readonly string[], host: LanguageServiceHost,
|
||||
): readonly NameAndKind[] {
|
||||
if (!endsWith(path, "*")) {
|
||||
// For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion.
|
||||
return !stringContains(path, "*") ? justPathMappingName(path) : emptyArray;
|
||||
@@ -484,12 +484,12 @@ namespace ts.Completions.StringCompletions {
|
||||
return remainingFragment === undefined ? justPathMappingName(pathPrefix) : flatMap(patterns, pattern =>
|
||||
getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host));
|
||||
|
||||
function justPathMappingName(name: string): ReadonlyArray<NameAndKind> {
|
||||
function justPathMappingName(name: string): readonly NameAndKind[] {
|
||||
return startsWith(name, fragment) ? [directoryResult(name)] : emptyArray;
|
||||
}
|
||||
}
|
||||
|
||||
function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: ReadonlyArray<string>, host: LanguageServiceHost): ReadonlyArray<NameAndKind> | undefined {
|
||||
function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: readonly string[], host: LanguageServiceHost): readonly NameAndKind[] | undefined {
|
||||
if (!host.readDirectory) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -546,7 +546,7 @@ namespace ts.Completions.StringCompletions {
|
||||
return path[0] === directorySeparator ? path.slice(1) : path;
|
||||
}
|
||||
|
||||
function getAmbientModuleCompletions(fragment: string, fragmentDirectory: string | undefined, checker: TypeChecker): ReadonlyArray<string> {
|
||||
function getAmbientModuleCompletions(fragment: string, fragmentDirectory: string | undefined, checker: TypeChecker): readonly string[] {
|
||||
// Get modules that the type checker picked up
|
||||
const ambientModules = checker.getAmbientModules().map(sym => stripQuotes(sym.name));
|
||||
const nonRelativeModuleNames = ambientModules.filter(moduleName => startsWith(moduleName, fragment));
|
||||
@@ -561,7 +561,7 @@ namespace ts.Completions.StringCompletions {
|
||||
return nonRelativeModuleNames;
|
||||
}
|
||||
|
||||
function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number, compilerOptions: CompilerOptions, host: LanguageServiceHost): ReadonlyArray<PathCompletion> | undefined {
|
||||
function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number, compilerOptions: CompilerOptions, host: LanguageServiceHost): readonly PathCompletion[] | undefined {
|
||||
const token = getTokenAtPosition(sourceFile, position);
|
||||
const commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
||||
const range = commentRanges && find(commentRanges, commentRange => position >= commentRange.pos && position <= commentRange.end);
|
||||
@@ -582,7 +582,7 @@ namespace ts.Completions.StringCompletions {
|
||||
return addReplacementSpans(toComplete, range.pos + prefix.length, names);
|
||||
}
|
||||
|
||||
function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, fragmentDirectory: string | undefined, extensionOptions: ExtensionOptions, result: NameAndKind[] = []): ReadonlyArray<NameAndKind> {
|
||||
function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, fragmentDirectory: string | undefined, extensionOptions: ExtensionOptions, result: NameAndKind[] = []): readonly NameAndKind[] {
|
||||
// Check for typings specified in compiler options
|
||||
const seen = createMap<true>();
|
||||
|
||||
@@ -648,7 +648,7 @@ namespace ts.Completions.StringCompletions {
|
||||
return packageJson;
|
||||
}
|
||||
|
||||
function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string): ReadonlyArray<string> {
|
||||
function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string): readonly string[] {
|
||||
if (!host.readFile || !host.fileExists) return emptyArray;
|
||||
|
||||
const result: string[] = [];
|
||||
@@ -701,13 +701,13 @@ namespace ts.Completions.StringCompletions {
|
||||
*/
|
||||
const tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*<reference\s+(path|types)\s*=\s*(?:'|"))([^\3"]*)$/;
|
||||
|
||||
const nodeModulesDependencyKeys: ReadonlyArray<string> = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
||||
const nodeModulesDependencyKeys: readonly string[] = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
||||
|
||||
function tryGetDirectories(host: LanguageServiceHost, directoryName: string): string[] {
|
||||
return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || [];
|
||||
}
|
||||
|
||||
function tryReadDirectory(host: LanguageServiceHost, path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>): ReadonlyArray<string> {
|
||||
function tryReadDirectory(host: LanguageServiceHost, path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[]): readonly string[] {
|
||||
return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || emptyArray;
|
||||
}
|
||||
|
||||
|
||||
@@ -603,7 +603,7 @@ namespace ts.SymbolDisplay {
|
||||
}
|
||||
}
|
||||
|
||||
function addSignatureDisplayParts(signature: Signature, allSignatures: ReadonlyArray<Signature>, flags = TypeFormatFlags.None) {
|
||||
function addSignatureDisplayParts(signature: Signature, allSignatures: readonly Signature[], flags = TypeFormatFlags.None) {
|
||||
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
if (allSignatures.length > 1) {
|
||||
displayParts.push(spacePart());
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user