Skip to content

Commit

Permalink
Fixes for new tsc and eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Nov 1, 2023
1 parent 80c0f08 commit bd10f98
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 15 deletions.
4 changes: 4 additions & 0 deletions src/common/internal/file_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ interface TestFileLoaderEventMap {
finish: MessageEvent<void>;
}

// Override the types for addEventListener/removeEventListener so the callbacks can be used as
// strongly-typed.
/* eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging */
export interface TestFileLoader extends EventTarget {
addEventListener<K extends keyof TestFileLoaderEventMap>(
type: K,
Expand All @@ -53,6 +56,7 @@ export interface TestFileLoader extends EventTarget {
}

// Base class for DefaultTestFileLoader and FakeTestFileLoader.
/* eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging */
export abstract class TestFileLoader extends EventTarget {
abstract listing(suite: string): Promise<TestSuiteListing>;
protected abstract import(path: string): Promise<SpecFile>;
Expand Down
6 changes: 3 additions & 3 deletions src/common/internal/query/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class TestQueryMultiFile {
*/
export class TestQueryMultiTest extends TestQueryMultiFile {
readonly level: TestQueryLevel = 2;
readonly isMultiFile: false = false;
readonly isMultiFile = false as const;
readonly isMultiTest: boolean = true;
readonly testPathParts: readonly string[];

Expand Down Expand Up @@ -100,7 +100,7 @@ export class TestQueryMultiTest extends TestQueryMultiFile {
*/
export class TestQueryMultiCase extends TestQueryMultiTest {
readonly level: TestQueryLevel = 3;
readonly isMultiTest: false = false;
readonly isMultiTest = false as const;
readonly isMultiCase: boolean = true;
readonly params: TestParams;

Expand Down Expand Up @@ -131,7 +131,7 @@ export class TestQueryMultiCase extends TestQueryMultiTest {
*/
export class TestQuerySingleCase extends TestQueryMultiCase {
readonly level: TestQueryLevel = 4;
readonly isMultiCase: false = false;
readonly isMultiCase = false as const;

get depthInLevel() {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/common/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export function assertNotSettledWithinTime(
const handle = timeout(() => {
resolve(undefined);
}, ms);
p.finally(() => clearTimeout(handle));
void p.finally(() => clearTimeout(handle));
});
return Promise.race([rejectWhenSettled, timeoutPromise]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/unittests/params_builder_and_utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { assert, objectEquals } from '../common/util/util.js';
import { UnitTest } from './unit_test.js';

class ParamsTest extends UnitTest {
expectParams<CaseP, SubcaseP>(
expectParams<CaseP extends {}, SubcaseP extends {}>(
act: ParamsBuilderBase<CaseP, SubcaseP>,
exp: CaseSubcaseIterable<{}, {}>,
caseFilter: TestParams | null = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ g.test('precision')
.params(u => u.combine('isAsync', [true, false]))
.fn(async t => {
const c1 = 3.14159;
const c2 = 3.141592653589793238;
const c2 = 3.141592653589793;
await t.ExpectShaderOutputWithConstants(
t.params.isAsync,
// These values will get rounded to f32 and createComputePipeline, so the values coming out from the shader won't be the exact same one as shown here.
Expand Down
7 changes: 2 additions & 5 deletions src/webgpu/api/operation/render_pipeline/overrides.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,9 @@ g.test('precision')
fragmentConstants: { R: 3.14159 } as Record<string, GPUPipelineConstantValue>,
},
{
expected: { R: 3.141592653589793238, G: 1.0, B: 1.0, A: 1.0 },
expected: { R: 3.141592653589793, G: 1.0, B: 1.0, A: 1.0 },
vertexConstants: {},
fragmentConstants: { R: 3.141592653589793238 } as Record<
string,
GPUPipelineConstantValue
>,
fragmentConstants: { R: 3.141592653589793 } as Record<string, GPUPipelineConstantValue>,
},
])
)
Expand Down
2 changes: 1 addition & 1 deletion src/webgpu/shader/execution/expression/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export async function run(
pipelineCache
);
checkBatch();
t.queue.onSubmittedWorkDone().finally(batchFinishedCallback);
void t.queue.onSubmittedWorkDone().finally(batchFinishedCallback);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ g.test('offscreenCanvas,snapshot')
let snapshot: HTMLImageElement | ImageBitmap;
switch (t.params.snapshotType) {
case 'convertToBlob': {
if (typeof offscreenCanvas.convertToBlob === undefined) {
if (typeof offscreenCanvas.convertToBlob === 'undefined') {
t.skip("Browser doesn't support OffscreenCanvas.convertToBlob");
return;
}
Expand All @@ -292,7 +292,7 @@ g.test('offscreenCanvas,snapshot')
break;
}
case 'transferToImageBitmap': {
if (typeof offscreenCanvas.transferToImageBitmap === undefined) {
if (typeof offscreenCanvas.transferToImageBitmap === 'undefined') {
t.skip("Browser doesn't support OffscreenCanvas.transferToImageBitmap");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/webgpu/web_platform/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function startPlayingAndWaitForVideo(
true
);

if ('requestVideoFrameCallback' in video) {
if (video.requestVideoFrameCallback) {
video.requestVideoFrameCallback(() => {
callbackAndResolve();
});
Expand Down

0 comments on commit bd10f98

Please sign in to comment.