Skip to content

Commit c60774b

Browse files
author
Andy
authored
Make many 'static' variables readonly (microsoft#17306)
1 parent 759ee28 commit c60774b

7 files changed

Lines changed: 13 additions & 15 deletions

File tree

src/harness/fourslash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ namespace FourSlash {
130130
// 0 - cancelled
131131
// >0 - not cancelled
132132
// <0 - not cancelled and value denotes number of isCancellationRequested after which token become cancelled
133-
private static NotCanceled: number = -1;
133+
private static readonly NotCanceled: number = -1;
134134
private numberOfCallsBeforeCancellation: number = TestCancellationToken.NotCanceled;
135135

136136
public isCancellationRequested(): boolean {

src/harness/harnessLanguageService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace Harness.LanguageService {
108108
}
109109

110110
class DefaultHostCancellationToken implements ts.HostCancellationToken {
111-
public static Instance = new DefaultHostCancellationToken();
111+
public static readonly Instance = new DefaultHostCancellationToken();
112112

113113
public isCancellationRequested() {
114114
return false;

src/harness/rwcRunner.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,8 @@ namespace RWC {
238238
}
239239

240240
class RWCRunner extends RunnerBase {
241-
private static sourcePath = "internal/cases/rwc/";
242-
243241
public enumerateTestFiles() {
244-
return Harness.IO.listFiles(RWCRunner.sourcePath, /.+\.json$/);
242+
return Harness.IO.listFiles("internal/cases/rwc/", /.+\.json$/);
245243
}
246244

247245
public kind(): TestRunnerKind {

src/harness/test262Runner.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
/* tslint:disable:no-null-keyword */
55

66
class Test262BaselineRunner extends RunnerBase {
7-
private static basePath = "internal/cases/test262";
8-
private static helpersFilePath = "tests/cases/test262-harness/helpers.d.ts";
9-
private static helperFile: Harness.Compiler.TestFile = {
7+
private static readonly basePath = "internal/cases/test262";
8+
private static readonly helpersFilePath = "tests/cases/test262-harness/helpers.d.ts";
9+
private static readonly helperFile: Harness.Compiler.TestFile = {
1010
unitName: Test262BaselineRunner.helpersFilePath,
1111
content: Harness.IO.readFile(Test262BaselineRunner.helpersFilePath),
1212
};
13-
private static testFileExtensionRegex = /\.js$/;
14-
private static options: ts.CompilerOptions = {
13+
private static readonly testFileExtensionRegex = /\.js$/;
14+
private static readonly options: ts.CompilerOptions = {
1515
allowNonTsExtensions: true,
1616
target: ts.ScriptTarget.Latest,
1717
module: ts.ModuleKind.CommonJS
1818
};
19-
private static baselineOptions: Harness.Baseline.BaselineOptions = {
19+
private static readonly baselineOptions: Harness.Baseline.BaselineOptions = {
2020
Subfolder: "test262",
2121
Baselinefolder: "internal/baselines"
2222
};

src/server/editorServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ namespace ts.server {
16141614
}
16151615

16161616
/** Makes a filename safe to insert in a RegExp */
1617-
private static filenameEscapeRegexp = /[-\/\\^$*+?.()|[\]{}]/g;
1617+
private static readonly filenameEscapeRegexp = /[-\/\\^$*+?.()|[\]{}]/g;
16181618
private static escapeFilenameForRegex(filename: string) {
16191619
return filename.replace(this.filenameEscapeRegexp, "\\$&");
16201620
}

src/server/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ namespace ts.server {
837837
*/
838838
export class InferredProject extends Project {
839839

840-
private static newName = (() => {
840+
private static readonly newName = (() => {
841841
let nextId = 1;
842842
return () => {
843843
const id = nextId;

src/services/formatting/ruleOperationContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
namespace ts.formatting {
55

66
export class RuleOperationContext {
7-
private customContextChecks: { (context: FormattingContext): boolean; }[];
7+
private readonly customContextChecks: { (context: FormattingContext): boolean; }[];
88

99
constructor(...funcs: { (context: FormattingContext): boolean; }[]) {
1010
this.customContextChecks = funcs;
1111
}
1212

13-
static Any: RuleOperationContext = new RuleOperationContext();
13+
static readonly Any: RuleOperationContext = new RuleOperationContext();
1414

1515
public IsAny(): boolean {
1616
return this === RuleOperationContext.Any;

0 commit comments

Comments
 (0)