Skip to content

Commit 73aeba6

Browse files
committed
lint
1 parent 0fdf282 commit 73aeba6

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

src/buffer-views.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function makeIntrinsicTypedArrayView(typeDef: TypeDefinition, buffer: ArrayBuffe
127127
? (buffer.byteLength - baseOffset) / sizeInBytes
128128
: numElements)
129129
: 1;
130-
// @ts-ignore
130+
// @ts-expect-error this is a bug in ts https://github.com/microsoft/TypeScript/issues/62343
131131
return new View(buffer, baseOffset, baseNumElements * effectiveNumElements);
132132
} catch {
133133
throw new Error(`unknown type: ${type}`);
@@ -524,7 +524,7 @@ function getView<T extends TypedArray>(arrayBuffer: ArrayBuffer, Ctor: TypedArra
524524
const viewsByCtor = getViewsByCtor(arrayBuffer);
525525
let view = viewsByCtor.get(Ctor);
526526
if (!view) {
527-
// @ts-ignore
527+
// @ts-expect-error this is a bug in ts https://github.com/microsoft/TypeScript/issues/62343
528528
view = new Ctor(arrayBuffer);
529529
viewsByCtor.set(Ctor, view);
530530
}

src/format-info.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { TypedArrayConstructor } from "./typed-arrays.js";
22

33
// [blockWidth, blockHeight, bytesPerBlock, units per TypedArray element, TypedArrayConstructor]
4-
type PackedFormatInfo = [number, number, number, number, TypedArrayConstructor?];
5-
64
const kFormatInfo = {
75
'rgba8unorm-srgb': [1, 1, 4, 4, Uint8Array],
86
'bgra8unorm-srgb': [1, 1, 4, 4, Uint8Array],
@@ -111,7 +109,7 @@ export function getTextureFormatInfo(format: GPUTextureFormat): FormatInfo {
111109
Type,
112110
};
113111
}
114-
112+
115113
// this is a hack! It will only work for common formats
116114
const [, channels, bits, typeName] = kTextureFormatRE.exec(format)!;
117115
// TODO: if the regex fails, use table for other formats?

src/texture-utils.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
TypedArray,
3-
TypedArrayConstructor,
43
isTypedArray,
54
} from './typed-arrays.js';
65
import {
@@ -122,7 +121,7 @@ function uploadDataToTexture(
122121
const blocksDown = Math.ceil(size[1] / blockHeight);
123122
const bytesPerRow = blocksAcross * bytesPerBlock!;
124123
const bytesPerLayer = bytesPerRow * blocksDown;
125-
const numLayers = texture.dimension == '3d'
124+
const numLayers = texture.dimension === '3d'
126125
? data.byteLength / bytesPerLayer
127126
: 1;
128127
size[0] = blocksAcross * blockWidth;
@@ -157,15 +156,15 @@ function uploadDataToTexture(
157156
* set mip level 0 layer 0 (4x4). If you pass in 24 bytes it will set mip level 0 layer 0(4x4)
158157
* and mip level 1 layer 0 (2x2). If you pass in 25 bytes it will set mip level 0, 1, 2, layer 0
159158
* If you pass in 75 bytes it would do all layers, all mip levels.
160-
*
159+
*
161160
* Note that for 3d textures there are no "layers" from the POV of this function. There is mip level 0 (which is a cube)
162161
* and mip level 1 (which is a cube). So a '3d' 4x4x3 r8unorm texture, you're expected to provide 48 bytes for mip level 0
163162
* where as for '2d' 4x4x3 you're expected to provide 16 bytes for mip level 0 layer 0. If you want to provide data
164163
* to each layer separately then pass them in as an array
165-
*
164+
*
166165
* ```js
167166
* // fill layer 0, mips 0
168-
* copySourcesToTexture(device, tex_4x4x3_r8_2d, [data16Bytes]);
167+
* copySourcesToTexture(device, tex_4x4x3_r8_2d, [data16Bytes]);
169168
*
170169
* // fill layer 0, mips 0, 1, 2
171170
* copySourcesToTexture(device, tex_4x4x3_r8_2d, [data25Bytes]);
@@ -179,12 +178,12 @@ function uploadDataToTexture(
179178
* // fills layer 0, mips 0, layer 1, mips 0, layer 2, mips 0
180179
* copySourcesToTexture(device, tex_4x4x3_r8_2d, [data16Bytes, data16bytes, data16Bytes]);
181180
* ```
182-
*
181+
*
183182
* This also works for compressed textures, so you can load an entire compressed texture, all mips, all layers in one call.
184183
* See texture-utils-tests.js for examples.
185-
*
184+
*
186185
* If the source is an `Array` is it converted to a typed array that matches the format.
187-
*
186+
*
188187
* * ????8snorm ????8sint -> `Int8Array`
189188
* * ????8unorm ????8uint -> `Uint8Array`
190189
* * ????16snorm ???16sint -> `Int16Array`
@@ -273,7 +272,6 @@ export function copySourceToTexture(
273272
* @property mipLevelCount Defaults to 1 or the number of mips needed for a full mipmap if `mips` is true
274273
*/
275274
export type CreateTextureOptions = CopyTextureOptions & {
276-
mips?: boolean,
277275
usage?: GPUTextureUsageFlags,
278276
format?: GPUTextureFormat,
279277
mipLevelCount?: number,

src/typed-arrays.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class TypedArrayViewGenerator {
4141
this.byteOffset += numBytes;
4242
}
4343
getView<T extends TypedArray>(Ctor: TypedArrayConstructor, numElements: number): T {
44-
// @ts-ignore
44+
// @ts-expect-error this is a bug in ts https://github.com/microsoft/TypeScript/issues/62343
4545
const view = new Ctor(this.arrayBuffer, this.byteOffset, numElements);
4646
this.byteOffset += view.byteLength;
4747
return view as T;

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function range<T>(count: number, fn: (i: number) => T) {
99
}
1010

1111
const isIterable = (v: any) =>
12-
v != null && typeof v[Symbol.iterator] === 'function';
12+
v !== null && typeof v[Symbol.iterator] === 'function';
1313

1414
export function normalizeExtent3D(extent: GPUExtent3D): [number, number, number] {
1515
if (!extent) {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"target": "ESNext",
55
"module": "NodeNext",
6-
"outDir": "dist/1.x",
6+
"outDir": "dist/2.x",
77
"moduleResolution": "NodeNext",
88
"declaration": true,
99
"typeRoots": [

0 commit comments

Comments
 (0)