Skip to content

Commit 18794c7

Browse files
authored
Enable noImplicitOverride (#52290)
1 parent da085ae commit 18794c7

File tree

14 files changed

+121
-120
lines changed

14 files changed

+121
-120
lines changed

src/harness/evaluatorImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class CommonJsLoader extends Loader<CommonJSModule> {
147147
return this.resolveIndex(dir);
148148
}
149149

150-
protected resolve(id: string, base: string) {
150+
protected override resolve(id: string, base: string) {
151151
const file = vpath.resolve(base, id);
152152
const resolved = this.resolveAsFile(file) || this.resolveAsDirectory(file);
153153
if (!resolved) throw new Error(`Module '${id}' could not be found.`);

src/harness/harnessLanguageService.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -295,23 +295,23 @@ class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts
295295
return script ? script.version.toString() : undefined!; // TODO: GH#18217
296296
}
297297

298-
directoryExists(dirName: string): boolean {
298+
override directoryExists(dirName: string): boolean {
299299
return this.sys.directoryExists(dirName);
300300
}
301301

302-
fileExists(fileName: string): boolean {
302+
override fileExists(fileName: string): boolean {
303303
return this.sys.fileExists(fileName);
304304
}
305305

306306
readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] {
307307
return this.sys.readDirectory(path, extensions, exclude, include, depth);
308308
}
309309

310-
readFile(path: string): string | undefined {
310+
override readFile(path: string): string | undefined {
311311
return this.sys.readFile(path);
312312
}
313313

314-
realpath(path: string): string {
314+
override realpath(path: string): string {
315315
return this.sys.realpath(path);
316316
}
317317

@@ -389,11 +389,11 @@ class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.L
389389
}
390390
}
391391

392-
getFilenames(): string[] { return this.nativeHost.getFilenames(); }
393-
getScriptInfo(fileName: string): ScriptInfo | undefined { return this.nativeHost.getScriptInfo(fileName); }
394-
addScript(fileName: string, content: string, isRootFile: boolean): void { this.nativeHost.addScript(fileName, content, isRootFile); }
395-
editScript(fileName: string, start: number, end: number, newText: string): void { this.nativeHost.editScript(fileName, start, end, newText); }
396-
positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToLineAndCharacter(fileName, position); }
392+
override getFilenames(): string[] { return this.nativeHost.getFilenames(); }
393+
override getScriptInfo(fileName: string): ScriptInfo | undefined { return this.nativeHost.getScriptInfo(fileName); }
394+
override addScript(fileName: string, content: string, isRootFile: boolean): void { this.nativeHost.addScript(fileName, content, isRootFile); }
395+
override editScript(fileName: string, start: number, end: number, newText: string): void { this.nativeHost.editScript(fileName, start, end, newText); }
396+
override positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToLineAndCharacter(fileName, position); }
397397

398398
getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); }
399399
getCancellationToken(): ts.HostCancellationToken { return this.nativeHost.getCancellationToken(); }
@@ -412,15 +412,15 @@ class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.L
412412
readDirectory = ts.notImplemented;
413413
readDirectoryNames = ts.notImplemented;
414414
readFileNames = ts.notImplemented;
415-
fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; }
416-
readFile(fileName: string) {
415+
override fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; }
416+
override readFile(fileName: string) {
417417
const snapshot = this.nativeHost.getScriptSnapshot(fileName);
418418
return snapshot && ts.getSnapshotText(snapshot);
419419
}
420420
log(s: string): void { this.nativeHost.log(s); }
421421
trace(s: string): void { this.nativeHost.trace(s); }
422422
error(s: string): void { this.nativeHost.error(s); }
423-
directoryExists(): boolean {
423+
override directoryExists(): boolean {
424424
// for tests pessimistically assume that directory always exists
425425
return true;
426426
}
@@ -746,12 +746,12 @@ class SessionClientHost extends NativeLanguageServiceHost implements ts.server.S
746746
this.client = client;
747747
}
748748

749-
openFile(fileName: string, content?: string, scriptKindName?: "TS" | "JS" | "TSX" | "JSX"): void {
749+
override openFile(fileName: string, content?: string, scriptKindName?: "TS" | "JS" | "TSX" | "JSX"): void {
750750
super.openFile(fileName, content, scriptKindName);
751751
this.client.openFile(fileName, content, scriptKindName);
752752
}
753753

754-
editScript(fileName: string, start: number, end: number, newText: string) {
754+
override editScript(fileName: string, start: number, end: number, newText: string) {
755755
const changeArgs = this.client.createChangeFileRequestArgs(fileName, start, end, newText);
756756
super.editScript(fileName, start, end, newText);
757757
this.client.changeFile(fileName, changeArgs);

src/server/project.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,7 +2124,7 @@ export class InferredProject extends Project {
21242124
}
21252125
}
21262126

2127-
setCompilerOptions(options?: CompilerOptions) {
2127+
override setCompilerOptions(options?: CompilerOptions) {
21282128
// Avoid manipulating the given options directly
21292129
if (!options && !this.getCompilationSettings()) {
21302130
return;
@@ -2180,7 +2180,7 @@ export class InferredProject extends Project {
21802180
this.enableGlobalPlugins(this.getCompilerOptions(), pluginConfigOverrides);
21812181
}
21822182

2183-
addRoot(info: ScriptInfo) {
2183+
override addRoot(info: ScriptInfo) {
21842184
Debug.assert(info.isScriptOpen());
21852185
this.projectService.startWatchingConfigFilesForInferredProjectRoot(info);
21862186
if (!this._isJsInferredProject && info.isJavaScript()) {
@@ -2189,7 +2189,7 @@ export class InferredProject extends Project {
21892189
super.addRoot(info);
21902190
}
21912191

2192-
removeRoot(info: ScriptInfo) {
2192+
override removeRoot(info: ScriptInfo) {
21932193
this.projectService.stopWatchingConfigFilesForInferredProjectRoot(info);
21942194
super.removeRoot(info);
21952195
if (this._isJsInferredProject && info.isJavaScript()) {
@@ -2200,7 +2200,7 @@ export class InferredProject extends Project {
22002200
}
22012201

22022202
/** @internal */
2203-
isOrphan() {
2203+
override isOrphan() {
22042204
return !this.hasRoots();
22052205
}
22062206

@@ -2212,12 +2212,12 @@ export class InferredProject extends Project {
22122212
this.getRootScriptInfos().length === 1;
22132213
}
22142214

2215-
close() {
2215+
override close() {
22162216
forEach(this.getRootScriptInfos(), info => this.projectService.stopWatchingConfigFilesForInferredProjectRoot(info));
22172217
super.close();
22182218
}
22192219

2220-
getTypeAcquisition(): TypeAcquisition {
2220+
override getTypeAcquisition(): TypeAcquisition {
22212221
return this.typeAcquisition || {
22222222
enable: allRootFilesAreJsOrDts(this),
22232223
include: ts.emptyArray,
@@ -2241,12 +2241,12 @@ class AuxiliaryProject extends Project {
22412241
/*currentDirectory*/ undefined);
22422242
}
22432243

2244-
isOrphan(): boolean {
2244+
override isOrphan(): boolean {
22452245
return true;
22462246
}
22472247

22482248
/** @internal */
2249-
scheduleInvalidateResolutionsOfFailedLookupLocations(): void {
2249+
override scheduleInvalidateResolutionsOfFailedLookupLocations(): void {
22502250
// Invalidation will happen on-demand as part of updateGraph
22512251
return;
22522252
}
@@ -2436,11 +2436,11 @@ export class AutoImportProviderProject extends Project {
24362436
return !some(this.rootFileNames);
24372437
}
24382438

2439-
isOrphan() {
2439+
override isOrphan() {
24402440
return true;
24412441
}
24422442

2443-
updateGraph() {
2443+
override updateGraph() {
24442444
let rootFileNames = this.rootFileNames;
24452445
if (!rootFileNames) {
24462446
rootFileNames = AutoImportProviderProject.getRootFileNames(
@@ -2461,62 +2461,62 @@ export class AutoImportProviderProject extends Project {
24612461
}
24622462

24632463
/** @internal */
2464-
scheduleInvalidateResolutionsOfFailedLookupLocations(): void {
2464+
override scheduleInvalidateResolutionsOfFailedLookupLocations(): void {
24652465
// Invalidation will happen on-demand as part of updateGraph
24662466
return;
24672467
}
24682468

2469-
hasRoots() {
2469+
override hasRoots() {
24702470
return !!this.rootFileNames?.length;
24712471
}
24722472

2473-
markAsDirty() {
2473+
override markAsDirty() {
24742474
this.rootFileNames = undefined;
24752475
super.markAsDirty();
24762476
}
24772477

2478-
getScriptFileNames() {
2478+
override getScriptFileNames() {
24792479
return this.rootFileNames || ts.emptyArray;
24802480
}
24812481

2482-
getLanguageService(): never {
2482+
override getLanguageService(): never {
24832483
throw new Error("AutoImportProviderProject language service should never be used. To get the program, use `project.getCurrentProgram()`.");
24842484
}
24852485

24862486
/** @internal */
2487-
onAutoImportProviderSettingsChanged(): never {
2487+
override onAutoImportProviderSettingsChanged(): never {
24882488
throw new Error("AutoImportProviderProject is an auto import provider; use `markAsDirty()` instead.");
24892489
}
24902490

24912491
/** @internal */
2492-
onPackageJsonChange(): never {
2492+
override onPackageJsonChange(): never {
24932493
throw new Error("package.json changes should be notified on an AutoImportProvider's host project");
24942494
}
24952495

2496-
getModuleResolutionHostForAutoImportProvider(): never {
2496+
override getModuleResolutionHostForAutoImportProvider(): never {
24972497
throw new Error("AutoImportProviderProject cannot provide its own host; use `hostProject.getModuleResolutionHostForAutomImportProvider()` instead.");
24982498
}
24992499

2500-
getProjectReferences() {
2500+
override getProjectReferences() {
25012501
return this.hostProject.getProjectReferences();
25022502
}
25032503

25042504
/** @internal */
2505-
includePackageJsonAutoImports() {
2505+
override includePackageJsonAutoImports() {
25062506
return PackageJsonAutoImportPreference.Off;
25072507
}
25082508

2509-
getTypeAcquisition(): TypeAcquisition {
2509+
override getTypeAcquisition(): TypeAcquisition {
25102510
return { enable: false };
25112511
}
25122512

25132513
/** @internal */
2514-
getSymlinkCache() {
2514+
override getSymlinkCache() {
25152515
return this.hostProject.getSymlinkCache();
25162516
}
25172517

25182518
/** @internal */
2519-
getModuleResolutionCache() {
2519+
override getModuleResolutionCache() {
25202520
return this.hostProject.getCurrentProgram()?.getModuleResolutionCache();
25212521
}
25222522
}
@@ -2554,7 +2554,7 @@ export class ConfiguredProject extends Project {
25542554
projectOptions?: ProjectOptions | true;
25552555

25562556
/** @internal */
2557-
isInitialLoadPending: () => boolean = returnTrue;
2557+
override isInitialLoadPending: () => boolean = returnTrue;
25582558

25592559
/** @internal */
25602560
sendLoadingProjectFinish = false;
@@ -2593,12 +2593,12 @@ export class ConfiguredProject extends Project {
25932593
}
25942594

25952595
/** @internal */
2596-
useSourceOfProjectReferenceRedirect() {
2596+
override useSourceOfProjectReferenceRedirect() {
25972597
return this.languageServiceEnabled;
25982598
}
25992599

26002600
/** @internal */
2601-
getParsedCommandLine(fileName: string) {
2601+
override getParsedCommandLine(fileName: string) {
26022602
const configFileName = asNormalizedPath(normalizePath(fileName));
26032603
const canonicalConfigFilePath = asNormalizedPath(this.projectService.toCanonicalFileName(configFileName));
26042604
// Ensure the config file existience info is cached
@@ -2630,7 +2630,7 @@ export class ConfiguredProject extends Project {
26302630
* If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph
26312631
* @returns: true if set of files in the project stays the same and false - otherwise.
26322632
*/
2633-
updateGraph(): boolean {
2633+
override updateGraph(): boolean {
26342634
const isInitialLoad = this.isInitialLoadPending();
26352635
this.isInitialLoadPending = returnFalse;
26362636
const reloadLevel = this.pendingReload;
@@ -2658,15 +2658,15 @@ export class ConfiguredProject extends Project {
26582658
}
26592659

26602660
/** @internal */
2661-
getCachedDirectoryStructureHost() {
2661+
override getCachedDirectoryStructureHost() {
26622662
return this.directoryStructureHost as CachedDirectoryStructureHost;
26632663
}
26642664

26652665
getConfigFilePath() {
26662666
return asNormalizedPath(this.getProjectName());
26672667
}
26682668

2669-
getProjectReferences(): readonly ProjectReference[] | undefined {
2669+
override getProjectReferences(): readonly ProjectReference[] | undefined {
26702670
return this.projectReferences;
26712671
}
26722672

@@ -2682,7 +2682,7 @@ export class ConfiguredProject extends Project {
26822682
}
26832683

26842684
/** @internal */
2685-
getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined {
2685+
override getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined {
26862686
const program = this.getCurrentProgram();
26872687
return program && program.getResolvedProjectReferenceToRedirect(fileName);
26882688
}
@@ -2724,22 +2724,22 @@ export class ConfiguredProject extends Project {
27242724
/**
27252725
* Get the errors that dont have any file name associated
27262726
*/
2727-
getGlobalProjectErrors(): readonly Diagnostic[] {
2727+
override getGlobalProjectErrors(): readonly Diagnostic[] {
27282728
return filter(this.projectErrors, diagnostic => !diagnostic.file) || emptyArray;
27292729
}
27302730

27312731
/**
27322732
* Get all the project errors
27332733
*/
2734-
getAllProjectErrors(): readonly Diagnostic[] {
2734+
override getAllProjectErrors(): readonly Diagnostic[] {
27352735
return this.projectErrors || emptyArray;
27362736
}
27372737

2738-
setProjectErrors(projectErrors: Diagnostic[]) {
2738+
override setProjectErrors(projectErrors: Diagnostic[]) {
27392739
this.projectErrors = projectErrors;
27402740
}
27412741

2742-
close() {
2742+
override close() {
27432743
this.projectService.configFileExistenceInfoCache.forEach((_configFileExistenceInfo, canonicalConfigFilePath) =>
27442744
this.releaseParsedConfig(canonicalConfigFilePath));
27452745
this.projectErrors = undefined;
@@ -2848,7 +2848,7 @@ export class ExternalProject extends Project {
28482848
documentRegistry: DocumentRegistry,
28492849
compilerOptions: CompilerOptions,
28502850
lastFileExceededProgramSize: string | undefined,
2851-
public compileOnSaveEnabled: boolean,
2851+
public override compileOnSaveEnabled: boolean,
28522852
projectFilePath?: string,
28532853
pluginConfigOverrides?: Map<string, any>,
28542854
watchOptions?: WatchOptions) {
@@ -2866,13 +2866,13 @@ export class ExternalProject extends Project {
28662866
this.enableGlobalPlugins(this.getCompilerOptions(), pluginConfigOverrides);
28672867
}
28682868

2869-
updateGraph() {
2869+
override updateGraph() {
28702870
const result = super.updateGraph();
28712871
this.projectService.sendProjectTelemetry(this);
28722872
return result;
28732873
}
28742874

2875-
getExcludedFiles() {
2875+
override getExcludedFiles() {
28762876
return this.excludedFiles;
28772877
}
28782878
}

src/services/services.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ class SymbolObject implements Symbol {
722722
}
723723

724724
class TokenObject<TKind extends SyntaxKind> extends TokenOrIdentifierObject implements Token<TKind> {
725-
public kind: TKind;
725+
public override kind: TKind;
726726

727727
constructor(kind: TKind, pos: number, end: number) {
728728
super(pos, end);
@@ -731,7 +731,7 @@ class TokenObject<TKind extends SyntaxKind> extends TokenOrIdentifierObject impl
731731
}
732732

733733
class IdentifierObject extends TokenOrIdentifierObject implements Identifier {
734-
public kind: SyntaxKind.Identifier = SyntaxKind.Identifier;
734+
public override kind: SyntaxKind.Identifier = SyntaxKind.Identifier;
735735
public escapedText!: __String;
736736
declare _primaryExpressionBrand: any;
737737
declare _memberExpressionBrand: any;
@@ -753,7 +753,7 @@ class IdentifierObject extends TokenOrIdentifierObject implements Identifier {
753753
}
754754
IdentifierObject.prototype.kind = SyntaxKind.Identifier;
755755
class PrivateIdentifierObject extends TokenOrIdentifierObject implements PrivateIdentifier {
756-
public kind: SyntaxKind.PrivateIdentifier = SyntaxKind.PrivateIdentifier;
756+
public override kind: SyntaxKind.PrivateIdentifier = SyntaxKind.PrivateIdentifier;
757757
public escapedText!: __String;
758758
declare _primaryExpressionBrand: any;
759759
declare _memberExpressionBrand: any;
@@ -992,7 +992,7 @@ function findBaseOfDeclaration<T>(checker: TypeChecker, declaration: Declaration
992992
}
993993

994994
class SourceFileObject extends NodeObject implements SourceFile {
995-
public kind: SyntaxKind.SourceFile = SyntaxKind.SourceFile;
995+
public override kind: SyntaxKind.SourceFile = SyntaxKind.SourceFile;
996996
declare _declarationBrand: any;
997997
declare _localsContainerBrand: any;
998998
public fileName!: string;

0 commit comments

Comments
 (0)