Skip to content

Session: don't return undefined if a response is required #17165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
6 commits merged into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/harness/unittests/projectErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace ts.projectSystem {
describe("Project errors", () => {
function checkProjectErrors(projectFiles: server.ProjectFilesWithTSDiagnostics, expectedErrors: string[]) {
function checkProjectErrors(projectFiles: server.ProjectFilesWithTSDiagnostics, expectedErrors: ReadonlyArray<string>): void {
assert.isTrue(projectFiles !== undefined, "missing project files");
checkProjectErrorsWorker(projectFiles.projectErrors, expectedErrors);
}

function checkProjectErrorsWorker(errors: Diagnostic[], expectedErrors: string[]) {
function checkProjectErrorsWorker(errors: ReadonlyArray<Diagnostic>, expectedErrors: ReadonlyArray<string>): void {
assert.equal(errors ? errors.length : 0, expectedErrors.length, `expected ${expectedErrors.length} error in the list`);
if (expectedErrors.length) {
for (let i = 0; i < errors.length; i++) {
Expand Down
18 changes: 9 additions & 9 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ts.server {

export interface ConfigFileDiagEvent {
eventName: typeof ConfigFileDiagEvent;
data: { triggerFile: string, configFileName: string, diagnostics: Diagnostic[] };
data: { triggerFile: string, configFileName: string, diagnostics: ReadonlyArray<Diagnostic> };
}

export interface ProjectLanguageServiceStateEvent {
Expand Down Expand Up @@ -200,7 +200,7 @@ namespace ts.server {
/**
* This helper function processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project.
*/
export function combineProjectOutput<T>(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean) {
export function combineProjectOutput<T>(projects: ReadonlyArray<Project>, action: (project: Project) => ReadonlyArray<T>, comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean) {
const result = flatMap(projects, action).sort(comparer);
return projects.length > 1 ? deduplicate(result, areEqual) : result;
}
Expand All @@ -220,14 +220,14 @@ namespace ts.server {

interface OpenConfigFileResult {
success: boolean;
errors?: Diagnostic[];
errors?: ReadonlyArray<Diagnostic>;

project?: ConfiguredProject;
}

export interface OpenConfiguredProjectResult {
configFileName?: NormalizedPath;
configFileErrors?: Diagnostic[];
configFileErrors?: ReadonlyArray<Diagnostic>;
}

interface FilePropertyReader<T> {
Expand Down Expand Up @@ -1102,18 +1102,18 @@ namespace ts.server {
}
}

private reportConfigFileDiagnostics(configFileName: string, diagnostics: Diagnostic[], triggerFile: string) {
private reportConfigFileDiagnostics(configFileName: string, diagnostics: ReadonlyArray<Diagnostic>, triggerFile: string) {
if (!this.eventHandler) {
return;
}

this.eventHandler(<ConfigFileDiagEvent>{
eventName: ConfigFileDiagEvent,
data: { configFileName, diagnostics: diagnostics || [], triggerFile }
data: { configFileName, diagnostics: diagnostics || emptyArray, triggerFile }
});
}

private createAndAddConfiguredProject(configFileName: NormalizedPath, projectOptions: ProjectOptions, configFileErrors: Diagnostic[], clientFileName?: string) {
private createAndAddConfiguredProject(configFileName: NormalizedPath, projectOptions: ProjectOptions, configFileErrors: ReadonlyArray<Diagnostic>, clientFileName?: string) {
const sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader);
const project = new ConfiguredProject(
configFileName,
Expand Down Expand Up @@ -1145,7 +1145,7 @@ namespace ts.server {
}
}

private addFilesToProjectAndUpdateGraph<T>(project: ConfiguredProject | ExternalProject, files: T[], propertyReader: FilePropertyReader<T>, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: Diagnostic[]): void {
private addFilesToProjectAndUpdateGraph<T>(project: ConfiguredProject | ExternalProject, files: T[], propertyReader: FilePropertyReader<T>, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray<Diagnostic>): void {
let errors: Diagnostic[];
for (const f of files) {
const rootFilename = propertyReader.getFileName(f);
Expand Down Expand Up @@ -1458,7 +1458,7 @@ namespace ts.server {

openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult {
let configFileName: NormalizedPath;
let configFileErrors: Diagnostic[];
let configFileErrors: ReadonlyArray<Diagnostic>;

let project: ConfiguredProject | ExternalProject = this.findContainingExternalProject(fileName);
if (!project) {
Expand Down
8 changes: 4 additions & 4 deletions src/server/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace ts.server {

/* @internal */
export interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles {
projectErrors: Diagnostic[];
projectErrors: ReadonlyArray<Diagnostic>;
}

export class UnresolvedImportsMap {
Expand Down Expand Up @@ -147,7 +147,7 @@ namespace ts.server {

private typingFiles: SortedReadonlyArray<string>;

protected projectErrors: Diagnostic[];
protected projectErrors: ReadonlyArray<Diagnostic>;

public typesVersion = 0;

Expand Down Expand Up @@ -1045,7 +1045,7 @@ namespace ts.server {
return getDirectoryPath(this.getConfigFilePath());
}

setProjectErrors(projectErrors: Diagnostic[]) {
setProjectErrors(projectErrors: ReadonlyArray<Diagnostic>) {
this.projectErrors = projectErrors;
}

Expand Down Expand Up @@ -1189,7 +1189,7 @@ namespace ts.server {
return this.typeAcquisition;
}

setProjectErrors(projectErrors: Diagnostic[]) {
setProjectErrors(projectErrors: ReadonlyArray<Diagnostic>) {
this.projectErrors = projectErrors;
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ namespace ts.server.protocol {
/**
* An array of span groups (one per file) that refer to the item to be renamed.
*/
locs: SpanGroup[];
locs: ReadonlyArray<SpanGroup>;
}

/**
Expand Down
Loading