From e480b6a1db645cab8e5443964b99cc1c3548715b Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Wed, 1 Nov 2023 15:03:24 -0700 Subject: [PATCH] Enable noImplicitOverride --- src/common/internal/query/query.ts | 24 +++++++++---------- src/common/util/preprocessor.ts | 2 +- src/unittests/async_expectations.spec.ts | 4 ++-- .../texture/same_subresource.spec.ts | 4 ++-- .../render_pipeline/sample_mask.spec.ts | 2 +- .../api/operation/sampling/anisotropy.spec.ts | 2 +- .../capability_checks/limits/limit_utils.ts | 12 ++++++---- src/webgpu/api/validation/error_scope.spec.ts | 2 +- src/webgpu/compat/compatibility_test.ts | 2 +- src/webgpu/gpu_test.ts | 10 ++++---- src/webgpu/idl/idl_test.ts | 2 +- tsconfig.json | 3 +-- 12 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/common/internal/query/query.ts b/src/common/internal/query/query.ts index 5534b8d31756..7c72a62f885a 100644 --- a/src/common/internal/query/query.ts +++ b/src/common/internal/query/query.ts @@ -68,8 +68,8 @@ export class TestQueryMultiFile { * Immutable (makes copies of constructor args). */ export class TestQueryMultiTest extends TestQueryMultiFile { - readonly level: TestQueryLevel = 2; - readonly isMultiFile = false as const; + override readonly level: TestQueryLevel = 2; + override readonly isMultiFile = false as const; readonly isMultiTest: boolean = true; readonly testPathParts: readonly string[]; @@ -79,11 +79,11 @@ export class TestQueryMultiTest extends TestQueryMultiFile { this.testPathParts = [...test]; } - get depthInLevel() { + override get depthInLevel() { return this.testPathParts.length; } - protected toStringHelper(): string[] { + protected override toStringHelper(): string[] { return [ this.suite, this.filePathParts.join(kPathSeparator), @@ -99,8 +99,8 @@ export class TestQueryMultiTest extends TestQueryMultiFile { * (which aren't normally supposed to change; they're marked readonly in TestParams). */ export class TestQueryMultiCase extends TestQueryMultiTest { - readonly level: TestQueryLevel = 3; - readonly isMultiTest = false as const; + override readonly level: TestQueryLevel = 3; + override readonly isMultiTest = false as const; readonly isMultiCase: boolean = true; readonly params: TestParams; @@ -110,11 +110,11 @@ export class TestQueryMultiCase extends TestQueryMultiTest { this.params = { ...params }; } - get depthInLevel() { + override get depthInLevel() { return Object.keys(this.params).length; } - protected toStringHelper(): string[] { + protected override toStringHelper(): string[] { return [ this.suite, this.filePathParts.join(kPathSeparator), @@ -130,14 +130,14 @@ export class TestQueryMultiCase extends TestQueryMultiTest { * Immutable (makes copies of constructor args). */ export class TestQuerySingleCase extends TestQueryMultiCase { - readonly level: TestQueryLevel = 4; - readonly isMultiCase = false as const; + override readonly level: TestQueryLevel = 4; + override readonly isMultiCase = false as const; - get depthInLevel() { + override get depthInLevel() { return 0; } - protected toStringHelper(): string[] { + protected override toStringHelper(): string[] { return [ this.suite, this.filePathParts.join(kPathSeparator), diff --git a/src/common/util/preprocessor.ts b/src/common/util/preprocessor.ts index 7dc2822498d8..6a26b290bcbe 100644 --- a/src/common/util/preprocessor.ts +++ b/src/common/util/preprocessor.ts @@ -54,7 +54,7 @@ class If extends Directive { } class ElseIf extends If { - applyTo(stack: StateStack) { + override applyTo(stack: StateStack) { assert(stack.length >= 1); const { allowsFollowingElse, state: siblingState } = stack.pop()!; this.checkDepth(stack); diff --git a/src/unittests/async_expectations.spec.ts b/src/unittests/async_expectations.spec.ts index 7b70029961fd..2d62978b8fc3 100644 --- a/src/unittests/async_expectations.spec.ts +++ b/src/unittests/async_expectations.spec.ts @@ -11,10 +11,10 @@ import { TestGroupTest } from './test_group_test.js'; import { UnitTest } from './unit_test.js'; class FixtureToTest extends UnitTest { - public immediateAsyncExpectation(fn: () => Promise): Promise { + public override immediateAsyncExpectation(fn: () => Promise): Promise { return super.immediateAsyncExpectation(fn); } - public eventualAsyncExpectation(fn: (niceStack: Error) => Promise): void { + public override eventualAsyncExpectation(fn: (niceStack: Error) => Promise): void { super.eventualAsyncExpectation(fn); } } diff --git a/src/webgpu/api/operation/memory_sync/texture/same_subresource.spec.ts b/src/webgpu/api/operation/memory_sync/texture/same_subresource.spec.ts index 5f05ffd0c5cf..3eed7a04ee6e 100644 --- a/src/webgpu/api/operation/memory_sync/texture/same_subresource.spec.ts +++ b/src/webgpu/api/operation/memory_sync/texture/same_subresource.spec.ts @@ -56,8 +56,8 @@ const fullscreenQuadWGSL = ` class TextureSyncTestHelper extends OperationContextHelper { private texture: GPUTexture; - public readonly kTextureSize = [4, 4] as const; - public readonly kTextureFormat: EncodableTextureFormat = 'rgba8unorm'; + public override readonly kTextureSize = [4, 4] as const; + public override readonly kTextureFormat: EncodableTextureFormat = 'rgba8unorm'; constructor( t: GPUTest, diff --git a/src/webgpu/api/operation/render_pipeline/sample_mask.spec.ts b/src/webgpu/api/operation/render_pipeline/sample_mask.spec.ts index c008c54a7d71..00069b777fcb 100644 --- a/src/webgpu/api/operation/render_pipeline/sample_mask.spec.ts +++ b/src/webgpu/api/operation/render_pipeline/sample_mask.spec.ts @@ -265,7 +265,7 @@ class F extends TextureTestMixin(GPUTest) { private sampleTexture: GPUTexture | undefined; private sampler: GPUSampler | undefined; - async init() { + override async init() { await super.init(); if (this.isCompatibility) { this.skip('WGSL sample_mask is not supported in compatibility mode'); diff --git a/src/webgpu/api/operation/sampling/anisotropy.spec.ts b/src/webgpu/api/operation/sampling/anisotropy.spec.ts index a2b9062da227..6595fa723ce4 100644 --- a/src/webgpu/api/operation/sampling/anisotropy.spec.ts +++ b/src/webgpu/api/operation/sampling/anisotropy.spec.ts @@ -53,7 +53,7 @@ class SamplerAnisotropicFilteringSlantedPlaneTest extends GPUTest { } private pipeline: GPURenderPipeline | undefined; - async init(): Promise { + override async init(): Promise { await super.init(); this.pipeline = this.device.createRenderPipeline({ diff --git a/src/webgpu/api/validation/capability_checks/limits/limit_utils.ts b/src/webgpu/api/validation/capability_checks/limits/limit_utils.ts index 370f95aae75f..fee2ea716e98 100644 --- a/src/webgpu/api/validation/capability_checks/limits/limit_utils.ts +++ b/src/webgpu/api/validation/capability_checks/limits/limit_utils.ts @@ -302,7 +302,7 @@ export class LimitTestsImpl extends GPUTestBase { defaultLimit = 0; adapterLimit = 0; - async init() { + override async init() { await super.init(); const gpu = getGPU(this.rec); this._adapter = await gpu.requestAdapter(); @@ -318,7 +318,7 @@ export class LimitTestsImpl extends GPUTestBase { return this._adapter!; } - get device(): GPUDevice { + override get device(): GPUDevice { assert(this._device !== undefined, 'device is only valid in _testThenDestroyDevice callback'); return this._device; } @@ -584,7 +584,11 @@ export class LimitTestsImpl extends GPUTestBase { /** * Calls a function that expects a validation error if shouldError is true */ - async expectValidationError(fn: () => R, shouldError: boolean = true, msg = ''): Promise { + override async expectValidationError( + fn: () => R, + shouldError: boolean = true, + msg = '' + ): Promise { return this.expectGPUErrorAsync('validation', fn, shouldError, msg); } @@ -1067,7 +1071,7 @@ export class LimitTestsImpl extends GPUTestBase { */ function makeLimitTestFixture(limit: GPUSupportedLimit): typeof LimitTestsImpl { class LimitTests extends LimitTestsImpl { - limit = limit; + override limit = limit; } return LimitTests; diff --git a/src/webgpu/api/validation/error_scope.spec.ts b/src/webgpu/api/validation/error_scope.spec.ts index 19dd1e8e0670..cb5581fed691 100644 --- a/src/webgpu/api/validation/error_scope.spec.ts +++ b/src/webgpu/api/validation/error_scope.spec.ts @@ -21,7 +21,7 @@ class ErrorScopeTests extends Fixture { return this._device; } - async init(): Promise { + override async init(): Promise { await super.init(); const gpu = getGPU(this.rec); const adapter = await gpu.requestAdapter(); diff --git a/src/webgpu/compat/compatibility_test.ts b/src/webgpu/compat/compatibility_test.ts index ebea0244ba08..bdd44b63744a 100644 --- a/src/webgpu/compat/compatibility_test.ts +++ b/src/webgpu/compat/compatibility_test.ts @@ -1,7 +1,7 @@ import { ValidationTest } from '../api/validation/validation_test.js'; export class CompatibilityTest extends ValidationTest { - async init() { + override async init() { await super.init(); if (!this.isCompatibility) { this.skip('compatibility tests do not work on non-compatibility mode'); diff --git a/src/webgpu/gpu_test.ts b/src/webgpu/gpu_test.ts index 4605dc8319eb..f9ef1f2f06ec 100644 --- a/src/webgpu/gpu_test.ts +++ b/src/webgpu/gpu_test.ts @@ -91,12 +91,12 @@ export class GPUTestSubcaseBatchState extends SubcaseBatchState { /** Provider for mismatched device. */ private mismatchedProvider: Promise | undefined; - async postInit(): Promise { + override async postInit(): Promise { // Skip all subcases if there's no device. await this.acquireProvider(); } - async finalize(): Promise { + override async finalize(): Promise { await super.finalize(); // Ensure devicePool.release is called for both providers even if one rejects. @@ -254,7 +254,7 @@ export class GPUTestSubcaseBatchState extends SubcaseBatchState { * as well as helpers that use that device. */ export class GPUTestBase extends Fixture { - public static MakeSharedState( + public static override MakeSharedState( recorder: TestCaseRecorder, params: TestParams ): GPUTestSubcaseBatchState { @@ -1074,7 +1074,7 @@ export class GPUTest extends GPUTestBase { private provider: DeviceProvider | undefined; private mismatchedProvider: DeviceProvider | undefined; - async init() { + override async init() { await super.init(); this.provider = await this.sharedState.acquireProvider(); @@ -1084,7 +1084,7 @@ export class GPUTest extends GPUTestBase { /** * GPUDevice for the test to use. */ - get device(): GPUDevice { + override get device(): GPUDevice { assert(this.provider !== undefined, 'internal error: GPUDevice missing?'); return this.provider.device; } diff --git a/src/webgpu/idl/idl_test.ts b/src/webgpu/idl/idl_test.ts index 1bcc4f9817ec..5077ac56238a 100644 --- a/src/webgpu/idl/idl_test.ts +++ b/src/webgpu/idl/idl_test.ts @@ -10,7 +10,7 @@ interface UnknownObject { * Base fixture for testing the exposed interface is correct (without actually using WebGPU). */ export class IDLTest extends Fixture { - init(): Promise { + override init(): Promise { // Ensure the GPU provider is initialized getGPU(this.rec); return Promise.resolve(); diff --git a/tsconfig.json b/tsconfig.json index 3a7d11338599..6d3b0d98bfcd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "strict": true, /* tsc lint options */ "allowUnusedLabels": false, + "noImplicitOverride": true, "noImplicitReturns": true, /* These should be caught by eslint instead */ "noFallthroughCasesInSwitch": false, @@ -18,8 +19,6 @@ "noUnusedParameters": false, "allowUnreachableCode": true, /* Compiler warnings we intentionally don't use */ - // - Would be nice, but we need to upgrade eslint first for new syntax - "noImplicitOverride": false, // - Would be nice, but produces lots of errors that probably aren't worth fixing "noUncheckedIndexedAccess": false, // - We could make our code pass this, but it doesn't seem to provide much value to us